mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Added a demo case for storing images
This commit is contained in:
parent
38ee88e5ee
commit
e6592e6201
@ -78,3 +78,4 @@ VDR Plugin 'osddemo' Revision History
|
|||||||
- Now using cOsd::MaxPixmapSize().
|
- Now using cOsd::MaxPixmapSize().
|
||||||
- Fixed a vertical black line in the "TiledPixmaps" area on the rpihddevice OSD with
|
- Fixed a vertical black line in the "TiledPixmaps" area on the rpihddevice OSD with
|
||||||
1280x800 pixel (thanks to Thomas Reufer).
|
1280x800 pixel (thanks to Thomas Reufer).
|
||||||
|
- Added a demo case for storing images (thanks to Thomas Reufer).
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* See the README file for copyright information and how to reach the author.
|
* 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>
|
#include <vdr/osd.h>
|
||||||
@ -90,6 +90,52 @@ void DrawSlopes(cOsd *Osd)
|
|||||||
Osd->Flush();
|
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 -------------------------------------------------------------
|
// --- cLineGame -------------------------------------------------------------
|
||||||
|
|
||||||
class cLineGame : public cOsdObject {
|
class cLineGame : public cOsdObject {
|
||||||
@ -540,6 +586,10 @@ eOSState cTrueColorDemo::ProcessKey(eKeys Key)
|
|||||||
SetArea();
|
SetArea();
|
||||||
DrawSlopes(osd);
|
DrawSlopes(osd);
|
||||||
break;
|
break;
|
||||||
|
case k3: Cancel(3);
|
||||||
|
SetArea();
|
||||||
|
DrawImages(osd);
|
||||||
|
break;
|
||||||
case kBack:
|
case kBack:
|
||||||
case kOk: return osEnd;
|
case kOk: return osEnd;
|
||||||
default: return state;
|
default: return state;
|
||||||
|
Loading…
Reference in New Issue
Block a user