Mailing List archive

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

[vdr] OSD with 256 colors



For those of you who would like to experiment with a 256 color OSD,
you might want to do this:

- get the latest driver from the CVS (previous driver versions were
  extremely slow when setting a 256 color palette for the OSD)

- change the line

  #define MAXNUMCOLORS 16

  in VDR/osdbase.h to

  #define MAXNUMCOLORS 256

- apply the attached patch to PLUGINS/src/osddemo/osddemo.c for a quick
  demonstration of a 256 color OSD (it simply draws a 256 color palette)

Note that due to the limited OSD memory you can't have a full screen
256 color OSD, but something like 256*256 pixel (as in the example)
can be done easily (the maximum of x*y should not exceed 80000).

One possible application for this could be a PIP (Picture In Picture)
plugin that displays a (still) picture of some image, which may be
derived from some file on disk, or some grabbed image from another
channel. You could even implement a display bar at the top, bottom,
left or right edge of the screen and display like, for instance,
four different pictures. Or, you could implement anything else that
needs more than 16 colors...

Klaus
-- 
_______________________________________________________________

Klaus Schmidinger                       Phone: +49-8635-6989-10
CadSoft Computer GmbH                   Fax:   +49-8635-6989-40
Hofmark 2                               Email:   kls@cadsoft.de
D-84568 Pleiskirchen, Germany           URL:     www.cadsoft.de
_______________________________________________________________
--- PLUGINS/src/osddemo/osddemo.c	2002/12/13 15:02:01	1.2
+++ PLUGINS/src/osddemo/osddemo.c	2003/06/15 11:26:50
@@ -43,13 +43,47 @@
 {
   osd = cOsd::OpenRaw(100, 50);
   if (osd) {
-     osd->Create(0, 0, 100, 200, 4);
-     osd->AddColor(clrBackground);
-     osd->AddColor(clrRed);
-     osd->AddColor(clrGreen);
-     osd->AddColor(clrYellow);
-     osd->AddColor(clrBlue);
-     osd->Clear();
+     int d = 256;
+     osd->Create(0, 0, d, d, 8, false);
+     for (int x = 0; x < 16; x++) {
+         for (int y = 0; y < 16; y++) {
+             int h = x * 359 / 16;
+             int s = 255 - y * 255 / 16;
+             int v = 200;
+
+             // this code was borrowed from Qt (www.trolltech.com):
+             int r=v, g=v, b=v;
+             if ( s == 0 || h == -1 ) {                  // achromatic case
+                 // Ignore
+             } else {                                    // chromatic case
+                 if ( (uint)h >= 360 )
+                     h %= 360;
+                 uint f = h%60;
+                 h /= 60;
+                 uint p = (uint)(2*v*(255-s)+255)/510;
+                 uint q, t;
+                 if ( h&1 ) {
+                     q = (uint)(2*v*(15300-s*f)+15300)/30600;
+                     switch( h ) {
+                         case 1: r=(int)q; g=(int)v, b=(int)p; break;
+                         case 3: r=(int)p; g=(int)q, b=(int)v; break;
+                         case 5: r=(int)v; g=(int)p, b=(int)q; break;
+                     }
+                 } else {
+                     t = (uint)(2*v*(15300-(s*(60-f)))+15300)/30600;
+                     switch( h ) {
+                         case 0: r=(int)v; g=(int)t, b=(int)p; break;
+                         case 2: r=(int)p; g=(int)v, b=(int)t; break;
+                         case 4: r=(int)t; g=(int)p, b=(int)v; break;
+                     }
+                 }
+             }
+             // end of code borrowed from Qt
+
+             int c = 0xFF000000 | ((b & 0xFF) << 16) | ((g & 0xFF) << 8) | (r & 0xFF);
+             osd->Fill(x * d / 16, y * d / 16, (x + 1) * d / 16, (y + 1) * d / 16, eDvbColor(c));
+             }
+         }
      osd->Flush();
      }
 }

Home | Main Index | Thread Index