Skip to content

Commit

Permalink
Implement DrawImageScaled()
Browse files Browse the repository at this point in the history
  • Loading branch information
rellla committed Jul 24, 2023
1 parent 29d641f commit 6510a1c
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 1 deletion.
2 changes: 1 addition & 1 deletion LibreELEC.tv
Submodule LibreELEC.tv updated 203 files
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
From 64cb3aaf33096bc027070d51ebed0d61108040f3 Mon Sep 17 00:00:00 2001
From: Andreas Baierl <ichgeh@imkreisrum.de>
Date: Mon, 24 Jul 2023 14:25:57 +0200
Subject: [PATCH] implement DrawImageScaled

---
openglosd.cpp | 36 ++++++++++++++++++++----------------
openglosd.h | 1 +
2 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/openglosd.cpp b/openglosd.cpp
index b2e4e61..66bd092 100644
--- a/openglosd.cpp
+++ b/openglosd.cpp
@@ -1903,8 +1903,8 @@ bool cOglCmdDrawImage::Execute(void) {

GLfloat x1 = x; //left
GLfloat y1 = y; //top
- GLfloat x2 = x + width; //right
- GLfloat y2 = y + height; //bottom
+ GLfloat x2 = x + width * scaleX; //right
+ GLfloat y2 = y + height * scaleY; //bottom

GLfloat quadVertices[] = {
x1, y2, 0.0, 1.0, // left bottom
@@ -2419,20 +2419,7 @@ void cOglPixmap::Fill(tColor Color) {
}

void cOglPixmap::DrawImage(const cPoint &Point, const cImage &Image) {
- if (!oglThread->Active())
- return;
- tColor *argb = MALLOC(tColor, Image.Width() * Image.Height());
- if (!argb)
- return;
- memcpy(argb, Image.Data(), sizeof(tColor) * Image.Width() * Image.Height());
-
- oglThread->DoCmd(new cOglCmdDrawImage(fb, argb, Image.Width(), Image.Height(), Point.X(), Point.Y()));
-#ifdef GRIDRECT
- DrawGridRect(cRect(Point.X(), Point.Y(), Image.Width(), Image.Height()), GRIDPOINTOFFSET, GRIDPOINTSIZE, GRIDPOINTCLR, GRIDPOINTBG, tinyfont);
-#endif
-
- SetDirty();
- MarkDrawPortDirty(cRect(Point, cSize(Image.Width(), Image.Height())).Intersected(DrawPort().Size()));
+ DrawImageScaled(Point, Image, 1.0f, 1.0f);
}

void cOglPixmap::DrawImage(const cPoint &Point, int ImageHandle) {
@@ -2456,6 +2443,23 @@ void cOglPixmap::DrawImage(const cPoint &Point, int ImageHandle) {
MarkDrawPortDirty(DrawPort());
}

+void cOglPixmap::DrawImageScaled(const cPoint &Point, const cImage &Image, double FactorX, double FactorY) {
+ if (!oglThread->Active())
+ return;
+ tColor *argb = MALLOC(tColor, Image.Width() * Image.Height());
+ if (!argb)
+ return;
+ memcpy(argb, Image.Data(), sizeof(tColor) * Image.Width() * Image.Height());
+
+ oglThread->DoCmd(new cOglCmdDrawImage(fb, argb, Image.Width(), Image.Height(), Point.X(), Point.Y(), true, FactorX, FactorY));
+#ifdef GRIDRECT
+ DrawGridRect(cRect(Point.X(), Point.Y(), Image.Width() * FactorX, Image.Height() * FactorY), GRIDPOINTOFFSET, GRIDPOINTSIZE, GRIDPOINTCLR, GRIDPOINTBG, tinyfont);
+#endif
+
+ SetDirty();
+ MarkDrawPortDirty(cRect(Point, cSize(Image.Width() * FactorX, Image.Height() * FactorY)).Intersected(DrawPort().Size()));
+}
+
void cOglPixmap::DrawPixel(const cPoint &Point, tColor Color) {
cRect r(Point.X(), Point.Y(), 1, 1);
oglThread->DoCmd(new cOglCmdDrawRectangle(fb, r.X(), r.Y(), r.Width(), r.Height(), Color));
diff --git a/openglosd.h b/openglosd.h
index a3de390..d3b944b 100644
--- a/openglosd.h
+++ b/openglosd.h
@@ -571,6 +571,7 @@ public:
virtual void Fill(tColor Color);
virtual void DrawImage(const cPoint &Point, const cImage &Image);
virtual void DrawImage(const cPoint &Point, int ImageHandle);
+ virtual void DrawImageScaled(const cPoint &Point, const cImage &Image, double FactorX, double FactorY);
virtual void DrawPixel(const cPoint &Point, tColor Color);
virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0, bool Overlay = false);
virtual void DrawText(const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width = 0, int Height = 0, int Alignment = taDefault);
--
2.30.2

73 changes: 73 additions & 0 deletions packages/vdr/_vdr/patches/0001-implement-DrawImageScaled.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
From 6f588e415d6be94c1f43b061137bf11719d8f156 Mon Sep 17 00:00:00 2001
From: Andreas Baierl <ichgeh@imkreisrum.de>
Date: Sun, 16 Jul 2023 22:04:16 +0200
Subject: [PATCH] implement DrawImageScaled()

---
osd.c | 11 +++++++++++
osd.h | 6 ++++++
2 files changed, 17 insertions(+)

diff --git a/osd.c b/osd.c
index 47bda686..f9fb0701 100644
--- a/osd.c
+++ b/osd.c
@@ -1259,6 +1259,11 @@ void cPixmapMemory::DrawImage(const cPoint &Point, int ImageHandle)
Unlock();
}

+void cPixmapMemory::DrawImageScaled(const cPoint &Point, const cImage &Image, double FactorX, double FactorY)
+{
+ DrawImage(Point, Image);
+}
+
void cPixmapMemory::DrawPixel(const cPoint &Point, tColor Color)
{
Lock();
@@ -2118,6 +2123,12 @@ void cOsd::DrawImage(const cPoint &Point, int ImageHandle)
pixmaps[0]->DrawImage(Point, ImageHandle);
}

+void cOsd::DrawImageScaled(const cPoint &Point, const cImage &Image, double FactorX, double FactorY)
+{
+ if (isTrueColor)
+ pixmaps[0]->DrawImageScaled(Point, Image, FactorX, FactorY);
+}
+
void cOsd::DrawPixel(int x, int y, tColor Color)
{
if (isTrueColor)
diff --git a/osd.h b/osd.h
index 77722662..456cb9cc 100644
--- a/osd.h
+++ b/osd.h
@@ -602,6 +602,8 @@ public:
///< the given Point. ImageHandle must be a value that has previously been
///< returned by a call to cOsdProvider::StoreImage(). If ImageHandle
///< has an invalid value, nothing happens.
+ virtual void DrawImageScaled(const cPoint &Point, const cImage &Image, double FactorX = 1.0f, double FactorY = 1.0f) = 0;
+ ///< Draws the given Image into this pixmap at the given Point and scale it.
virtual void DrawPixel(const cPoint &Point, tColor Color) = 0;
///< Sets the pixel at the given Point to the given Color, which is
///< a full 32 bit ARGB value. If the alpha value of Color is not 0xFF
@@ -700,6 +702,7 @@ public:
virtual void Fill(tColor Color);
virtual void DrawImage(const cPoint &Point, const cImage &Image);
virtual void DrawImage(const cPoint &Point, int ImageHandle);
+ virtual void DrawImageScaled(const cPoint &Point, const cImage &Image, double FactorX = 1.0, double FactorY = 1.0);
virtual void DrawPixel(const cPoint &Point, tColor Color);
virtual void DrawBlendedPixel(const cPoint &Point, tColor Color, uint8_t AlphaLayer = ALPHA_OPAQUE);
virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0, bool Overlay = false);
@@ -857,6 +860,9 @@ public:
///< returned by a call to cOsdProvider::StoreImage(). If ImageHandle
///< has an invalid value, nothing happens.
///< If this is not a true color OSD, this function does nothing.
+ virtual void DrawImageScaled(const cPoint &Point, const cImage &Image, double FactorX = 1.0, double FactorY = 1.0);
+ ///< Draws the given Image on this OSD at the given Point and scale it.
+ ///< If this is not a true color OSD, this function does nothing.
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas);
///< Checks whether the OSD can display the given set of sub-areas.
///< The return value indicates whether a call to SetAreas() with this
--
2.30.2

0 comments on commit 6510a1c

Please sign in to comment.