dithernPatch and Demo

Message ID 43BBF691.8090308@gmx.de
State New
Headers

Commit Message

Patrick Fischer Jan. 4, 2006, 4:23 p.m. UTC
  In the last days of 2005 I have written an small but effect full patch 
for VDR.
It allows the developer to mix two Colors. So if your Memory only allows 
you to use 4 Colors, you can mix them to 16 Colors :-)
If you can use 8 Colors then you can mix them to 64 Colors.
This is the theory. Not all colors looks nice. But you can use them.
An other limitation is that you only can use the new colors for rectangles.
(maybe I will expand this to the other elements)

If you mix two colors the pixel will be alternating plotted.
Like:

            if(((x%2)&&(y%2)) || (!(x%2)&&!(y%2)))
              SetIndex(x, y, color1);
            else
              SetIndex(x, y, color2);

In the case of using mixed Colors, the OSD will be drawn a little bit 
slower. (you will not notice it)
In the case of normal drawing nothing will be different. Full compatibility.

I have written a demoplugin to show how it works.
You can use the demoplugin with or without the patch.
If you have patched vdr, you need to  define #define USEVDRWITHPATCH at 
the beginning of the ditherndemo.c file. (commented out)

If you use the demo without patching the vdr, it will work much slower.


DithernDemo
You can install the demo like every other plugin.
if you start it, you can change the base colors by pressing the color 
buttons on your RC.
The first line shows you the base colors. All other colors are mixed.

I have written this demo to test this Plugin on my Activy300. So it is 
limited to 4 Colors.
With this patch we can create other skins with more colors.

If Klaus find it usefully, I will look for the other elements.

Greetings
Patrick
  

Comments

Frank Jan. 4, 2006, 8:29 p.m. UTC | #1
> In the last days of 2005 I have written an small but effect full patch
> for VDR.
> It allows the developer to mix two Colors. So if your Memory only allows
> you to use 4 Colors, you can mix them to 16 Colors :-)
> If you can use 8 Colors then you can mix them to 64 Colors.
> This is the theory. Not all colors looks nice. But you can use them.
> An other limitation is that you only can use the new colors for
rectangles.
> (maybe I will expand this to the other elements)
>...

Thanks.

I have attached a patch for the demonstration because on my system with
FF-cards the plugin will create but not osd is not show
-> ("wrong aligment" in log).
-> Width will now defined with "& ~0x07"
Three other changes also included:
1. osd will only deleted if it exist before creating osd (i'm not sure if it
needed)
2. i think the definition of area was to big (height and width is now
decreased by 1)
3. without the patch for vdr only 1 color is used

Greetings
Frank
  
Frank Jan. 5, 2006, 11:54 p.m. UTC | #2
Hello,

i have just a second patch for the demo:

- no need to reopen the OSD for every keypress

but somewhere maybe a bug in the demo, not everytime,
but on some keypresses, without a scheme on my mind,
in the log are the messages:
...too many different colors used in palette
...last message repeated 7578 times

Greetings
Frank
  

Patch

--- ../vdr-1.3.37_orig/osd.c	2005-11-04 15:19:31.000000000 +0100
+++ osd.c	2006-01-04 16:00:55.000000000 +0100
@@ -435,7 +435,7 @@ 
      }
 }
 
-void cBitmap::DrawRectangle(int x1, int y1, int x2, int y2, tColor Color)
+void cBitmap::DrawRectangle(int x1, int y1, int x2, int y2, tColor Color, tColor Color2)
 {
   if (bitmap && Intersects(x1, y1, x2, y2)) {
      if (Covers(x1, y1, x2, y2))
@@ -449,10 +449,21 @@ 
      x2 = min(x2, width - 1);
      y2 = min(y2, height - 1);
      tIndex c = Index(Color);
-     for (int y = y1; y <= y2; y++)
+     if(!Color2){
+       for (int y = y1; y <= y2; y++)
          for (int x = x1; x <= x2; x++)
-             SetIndex(x, y, c);
+              SetIndex(x, y, c);
+     }else{
+     //Color2 is set, so use dithern
+       tIndex c2 = Index(Color2);     
+       for (int y = y1; y <= y2; y++)
+         for (int x = x1; x <= x2; x++)
+            if(((x%2)&&(y%2)) || (!(x%2)&&!(y%2)))
+              SetIndex(x, y, c);
+            else 
+              SetIndex(x, y, c2);
      }
+  }
 }
 
 void cBitmap::DrawEllipse(int x1, int y1, int x2, int y2, tColor Color, int Quadrants)
@@ -695,10 +706,10 @@ 
       bitmaps[i]->DrawText(x, y, s, ColorFg, ColorBg, Font, Width, Height, Alignment);
 }
 
-void cOsd::DrawRectangle(int x1, int y1, int x2, int y2, tColor Color)
+void cOsd::DrawRectangle(int x1, int y1, int x2, int y2, tColor Color, tColor Color2)
 {
   for (int i = 0; i < numBitmaps; i++)
-      bitmaps[i]->DrawRectangle(x1, y1, x2, y2, Color);
+      bitmaps[i]->DrawRectangle(x1, y1, x2, y2, Color,Color2);
 }
 
 void cOsd::DrawEllipse(int x1, int y1, int x2, int y2, tColor Color, int Quadrants)
--- ../vdr-1.3.37_orig/osd.h	2005-06-19 12:35:25.000000000 +0200
+++ osd.h	2006-01-04 15:57:18.000000000 +0100
@@ -169,7 +169,7 @@ 
        ///< will be drawn into a rectangle with the given size and the given
        ///< Alignment (default is top-left). If ColorBg is clrTransparent, no
        ///< background pixels will be drawn, which allows drawing "transparent" text.
-  void DrawRectangle(int x1, int y1, int x2, int y2, tColor Color);
+  void DrawRectangle(int x1, int y1, int x2, int y2, tColor Color, tColor Color2=0);
        ///< Draws a filled rectangle defined by the upper left (x1, y1) and lower right
        ///< (x2, y2) corners with the given Color. If the rectangle covers the entire
        ///< bitmap area, the color palette will be reset, so that new colors can be
@@ -290,7 +290,7 @@ 
        ///< will be drawn into a rectangle with the given size and the given
        ///< Alignment (default is top-left). If ColorBg is clrTransparent, no
        ///< background pixels will be drawn, which allows drawing "transparent" text.
-  virtual void DrawRectangle(int x1, int y1, int x2, int y2, tColor Color);
+  virtual void DrawRectangle(int x1, int y1, int x2, int y2, tColor Color, tColor Color2=0);
        ///< Draws a filled rectangle defined by the upper left (x1, y1) and lower right
        ///< (x2, y2) corners with the given Color.
   virtual void DrawEllipse(int x1, int y1, int x2, int y2, tColor Color, int Quadrants = 0);