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, 32);
19 for (int y=0; y<576; y++) // make whole screen transparent
20 memset(fb->lfb+y*fb->Stride(), 0x00, fb->Stride());
27 surface.stride = fb->Stride();
28 surface.data = fb->lfb;
29 surface.clut.colors=256;
30 surface.clut.data=new gRGB[surface.clut.colors];
32 m_pixmap = new gPixmap(&surface);
34 memset(surface.clut.data, 0, sizeof(*surface.clut.data)*surface.clut.colors);
44 void gFBDC::calcRamp()
47 float fgamma=gamma ? gamma : 1;
50 for (int i=0; i<256; i++)
52 float raw=i/255.0; // IIH, float.
53 float corr=pow(raw, fgamma) * 256.0;
55 int d=corr * (float)(256-brightness) / 256 + brightness;
62 rampalpha[i]=i*alpha/256;
65 for (int i=0; i<256; i++)
69 d=(d-128)*(gamma+64)/(128+64)+128;
70 d+=brightness-128; // brightness correction
77 rampalpha[i]=i*alpha/256;
80 rampalpha[255]=255; // transparent BLEIBT bitte so.
83 void gFBDC::setPalette()
85 if (!surface.clut.data)
88 for (int i=0; i<256; ++i)
90 fb->CMAP()->red[i]=ramp[surface.clut.data[i].r]<<8;
91 fb->CMAP()->green[i]=ramp[surface.clut.data[i].g]<<8;
92 fb->CMAP()->blue[i]=ramp[surface.clut.data[i].b]<<8;
93 fb->CMAP()->transp[i]=rampalpha[surface.clut.data[i].a]<<8;
94 if (!fb->CMAP()->red[i])
95 fb->CMAP()->red[i]=0x100;
100 void gFBDC::exec(gOpcode *o)
104 case gOpcode::setPalette:
116 void gFBDC::setAlpha(int a)
124 void gFBDC::setBrightness(int b)
132 void gFBDC::setGamma(int g)
140 void gFBDC::saveSettings()
142 eConfig::getInstance()->setKey("/ezap/osd/alpha", alpha);
143 eConfig::getInstance()->setKey("/ezap/osd/gamma", gamma);
144 eConfig::getInstance()->setKey("/ezap/osd/brightness", brightness);
147 void gFBDC::reloadSettings()
149 if (eConfig::getInstance()->getKey("/ezap/osd/alpha", alpha))
151 if (eConfig::getInstance()->getKey("/ezap/osd/gamma", gamma))
153 if (eConfig::getInstance()->getKey("/ezap/osd/brightness", brightness))
160 // eAutoInitPtr<gFBDC> init_gFBDC(eAutoInitNumbers::graphic-1, "GFBDC");
162 eAutoInitPtr<gFBDC> init_gFBDC(eAutoInitNumbers::graphic-1, "GFBDC");