summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManiac <maniac>2011-05-14 21:33:09 +0200
committerManiac <maniac>2011-05-14 21:33:09 +0200
commit7435f69e68348ddfd9a0d63ed1599886f5f74dd8 (patch)
treee22be254758bd57dfac44c058cb6ca0dee2c7ffd
parent5c50e932568d197c9b2579c6d5c6feeac5ef4b3a (diff)
downloadvdr-plugin-skinpearlhd-7435f69e68348ddfd9a0d63ed1599886f5f74dd8.tar.gz
vdr-plugin-skinpearlhd-7435f69e68348ddfd9a0d63ed1599886f5f74dd8.tar.bz2
use pixmap for drawing pictures in truecolor mode
-rw-r--r--bitmap.c50
-rw-r--r--bitmap.h3
-rw-r--r--pearlhd.c74
3 files changed, 110 insertions, 17 deletions
diff --git a/bitmap.c b/bitmap.c
index 737bb52..029a909 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -1,4 +1,5 @@
#include "bitmap.h"
+#include <math.h>
using namespace Magick;
@@ -15,8 +16,11 @@ bool cOSDImageBitmap::Load(cBitmap &bmp, const char *Filename, int width, int he
#ifdef DEBUG_SKINPEARLHD
int start = cTimeMs::Now();
#endif
-
+
int w, h;
+ if (bpp > 8)
+ bpp = 8;
+ int colors = pow(2,bpp);
Image osdImage;
osdImage.read(Filename);
@@ -25,7 +29,7 @@ bool cOSDImageBitmap::Load(cBitmap &bmp, const char *Filename, int width, int he
osdImage.opacity(OpaqueOpacity);
osdImage.backgroundColor( Color(0, 0, 0, 0));
osdImage.quantizeColorSpace(RGBColorspace);
- osdImage.quantizeColors(bpp);
+ osdImage.quantizeColors(colors);
osdImage.quantize();
}
@@ -57,3 +61,45 @@ bool cOSDImageBitmap::Load(cBitmap &bmp, const char *Filename, int width, int he
return false;
}
}
+
+#if VDRVERSNUM > 10716
+bool cOSDImageBitmap::Load(cImage &bmp, const char *Filename, int width, int height)
+{
+ try
+ {
+ #ifdef DEBUG_SKINPEARLHD
+ int start = cTimeMs::Now();
+ #endif
+
+ int w, h;
+ Image osdImage;
+ osdImage.read(Filename);
+
+ if (height != 0 || width != 0)
+ osdImage.sample( Geometry(width, height));
+ w = osdImage.columns();
+ h = osdImage.rows();
+
+ const PixelPacket *pixels = osdImage.getConstPixels(0, 0, w, h);
+
+ for (int iy = 0; iy < h; ++iy) {
+ for (int ix = 0; ix < w; ++ix) {
+ tColor col = (~int(pixels->opacity * 255 / MaxRGB) << 24)
+ | (int(pixels->green * 255 / MaxRGB) << 8)
+ | (int(pixels->red * 255 / MaxRGB) << 16)
+ | (int(pixels->blue * 255 / MaxRGB) );
+ bmp.SetPixel(cPoint(ix, iy), col);
+ ++pixels;
+ }
+ }
+ #ifdef DEBUG_SKINPEARLHD
+ printf ("skinpearlhd: bitmap render took %d ms\n", int(cTimeMs::Now()-start));
+ #endif
+ return true;
+ }
+ catch (...)
+ {
+ return false;
+ }
+}
+#endif
diff --git a/bitmap.h b/bitmap.h
index 2bfb04e..7e2999b 100644
--- a/bitmap.h
+++ b/bitmap.h
@@ -14,6 +14,9 @@ public:
cOSDImageBitmap();
~cOSDImageBitmap();
bool Load(cBitmap &bmp, const char *Filename, int width=0, int height=0, int bpp=0);
+ #if VDRVERSNUM > 10716
+ bool Load(cImage &bmp, const char *Filename, int width, int height);
+ #endif
private:
};
diff --git a/pearlhd.c b/pearlhd.c
index 7009418..dfd4093 100644
--- a/pearlhd.c
+++ b/pearlhd.c
@@ -208,20 +208,49 @@ void cSkinPearlHDDisplayChannel::SetChannel(const cChannel *Channel, int Number)
std::string displayLogoPath = logoPath + Channel->Name() + "." + logoFormat;
cOSDImageBitmap osdbitmap;
- cBitmap logo (1, 1, bpp);
switch (PearlHDConfig.ChannelLogoPos)
{
case 1 :
- if(osdbitmap.Load(logo, displayLogoPath.c_str(), 64, 48)){
- osd->DrawBitmap(x1ChannelInfo+120, y1ChannelInfo, logo);
- }
+ #if VDRVERSNUM > 10716
+ if (bpp > 8)
+ {
+ cImage logo (cSize(64, 48));
+ if(osdbitmap.Load(logo, displayLogoPath.c_str(), 64, 48)){
+ cPixmap *logoPixmap;
+ logoPixmap = osd->CreatePixmap(0, cRect(x1ChannelInfo+120, y1ChannelInfo, 64, 48));
+ logoPixmap->DrawImage(cPoint(0, 0), logo);
+ }
+ }
+ else
+ #endif
+ {
+ cBitmap logo (1, 1, bpp);
+ if(osdbitmap.Load(logo, displayLogoPath.c_str(), 64, 48)){
+ osd->DrawBitmap(x1ChannelInfo+120, y1ChannelInfo, logo);
+ }
+ }
break;
case 2 :
- if(osdbitmap.Load(logo, displayLogoPath.c_str(), 120, 100)){
- osd->DrawBitmap(x2ChannelInfo-125, y2ChannelInfo-110, logo);
- }
+ #if VDRVERSNUM > 10716
+ if (bpp > 8)
+ {
+ cImage logo (cSize(120, 100));
+ if(osdbitmap.Load(logo, displayLogoPath.c_str(), 120, 100)){
+ cPixmap *logoPixmap;
+ logoPixmap = osd->CreatePixmap(0, cRect(x2ChannelInfo-125, y2ChannelInfo-110, 120, 100));
+ logoPixmap->DrawImage(cPoint(0, 0), logo);
+ }
+ }
+ else
+ #endif
+ {
+ cBitmap logo (1, 1, bpp);
+ if(osdbitmap.Load(logo, displayLogoPath.c_str(), 120, 100)){
+ osd->DrawBitmap(x2ChannelInfo-125, y2ChannelInfo-110, logo);
+ }
+ }
break;
}
@@ -948,21 +977,36 @@ void cSkinPearlHDDisplayMenu::SetEvent(const cEvent *Event)
snprintf(logoFormat, sizeof(logoFormat), "jpg");
break;
}
-
+
cOSDImageBitmap osdbitmap;
- cBitmap epgImg (300, 225, bpp);
- std::stringstream epgPath;
- if (PearlHDConfig.EpgDirSet)
- epgPath << PearlHDConfig.EpgImagesDir;
+ std::stringstream epgPath;
+ if (PearlHDConfig.EpgDirSet)
+ epgPath << PearlHDConfig.EpgImagesDir;
else
{
epgPath << cPlugin::ConfigDirectory() << "/tvm2vdr/epgimages";
}
epgPath << "/" << Event->EventID() << "." << logoFormat;
- if(osdbitmap.Load(epgImg, epgPath.str().c_str(), 300, 225, bpp)){
- osd->DrawBitmap(x2Menu-330, y2Menu-285, epgImg);
- }
+
+ #if VDRVERSNUM > 10716
+ if (bpp > 8)
+ {
+ cImage epgImg (cSize(300, 225));
+ if(osdbitmap.Load(epgImg, epgPath.str().c_str(), 300, 225)){
+ cPixmap *epgPixmap;
+ epgPixmap = osd->CreatePixmap(0, cRect(x2Menu-330, y2Menu-285, 300, 225));
+ epgPixmap->DrawImage(cPoint(0, 0), epgImg);
+ }
+ }
+ else
+ #endif
+ {
+ cBitmap epgImg (300, 225, bpp);
+ if(osdbitmap.Load(epgImg, epgPath.str().c_str(), 300, 225, bpp)){
+ osd->DrawBitmap(x2Menu-330, y2Menu-285, epgImg);
+ }
+ }
}
osd->DrawText(x1Menu+75, y1Menu+60, Event->Title(), Theme.Color(clrFontColor), clrTransparent, fontSansBook37);