Mailing List archive

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

[vdr] Re: AddColor() / SetColor()



Klaus Schmidinger <Klaus.Schmidinger@cadsoft.de> wrote:

> > Ok this means if I have a cBitmap bm and want to set it into an area
> > that has been drawn on before, I would do a DrawRectangle on the
> > whole area bm covers with bm->Color(0) and then do DrawBitmap.
> > Thanks for the Hint!:-)
> > 
> > But wouldn't it make sense to do the same check (and possibly reset)
> > in DrawBitmap, too? (Just a question)
> 
> You're right, this makes sense in any function that covers the entire
> bitmap. I'll implement this in the next version.

is it only me, who thinks the whole osd stuff is more complicated then
it should be? ;-) AFAICS, the main thing about it, is that different
areas on the osd can have different palettes. thats what this is the
SetAreas() methode for. but why isn't the palette part of the Area
struct? also i don't understand why cBitmap is derived from cPalette.
IMHO, a Bitmap HAS a Palette but it isn't one (OO has or is relation).

all i want to do is:

open an osd with given x, y, w, h, depth
set the palette for this osd (16/256 color table)
set pixels within the osd (x, y, idx)
call an update function (Flush())
close the osd

can anybody point me to the most fitting aproach to do this with the osd
api? my current solution seems to be non optimal:

#define COLOR(R,G,B,A) (B+(G<<8)+(R<<16)+(A<<24))
#define PALETTE(I)     ((tColor)colortable[I])

static cOsd *screen = NULL;
static int W, H, colortable[COLORS];

int
palette() {
   colortable[0]  = COLOR(0x00, 0x00, 0x00, 0x7F); // Background
   colortable[1]  = COLOR(0xFC, 0xFC, 0xFC, 0xFF); // White
   colortable[2]  = COLOR(0xFC, 0x14, 0x14, 0xFF); // Red
   colortable[3]  = COLOR(0x00, 0xFC, 0xFC, 0xFF); // Cyan
   colortable[4]  = COLOR(0xB0, 0x00, 0xFC, 0xFF); // Magenta
   colortable[5]  = COLOR(0x24, 0xFC, 0x24, 0xFF); // Green
   colortable[6]  = COLOR(0x00, 0x00, 0xFC, 0xFF); // Blue
   colortable[7]  = COLOR(0xFC, 0xC0, 0x24, 0xFF); // Yellow
   colortable[8]  = COLOR(0xC0, 0xA0, 0x00, 0xFF); // Orange
   colortable[9]  = COLOR(0xFF, 0xA0, 0x00, 0xFF); // Orange2
   colortable[10] = COLOR(0xF0, 0x80, 0x80, 0xFF); // Pink
   colortable[11] = COLOR(0x00, 0xFF, 0xFF, 0xFF); // Cyan2
   colortable[12] = COLOR(0xFF, 0x00, 0xFF, 0xFF); // Purple2
   colortable[13] = COLOR(0x00, 0xFF, 0x00, 0xFF); // Green2
   colortable[14] = COLOR(0x00, 0xA0, 0xFF, 0xFF); // Blue2
   colortable[15] = COLOR(0x00, 0x00, 0x00, 0xFF); // Black
   for (int i=0; i<COLORS; i++) {
      screen->GetBitmap(0)->SetColor(i, PALETTE(i));
   }
   return (0);
}

int
pixel(int x, int y, int idx) {
   screen->DrawPixel(x, y, PALETTE(idx));
   return (0);
}

int
open(int x, int y, int w, int h) {
   if (screen) return (-1);
   tArea win = { 0, 0, w-1, h-1, DEPTH };

   if (!(screen = cOsdProvider::NewOsd(x, y))) {
      if (!(screen = cOsdProvider::NewOsd(x, y))) {
         return(-1);
      }
   }
   screen->SetAreas(&win, 1);
   palette(PAL_VDR);
   screen->Flush();
}

int
close(void) {
   if (screen) {
      delete (screen);
      return (0);
   }
   return (-1);
}

int
update(void) {
   if (screen) {
      screen->Flush();
      return (0);
   }
   return (-1);
}

thx ...
clemens


-- 
Info:
To unsubscribe send a mail to ecartis@linuxtv.org with "unsubscribe vdr" as subject.



Home | Main Index | Thread Index