diff options
Diffstat (limited to 'PLUGINS/src/osddemo/osddemo.c')
-rw-r--r-- | PLUGINS/src/osddemo/osddemo.c | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/PLUGINS/src/osddemo/osddemo.c b/PLUGINS/src/osddemo/osddemo.c index 2d69f442..89fd6954 100644 --- a/PLUGINS/src/osddemo/osddemo.c +++ b/PLUGINS/src/osddemo/osddemo.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: osddemo.c 4.2 2015/03/08 16:42:01 kls Exp $ + * $Id: osddemo.c 4.3 2015/04/12 09:35:21 kls Exp $ */ #include <vdr/osd.h> @@ -90,6 +90,52 @@ void DrawSlopes(cOsd *Osd) Osd->Flush(); } +// --- DrawImages ------------------------------------------------------------ + +struct tOsdImageRef { + int image; + cSize size; + }; + +#define NUMOSDIMAGES 16 +#define NUMOSDIMAGEVARIANTS 8 + +void DrawImages(cOsd *Osd) +{ + // Create images: + cImage *images[NUMOSDIMAGEVARIANTS]; + for (int i = 0; i < NUMOSDIMAGEVARIANTS; i++) { + images[i] = new cImage(cSize( + i == 0 || i == 1 ? Osd->MaxPixmapSize().Width() + 1 : rand() % Osd->Width(), + i == 0 || i == 2 ? Osd->MaxPixmapSize().Height() + 1 : rand() % Osd->Height())); + for (int x = 0; x < images[i]->Width(); x++) { + for (int y = 0; y < images[i]->Height(); y++) { + images[i]->SetPixel(cPoint(x, y), + (!x || !y || x == images[i]->Width() - 1 || y == images[i]->Height() - 1) ? clrWhite : + (x > images[i]->Width() / 2 ? + (y > images[i]->Height() / 2 ? clrBlue : clrGreen) : + (y > images[i]->Height() / 2 ? clrRed : clrYellow))); + } + } + } + // Store images: + tOsdImageRef osdImages[NUMOSDIMAGES]; + for (int i = 0; i < NUMOSDIMAGES; i++) { + osdImages[i].image = cOsdProvider::StoreImage(*images[i % NUMOSDIMAGEVARIANTS]); + osdImages[i].size.Set(images[i % NUMOSDIMAGEVARIANTS]->Size()); + } + // Delete images: + for (int i = 0; i < NUMOSDIMAGEVARIANTS; i++) + delete images[i]; + // Draw images: + for (int i = 0; i < NUMOSDIMAGES; i++) + Osd->DrawImage(cPoint(rand() % (Osd->Width() + osdImages[i].size.Width()), rand() % (Osd->Height() + osdImages[i].size.Height())).Shifted(-osdImages[i].size.Width(), -osdImages[i].size.Height()), osdImages[i].image); + // Drop image references: + for (int i = 0; i < NUMOSDIMAGES; i++) + cOsdProvider::DropImage(osdImages[i].image); + Osd->Flush(); +} + // --- cLineGame ------------------------------------------------------------- class cLineGame : public cOsdObject { @@ -540,6 +586,10 @@ eOSState cTrueColorDemo::ProcessKey(eKeys Key) SetArea(); DrawSlopes(osd); break; + case k3: Cancel(3); + SetArea(); + DrawImages(osd); + break; case kBack: case kOk: return osEnd; default: return state; |