Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: non-transparent osd skin



On Mon, 2004-10-18 at 17:22 +0200, Klaus Schmidinger wrote:
> Torgeir Veimo wrote:
> > 
> Just take a look at what's done in VDR/dvbosd.c.
> cDvbOsd is derived from cOsd and implements what it takes
> to get the bitmap(s) displayed on the screen. Your implemenation
> of a derived cOsd class may do different things, but eventually
> it will send the bitmap data to some display facility in the
> Flush() function. There you can do your dithering stuff first.
> 
> If you need full control over text drawing, you can implement
> the DrawText() function as well.

This is for creating a plugin that replaces the built in VDR osd?

I tried a simpler approach by just dithering in softdevice's Xv output
class just before the OSD is drawn using X calls. There's a check to
counter jagged edges for fonts as well, but it creates a shadow to the
right of solid areas as well. 

-- 
Torgeir Veimo <torgeir@pobox.com>
Index: video-xv.c
===================================================================
RCS file: /cvsroot/softdevice/softdevice/video-xv.c,v
retrieving revision 1.3
diff -u -r1.3 video-xv.c
--- video-xv.c	18 Oct 2004 03:32:37 -0000	1.3
+++ video-xv.c	18 Oct 2004 15:46:00 -0000
@@ -23,12 +23,16 @@
 #include <sys/ioctl.h>
 #include <fcntl.h>
 #include <vdr/plugin.h>
+#include <vdr/osd.h>
 #include "video-xv.h"
 #include "xscreensaver.h"
 #include "utils.h"
 
 #define PATCH_VERSION "007_pre_2+"
 
+#define OPACITY_THRESHOLD 0x8F
+#define TRANSPARENT_THRESHOLD 0x0F
+
 static pthread_mutex_t  xv_mutex = PTHREAD_MUTEX_INITIALIZER;
 static cXvRemote        *xvRemote = NULL;
 static cScreensaver     *xScreensaver = NULL;
@@ -869,6 +873,27 @@
   }
 }
 
+void cXvVideoOut::Dither(cBitmap *Bitmap)
+{
+  bool previous = false;
+  for (int y = 0; y <= Bitmap->Height(); y++) {
+    previous = false; // no carry over between lines
+    for (int x = 0; x <= Bitmap->Width(); x++) {
+      unsigned int opacity = (Bitmap->Color(*Bitmap->Data(x, y)) >> 24);
+      if (opacity < OPACITY_THRESHOLD && opacity > TRANSPARENT_THRESHOLD) {
+        if ((x % 2 == 1 && y % 2 == 1) || x % 2 == 0 && y % 2 == 0 || previous) {
+          Bitmap->DrawRectangle(x, y, x, y, clrBlack);
+        } else {
+          Bitmap->DrawRectangle(x, y, x, y, clrTransparent);
+        }
+        previous = false;
+      } else {
+        previous = true;
+      }
+    }
+  }
+}
+
 #if VDRVERSNUM >= 10307
 void cXvVideoOut::Refresh(cBitmap *Bitmap)
 {
@@ -878,6 +903,7 @@
     return;
   if (OSDpresent)
   {
+    Dither(Bitmap);
     Draw(Bitmap, osd_buffer, osd_image->bytes_per_line);
 
     pthread_mutex_lock(&xv_mutex);
Index: video-xv.h
===================================================================
RCS file: /cvsroot/softdevice/softdevice/video-xv.h,v
retrieving revision 1.2
diff -u -r1.2 video-xv.h
--- video-xv.h	8 Aug 2004 20:55:59 -0000	1.2
+++ video-xv.h	18 Oct 2004 15:46:00 -0000
@@ -129,8 +129,8 @@
   uint64_t lastUpdate;
 
   bool              fullScreen;
   void toggleFullScreen(void);
-
+  void Dither(cBitmap *Bitmap);
 
 public:
   cXvVideoOut();

Home | Main Index | Thread Index