diff options
author | lordjaxom <lordjaxom> | 2004-06-01 21:02:41 +0000 |
---|---|---|
committer | lordjaxom <lordjaxom> | 2004-06-01 21:02:41 +0000 |
commit | e535cdbe09d9c13d79cd6722aafca5798b7d1e35 (patch) | |
tree | 640a6597a28e3f548a469b3c19e681d48a0622dc | |
parent | 37b57e7872214cc59119faf29bd058362504b3f6 (diff) | |
download | vdr-plugin-text2skin-e535cdbe09d9c13d79cd6722aafca5798b7d1e35.tar.gz vdr-plugin-text2skin-e535cdbe09d9c13d79cd6722aafca5798b7d1e35.tar.bz2 |
- fixed possible segfault when showing language logo (happened when channelv0.0.1-rc3
was not available)
- fixed some memory leaks
- fixed "too many colors used in palette" warning for non-imlib-users
-rw-r--r-- | HISTORY | 7 | ||||
-rw-r--r-- | Makefile | 11 | ||||
-rw-r--r-- | bitmap.c | 17 | ||||
-rw-r--r-- | bitmap.h | 5 | ||||
-rw-r--r-- | common.c | 19 | ||||
-rw-r--r-- | common.h | 3 | ||||
-rw-r--r-- | data.c | 7 | ||||
-rw-r--r-- | loader.c | 9 | ||||
-rw-r--r-- | render.c | 13 | ||||
-rw-r--r-- | text2skin.c | 4 |
10 files changed, 72 insertions, 23 deletions
@@ -1,6 +1,13 @@ VDR Plugin 'text2skin' Revision History --------------------------------------- +2004-06-01: Version 0.0.1-rc3 + +- fixed possible segfault when showing language logo (happened when channel + was not available) +- fixed some memory leaks +- fixed "too many colors used in palette" warning for non-imlib-users + 2004-06-01: Version 0.0.1-rc2 - fixed some possible segfaults in Display Update @@ -1,12 +1,17 @@ # # Makefile for a Video Disk Recorder plugin # -# $Id: Makefile,v 1.2 2004/05/26 21:27:11 lordjaxom Exp $ +# $Id: Makefile,v 1.3 2004/06/01 21:02:38 lordjaxom Exp $ # disable in case you don't want to install imlib # in that case, you will not be able to load other files than simple xpms HAVE_IMLIB2=1 +# !!!!THIS DOESN'T WORK YET!!!! +# disable in case you don't want to install ImageMagick +# in that case, you will not be able to load other files than simple xpms +#HAVE_IMAGEMAGICK=1 + # The official name of this plugin. # This name will be used in the '-P...' option of VDR to load the plugin. # By default the main source file also carries this name. @@ -48,6 +53,10 @@ ifdef HAVE_IMLIB2 DEFINES += -DHAVE_IMLIB2 endif +ifdef HAVE_IMAGEMAGICK + DEFINES += -DHAVE_IMAGEMAGICK +endif + INCLUDES += -I$(VDRDIR)/include -I$(DVBDIR)/include DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"' @@ -1,5 +1,5 @@ /* - * $Id: bitmap.c,v 1.5 2004/06/01 17:10:13 lordjaxom Exp $ + * $Id: bitmap.c,v 1.6 2004/06/01 21:02:38 lordjaxom Exp $ */ #define __STL_CONFIG_H @@ -24,11 +24,10 @@ cText2SkinBitmap::~cText2SkinBitmap() { bool cText2SkinBitmap::Load(const char *Filename) { int len = strlen(Filename); if (len > 4) { -#ifndef HAVE_IMLIB2 if (strcmp(Filename + len - 4, ".xpm") == 0) return LoadXpm(Filename); -#else - if (strcmp(Filename + len - 4, ".xpm") == 0 || strcmp(Filename + len - 4, ".png") == 0) +#ifdef HAVE_IMLIB2 + else if (strcmp(Filename + len - 4, ".png") == 0) return LoadImlib(Filename); #endif else @@ -44,6 +43,8 @@ bool cText2SkinBitmap::LoadImlib(const char *Filename) { image = imlib_load_image(Filename); if (!image) return false; + Imlib_Context ctx = imlib_context_new(); + imlib_context_push(ctx); imlib_context_set_image(image); SetSize(imlib_image_get_width(), imlib_image_get_height()); SetBpp(8); @@ -62,6 +63,14 @@ bool cText2SkinBitmap::LoadImlib(const char *Filename) { } } imlib_free_image(); + imlib_context_free(ctx); return true; } #endif + +#ifdef HAVE_IMAGEMAGICK +bool cText2SkinBitmap::LoadMagick(const char *Filename) { + Image image; + image.read(Filename); +} +#endif @@ -1,5 +1,5 @@ /* - * $Id: bitmap.h,v 1.4 2004/06/01 17:10:13 lordjaxom Exp $ + * $Id: bitmap.h,v 1.5 2004/06/01 21:02:38 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_BITMAP_H @@ -19,6 +19,9 @@ public: #ifdef HAVE_IMLIB2 bool LoadImlib(const char *Filename); #endif +#ifdef HAVE_IMAGEMAGICK + bool LoadMagick(const char *Filename); +#endif }; #endif // VDR_TEXT2SKIN_BITMAP_H @@ -1,5 +1,5 @@ /* - * $Id: common.c,v 1.4 2004/05/31 19:54:12 lordjaxom Exp $ + * $Id: common.c,v 1.5 2004/06/01 21:02:38 lordjaxom Exp $ */ #define __STL_CONFIG_H @@ -62,6 +62,23 @@ void DrawTextTransparent(cOsd *Osd, int x, int y, const char *s, tColor ColorFg, } } +void DrawBitmap(cOsd *Osd, int x, int y, cBitmap &Bitmap, tColor ColorFg, tColor ColorBg) { + if (ColorFg || ColorBg) { + Bitmap.SetColor(0, ColorBg); + Bitmap.SetColor(1, ColorFg); + } + tColor fill = Bitmap.Color(*Bitmap.Data(0, 0)); // to be sure to grab a USED color + Osd->DrawRectangle(x, y, x + Bitmap.Width() - 1, y + Bitmap.Height() - 1, fill); // to be sure the palette is reset, if the Bitmap covers an Area + for (int iy = 0; iy < Bitmap.Height(); iy++) { + const tIndex *ptr = Bitmap.Data(0, iy); + for (int ix = 0; ix < Bitmap.Width(); ix++, ptr += sizeof(tIndex)) { + // DrawPixel is b0rked + //Osd->DrawPixel(x + ix, y + iy, Bitmap.Color(*ptr)); + Osd->DrawRectangle(x + ix, y + iy, x + ix, y + iy, Bitmap.Color(*ptr)); + } + } +} + const char *ChannelNumber(const cChannel *Channel, int Number) { static char buffer[256]; buffer[0] = '\0'; @@ -1,5 +1,5 @@ /* - * $Id: common.h,v 1.4 2004/05/31 19:54:12 lordjaxom Exp $ + * $Id: common.h,v 1.5 2004/06/01 21:02:38 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_COMMON_H @@ -13,6 +13,7 @@ class cText2SkinItem; const char *SkinPath(void); void DrawTextTransparent(cOsd *Osd, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width, int Height, int Alignment); +void DrawBitmap(cOsd *Osd, int x, int y, cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0); const char *ChannelNumber(const cChannel *Channel, int Number); const char *ChannelName(const cChannel *Channel, int Number); string ItemText(cText2SkinItem *Item, const string &Content); @@ -1,5 +1,5 @@ /* - * $Id: data.c,v 1.10 2004/05/31 19:54:12 lordjaxom Exp $ + * $Id: data.c,v 1.11 2004/06/01 21:02:38 lordjaxom Exp $ */ #include "data.h" @@ -156,17 +156,18 @@ bool cText2SkinItem::ParseVar(const char *Text, const char *Name, int *Value) { bool cText2SkinItem::ParseVar(const char *Text, const char *Name, string &Value){ char *ptr1, *ptr2; char *str; + bool res = false; asprintf(&str, "%s=", Name); if ((ptr1 = strstr(Text, str))) { ptr1 += strlen(str); if ((ptr2 = strchr(ptr1, ',')) || (ptr2 = strchr(ptr1, ';'))) { Value = ptr1; Value.erase(ptr2 - ptr1); - return true; + res = true; } } free(str); - return false; + return res; } bool cText2SkinItem::ParseVar(const char *Text, const char *Name, tColor **Value) { @@ -1,5 +1,5 @@ /* - * $Id: loader.c,v 1.4 2004/05/31 19:54:12 lordjaxom Exp $ + * $Id: loader.c,v 1.5 2004/06/01 21:02:38 lordjaxom Exp $ */ #define __STL_CONFIG_H @@ -33,12 +33,11 @@ void cText2SkinLoader::Start(void) { } void cText2SkinLoader::Load(const char *Skin) { - char *skinfile; struct stat buf; - asprintf(&skinfile, "%s/%s/%s.skin", SkinPath(), Skin, Skin); - if (stat(skinfile, &buf) == 0) { + string file = (string)SkinPath() + "/" + Skin + "/" + Skin + ".skin"; + if (stat(file.c_str(), &buf) == 0) { cText2SkinData *data = new cText2SkinData(Skin); - if (data->Load(skinfile)) { + if (data->Load(file.c_str())) { cText2SkinItem *skin = data->Get(itemSkin); if (skin) { new cText2SkinLoader(data, Skin, skin->Name()); @@ -1,5 +1,5 @@ /* - * $Id: render.c,v 1.14 2004/06/01 17:25:38 lordjaxom Exp $ + * $Id: render.c,v 1.15 2004/06/01 21:02:38 lordjaxom Exp $ */ #include "render.h" @@ -195,7 +195,7 @@ void cText2SkinRender::DrawBackground(const POINT &Pos, const SIZE &Size, const } if (image) - mOsd->DrawBitmap(Pos.x, Pos.y, bm); + DrawBitmap(mOsd, Pos.x, Pos.y, bm); else mOsd->DrawRectangle(Pos.x, Pos.y, Pos.x + Size.w - 1, Pos.y + Size.h - 1, Bg ? *Bg : 0); } @@ -209,7 +209,7 @@ void cText2SkinRender::DrawImage(const POINT &Pos, const SIZE &Size, const tColo if (Bg) bm.SetColor(0, *Bg); if (Fg) bm.SetColor(1, *Fg); //mOsd->DrawRectangle(Pos.x, Pos.y, Pos.x + Size.w - 1, Pos.y + Size.h - 1, bm.Color(0)); - mOsd->DrawBitmap(Pos.x, Pos.y, bm); + DrawBitmap(mOsd, Pos.x, Pos.y, bm); } free(p); } @@ -323,8 +323,10 @@ void cText2SkinRender::DisplayLanguage(cText2SkinItem *Item) { ++i; } printf("\n"); - string path = Item->Path() + "/" + tracks[current] + "." + Item->Type(); - DrawImage(Item->Pos(), Item->Size(), Item->Bg(), Item->Fg(), path); + if (current < i) { + string path = Item->Path() + "/" + tracks[current] + "." + Item->Type(); + DrawImage(Item->Pos(), Item->Size(), Item->Bg(), Item->Fg(), path); + } } } @@ -353,6 +355,7 @@ void cText2SkinRender::DisplayTime(cText2SkinItem *Item) { char *text = strdup(DayDateTime(time(NULL))); text[18] = '\0'; DrawText(Item->Pos(), Item->Size(), Item->Fg(), ItemText(Item, text + 13), Item->Font(), Item->Align()); + free(text); } void cText2SkinRender::DisplayChannelNumberName(cText2SkinItem *Item) { diff --git a/text2skin.c b/text2skin.c index 4163b18..e2b0b9a 100644 --- a/text2skin.c +++ b/text2skin.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: text2skin.c,v 1.6 2004/06/01 16:47:47 lordjaxom Exp $ + * $Id: text2skin.c,v 1.7 2004/06/01 21:02:38 lordjaxom Exp $ */ #define __STL_CONFIG_H @@ -11,7 +11,7 @@ #undef __STL_CONFIG_H #include "loader.h" -static const char *VERSION = "0.0.1-rc2"; +static const char *VERSION = "0.0.1-rc3"; static const char *DESCRIPTION = "Loader for text-based skins"; class cText2SkinPlugin : public cPlugin { |