1 #include <lib/gdi/gfbdc.h>
3 #include <lib/base/init.h>
4 #include <lib/base/init_num.h>
5 #include <lib/base/econfig.h>
7 gFBDC *gFBDC::instance;
15 eFatal("no framebuffer available");
17 fb->SetMode(720, 576, 8);
18 for (int y=0; y<576; y++) // make whole screen transparent
19 memset(fb->lfb+y*fb->Stride(), 0x00, fb->Stride());
26 pixmap->stride=fb->Stride();
29 pixmap->clut.colors=256;
30 pixmap->clut.data=new gRGB[pixmap->clut.colors];
31 memset(pixmap->clut.data, 0, sizeof(*pixmap->clut.data)*pixmap->clut.colors);
42 void gFBDC::calcRamp()
45 float fgamma=gamma ? gamma : 1;
48 for (int i=0; i<256; i++)
50 float raw=i/255.0; // IIH, float.
51 float corr=pow(raw, fgamma) * 256.0;
53 int d=corr * (float)(256-brightness) / 256 + brightness;
60 rampalpha[i]=i*alpha/256;
63 for (int i=0; i<256; i++)
67 d=(d-128)*(gamma+64)/(128+64)+128;
68 d+=brightness-128; // brightness correction
75 /* if ( eDVB::getInstance()->getmID == 1 )
76 rampalpha[i]=i*alpha/65535;
78 rampalpha[i]=i*alpha/256;
81 rampalpha[255]=255; // transparent BLEIBT bitte so.
84 void gFBDC::setPalette()
86 if (!pixmap->clut.data)
89 for (int i=0; i<256; ++i)
91 fb->CMAP()->red[i]=ramp[pixmap->clut.data[i].r]<<8;
92 fb->CMAP()->green[i]=ramp[pixmap->clut.data[i].g]<<8;
93 fb->CMAP()->blue[i]=ramp[pixmap->clut.data[i].b]<<8;
94 fb->CMAP()->transp[i]=rampalpha[pixmap->clut.data[i].a]<<8;
95 if (!fb->CMAP()->red[i])
96 fb->CMAP()->red[i]=0x100;
101 void gFBDC::exec(gOpcode *o)
105 case gOpcode::setPalette:
117 gFBDC *gFBDC::getInstance()
122 void gFBDC::setAlpha(int a)
130 void gFBDC::setBrightness(int b)
138 void gFBDC::setGamma(int g)
146 void gFBDC::saveSettings()
148 eConfig::getInstance()->setKey("/ezap/osd/alpha", alpha);
149 eConfig::getInstance()->setKey("/ezap/osd/gamma", gamma);
150 eConfig::getInstance()->setKey("/ezap/osd/brightness", brightness);
153 void gFBDC::reloadSettings()
155 if (eConfig::getInstance()->getKey("/ezap/osd/alpha", alpha))
157 if (eConfig::getInstance()->getKey("/ezap/osd/gamma", gamma))
159 if (eConfig::getInstance()->getKey("/ezap/osd/brightness", brightness))
166 eAutoInitP0<gFBDC> init_gFBDC(eAutoInitNumbers::graphic+1, "GFBDC");