From 9e39d4facfd8f83377bac52dffd9c4e27c0fd1da Mon Sep 17 00:00:00 2001 From: Conrad Kostecki Date: Sun, 24 Jul 2022 19:41:48 +0200 Subject: app-misc/graphlcd-base: add support for imagemagick7 Upstream added support for ImageMagick7, so re-adding support. Bug: https://bugs.gentoo.org/858437 Signed-off-by: Conrad Kostecki --- .../files/graphlcd-base-2.0.3-imagemagick7.patch | 338 +++++++++++++++++++++ .../graphlcd-base/graphlcd-base-2.0.3-r1.ebuild | 84 ----- .../graphlcd-base/graphlcd-base-2.0.3-r2.ebuild | 91 ++++++ app-misc/graphlcd-base/metadata.xml | 2 + 4 files changed, 431 insertions(+), 84 deletions(-) create mode 100644 app-misc/graphlcd-base/files/graphlcd-base-2.0.3-imagemagick7.patch delete mode 100644 app-misc/graphlcd-base/graphlcd-base-2.0.3-r1.ebuild create mode 100644 app-misc/graphlcd-base/graphlcd-base-2.0.3-r2.ebuild (limited to 'app-misc') diff --git a/app-misc/graphlcd-base/files/graphlcd-base-2.0.3-imagemagick7.patch b/app-misc/graphlcd-base/files/graphlcd-base-2.0.3-imagemagick7.patch new file mode 100644 index 000000000000..1c938fadd870 --- /dev/null +++ b/app-misc/graphlcd-base/files/graphlcd-base-2.0.3-imagemagick7.patch @@ -0,0 +1,338 @@ +From 5863f4aae667bce9242fe63f1afbd5b16ee23f1e Mon Sep 17 00:00:00 2001 +From: Manuel Reimer +Date: Sun, 17 Jul 2022 19:19:31 +0200 +Subject: [PATCH] Update ImageMagick library name + +ImageMagick++.pc was deleted back in 2012 +https://github.com/ImageMagick/ImageMagick/commit/ae2846b1c8c016382febb54ddea432f1aba57296 +--- + glcdgraphics/Makefile | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/glcdgraphics/Makefile b/glcdgraphics/Makefile +index 9d74477..cfb50de 100644 +--- a/glcdgraphics/Makefile ++++ b/glcdgraphics/Makefile +@@ -49,8 +49,8 @@ endif + # two ifdef/endif are used because older installations may not support 'else ifdef' + ifeq ($(IMAGELIB), imagemagick) + DEFINES += -DHAVE_IMAGEMAGICK +- INCLUDES += $(shell pkg-config --cflags ImageMagick++) +- LIBS += $(shell pkg-config --libs ImageMagick++) ++ INCLUDES += $(shell pkg-config --cflags Magick++) ++ LIBS += $(shell pkg-config --libs Magick++) + endif + ifeq ($(IMAGELIB), graphicsmagick) + DEFINES += -DHAVE_IMAGEMAGICK # yep, really HAVE_IMAGEMAGICK here +From 93108089cc05ffabc18d81ebc97d39feb7f2c56e Mon Sep 17 00:00:00 2001 +From: Manuel Reimer +Date: Sun, 24 Jul 2022 19:20:30 +0200 +Subject: [PATCH] Add ImageMagick 7 support. Fixes #3 + +--- + glcdgraphics/Makefile | 13 ++- + glcdgraphics/extformats.c | 186 ++++++++++++++++++-------------------- + 2 files changed, 95 insertions(+), 104 deletions(-) + +diff --git a/glcdgraphics/Makefile b/glcdgraphics/Makefile +index cfb50de..92e2847 100644 +--- a/glcdgraphics/Makefile ++++ b/glcdgraphics/Makefile +@@ -12,6 +12,7 @@ ifdef HAVE_GRAPHICSMAGICK + endif + ifdef HAVE_IMAGEMAGICK + IMAGELIB = imagemagick ++ HAVE_IMAGEMAGICK_7 = $(shell pkg-config --atleast-version=7.0.0 MagickWand && echo true) + endif + + +@@ -49,13 +50,17 @@ endif + # two ifdef/endif are used because older installations may not support 'else ifdef' + ifeq ($(IMAGELIB), imagemagick) + DEFINES += -DHAVE_IMAGEMAGICK +- INCLUDES += $(shell pkg-config --cflags Magick++) +- LIBS += $(shell pkg-config --libs Magick++) ++ INCLUDES += $(shell pkg-config --cflags MagickWand) ++ LIBS += $(shell pkg-config --libs MagickWand) ++ ifeq ($(HAVE_IMAGEMAGICK_7), true) ++ DEFINES += -DHAVE_IMAGEMAGICK_7 ++ endif + endif ++ + ifeq ($(IMAGELIB), graphicsmagick) + DEFINES += -DHAVE_IMAGEMAGICK # yep, really HAVE_IMAGEMAGICK here +- INCLUDES += $(shell pkg-config --cflags GraphicsMagick++) +- LIBS += $(shell pkg-config --libs GraphicsMagick++) ++ INCLUDES += $(shell pkg-config --cflags GraphicsMagickWand) ++ LIBS += $(shell pkg-config --libs GraphicsMagickWand) + endif + + +diff --git a/glcdgraphics/extformats.c b/glcdgraphics/extformats.c +index 5734fce..90441e6 100644 +--- a/glcdgraphics/extformats.c ++++ b/glcdgraphics/extformats.c +@@ -21,11 +21,10 @@ + #include "extformats.h" + #include "image.h" + +-#ifdef HAVE_IMAGEMAGICK +-#include +-//#elif defined(HAVE_IMLIB2) +-//#include "quantize.h" +-//#include ++#ifdef HAVE_IMAGEMAGICK_7 ++ #include ++#elifdef HAVE_IMAGEMAGICK ++ #include + #endif + + +@@ -37,9 +36,11 @@ using namespace std; + + cExtFormatFile::cExtFormatFile() + { +-#ifdef HAVE_IMAGEMAGICK +- Magick::InitializeMagick(NULL); +-#endif ++#ifdef HAVE_IMAGEMAGICK_7 ++ MagickWandGenesis(); ++#elifdef HAVE_IMAGEMAGICK ++ InitializeMagick(NULL); ++#endif + } + + cExtFormatFile::~cExtFormatFile() +@@ -56,118 +57,103 @@ bool cExtFormatFile::Load(cImage & image, const string & fileName) + bool cExtFormatFile::LoadScaled(cImage & image, const string & fileName, uint16_t & scalew, uint16_t & scaleh) + { + #ifdef HAVE_IMAGEMAGICK +- std::vector extimages; +- try { +- uint16_t width = 0; +- uint16_t height = 0; +- //uint16_t count; +- uint32_t delay; +- +- std::vector::iterator it; +- readImages(&extimages, fileName); +- if (extimages.size() == 0) { +- syslog(LOG_ERR, "glcdgraphics: Couldn't load '%s' (cExtFormatFile::LoadScaled)", fileName.c_str()); +- return false; +- } ++ MagickWand* mw = NewMagickWand(); + +- delay = (uint32_t)(extimages[0].animationDelay() * 10); ++ uint16_t width = 0; ++ uint16_t height = 0; ++ uint32_t delay; ++ ++ if (MagickReadImage(mw, fileName.c_str()) == MagickFalse) { ++ syslog(LOG_ERR, "glcdgraphics: Couldn't load '%s' (cExtFormatFile::LoadScaled)", fileName.c_str()); ++ return false; ++ } + +- image.Clear(); +- image.SetDelay(delay); ++ delay = (uint32_t)(MagickGetImageDelay(mw) * 10); + +- bool firstImage = true; ++ image.Clear(); ++ image.SetDelay(delay); + +- for (it = extimages.begin(); it != extimages.end(); ++it) { +- bool ignoreImage = false; ++ for (unsigned long imageindex = 0; imageindex < MagickGetNumberImages(mw); imageindex++) { + +- //(*it).quantizeColorSpace( Magick::RGBColorspace ); +- //(*it).quantizeColors( 256*256*256 /*colors*/ ); +- //(*it).quantize(); ++#ifdef HAVE_IMAGEMAGICK_7 ++ MagickSetIteratorIndex(mw, imageindex); ++#else ++ MagickSetImageIndex(mw, imageindex); ++#endif + +- if (firstImage) { +- width = (uint16_t)((*it).columns()); +- height = (uint16_t)((*it).rows()); +- firstImage = false; ++ bool ignoreImage = false; + +- // one out of scalew/h == 0 ? -> auto aspect ratio +- if (scalew && ! scaleh) { +- scaleh = (uint16_t)( ((uint32_t)scalew * (uint32_t)height) / (uint32_t)width ); +- } else if (!scalew && scaleh) { +- scalew = (uint16_t)( ((uint32_t)scaleh * (uint32_t)width) / (uint32_t)height ); +- } ++ if (imageindex == 0) { // If first image ++ width = (uint16_t)MagickGetImageWidth(mw); ++ height = (uint16_t)MagickGetImageHeight(mw); + +- // scale image +- if (scalew && ! (scalew == width && scaleh == height)) { +- (*it).sample(Magick::Geometry(scalew, scaleh)); +- width = scalew; +- height = scaleh; +- } else { +- // not scaled => reset to 0 +- scalew = 0; +- scaleh = 0; +- } ++ // one out of scalew/h == 0 ? -> auto aspect ratio ++ if (scalew && ! scaleh) { ++ scaleh = (uint16_t)( ((uint32_t)scalew * (uint32_t)height) / (uint32_t)width ); ++ } else if (!scalew && scaleh) { ++ scalew = (uint16_t)( ((uint32_t)scaleh * (uint32_t)width) / (uint32_t)height ); ++ } + +- image.SetWidth(width); +- image.SetHeight(height); ++ // scale image ++ if (scalew && ! (scalew == width && scaleh == height)) { ++ MagickSampleImage(mw, scalew, scaleh); ++ width = scalew; ++ height = scaleh; + } else { +- if (scalew && scaleh) { +- (*it).sample(Magick::Geometry(scalew, scaleh)); +- } else +- if ( (width != (uint16_t)((*it).columns())) || (height != (uint16_t)((*it).rows())) ) { +- ignoreImage = true; +- } ++ // not scaled => reset to 0 ++ scalew = 0; ++ scaleh = 0; + } + +- if (! ignoreImage) { +- /* +- if ((*it).depth() > 8) { +- esyslog("ERROR: text2skin: More than 8bpp images are not supported"); +- return false; +- } +- */ +- uint32_t * bmpdata = new uint32_t[height * width]; +- //Dprintf("this image has %d colors\n", (*it).totalColors()); ++ image.SetWidth(width); ++ image.SetHeight(height); ++ } else { ++ if (scalew && scaleh) { ++ MagickSampleImage(mw, scalew, scaleh); ++ } else ++ if ( (width != (uint16_t)MagickGetImageWidth(mw)) || (height != (uint16_t)MagickGetImageHeight(mw)) ) { ++ ignoreImage = true; ++ } ++ } + +- bool isMatte = (*it).matte(); +- //bool isMonochrome = ((*it).totalColors() <= 2) ? true : false; +- const Magick::PixelPacket *pix = (*it).getConstPixels(0, 0, (int)width, (int)height); ++ if (! ignoreImage) { ++ uint32_t * bmpdata = new uint32_t[height * width]; ++ ++#ifdef HAVE_IMAGEMAGICK_7 ++ unsigned int status = MagickExportImagePixels(mw, 0, 0, width, height, "BGRA", CharPixel, (unsigned char*)bmpdata); ++#else ++ unsigned int status = MagickGetImagePixels(mw, 0, 0, width, height, "BGRA", CharPixel, (unsigned char*)bmpdata); ++#endif ++ ++ if (status == MagickFalse) { ++ syslog(LOG_ERR, "glcdgraphics: Couldn't load '%s' (cExtFormatFile::LoadScaled): MagickGetImagePixels", fileName.c_str()); ++ return false; ++ } + ++#ifdef HAVE_IMAGEMAGICK_7 ++ bool isMatte = (MagickGetImageAlphaChannel(mw) == MagickTrue); ++#else ++ bool isMatte = (MagickGetImageMatte(mw) == MagickTrue); ++#endif ++ ++ // Give all transparent pixels our defined transparent color ++ if (isMatte) { + for (int iy = 0; iy < (int)height; ++iy) { + for (int ix = 0; ix < (int)width; ++ix) { +- if ( isMatte && Magick::Color::scaleQuantumToDouble(pix->opacity) * 255 == 255 ) { +- bmpdata[iy*width+ix] = cColor::Transparent; +- } else { +- bmpdata[iy*width+ix] = (uint32_t)( +- (uint32_t(255 - (Magick::Color::scaleQuantumToDouble(pix->opacity) * 255)) << 24) | +- (uint32_t( Magick::Color::scaleQuantumToDouble(pix->red) * 255) << 16) | +- (uint32_t( Magick::Color::scaleQuantumToDouble(pix->green) * 255) << 8) | +- uint32_t( Magick::Color::scaleQuantumToDouble(pix->blue) * 255) +- ); +- //if ( isMonochrome ) { // if is monochrome: exchange black and white +- // uint32_t c = bmpdata[iy*width+ix]; +- // switch(c) { +- // case cColor::White: c = cColor::Black; break; +- // case cColor::Black: c = cColor::White; break; +- // } +- // bmpdata[iy*width+ix] = c; +- //} +- } +- ++pix; ++ uint32_t* pixel = &bmpdata[ix+iy*width]; ++ uint8_t alpha = *pixel >> 24; ++ if (alpha == 0) ++ *pixel = cColor::Transparent; + } + } +- cBitmap * b = new cBitmap(width, height, bmpdata); +- //b->SetMonochrome(isMonochrome); +- image.AddBitmap(b); +- delete[] bmpdata; +- bmpdata = NULL; + } ++ ++ cBitmap * b = new cBitmap(width, height, bmpdata); ++ //b->SetMonochrome(isMonochrome); ++ image.AddBitmap(b); ++ delete[] bmpdata; ++ bmpdata = NULL; + } +- } catch (Magick::Exception &e) { +- syslog(LOG_ERR, "glcdgraphics: Couldn't load '%s': %s (cExtFormatFile::LoadScaled)", fileName.c_str(), e.what()); +- return false; +- } catch (...) { +- syslog(LOG_ERR, "glcdgraphics: Couldn't load '%s': Unknown exception caught (cExtFormatFile::LoadScaled)", fileName.c_str()); +- return false; + } + return true; + #else +From ad6496557a817a57cb29f2247ffaeaaa71168c72 Mon Sep 17 00:00:00 2001 +From: Manuel Reimer +Date: Sun, 24 Jul 2022 19:39:59 +0200 +Subject: [PATCH] Add cleanup for MagickWand + +--- + glcdgraphics/extformats.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/glcdgraphics/extformats.c b/glcdgraphics/extformats.c +index 90441e6..79d14da 100644 +--- a/glcdgraphics/extformats.c ++++ b/glcdgraphics/extformats.c +@@ -65,6 +65,7 @@ bool cExtFormatFile::LoadScaled(cImage & image, const string & fileName, uint16_ + + if (MagickReadImage(mw, fileName.c_str()) == MagickFalse) { + syslog(LOG_ERR, "glcdgraphics: Couldn't load '%s' (cExtFormatFile::LoadScaled)", fileName.c_str()); ++ DestroyMagickWand(mw); + return false; + } + +@@ -127,6 +128,7 @@ bool cExtFormatFile::LoadScaled(cImage & image, const string & fileName, uint16_ + + if (status == MagickFalse) { + syslog(LOG_ERR, "glcdgraphics: Couldn't load '%s' (cExtFormatFile::LoadScaled): MagickGetImagePixels", fileName.c_str()); ++ DestroyMagickWand(mw); + return false; + } + +@@ -155,6 +157,7 @@ bool cExtFormatFile::LoadScaled(cImage & image, const string & fileName, uint16_ + bmpdata = NULL; + } + } ++ DestroyMagickWand(mw); + return true; + #else + return false; diff --git a/app-misc/graphlcd-base/graphlcd-base-2.0.3-r1.ebuild b/app-misc/graphlcd-base/graphlcd-base-2.0.3-r1.ebuild deleted file mode 100644 index be25edf67fd8..000000000000 --- a/app-misc/graphlcd-base/graphlcd-base-2.0.3-r1.ebuild +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright 1999-2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -inherit optfeature toolchain-funcs udev - -DESCRIPTION="Contains the lowlevel lcd drivers for GraphLCD" -HOMEPAGE="https://projects.vdr-developer.org/projects/graphlcd-base" -SRC_URI="https://projects.vdr-developer.org/git/${PN}.git/snapshot/${P}.tar.bz2" - -KEYWORDS="amd64 x86" -SLOT="0" -LICENSE="GPL-2" -IUSE="fontconfig freetype lcd_devices_ax206dpf lcd_devices_picolcd_256x64 lcd_devices_vnc" - -RDEPEND=" - dev-libs/libhid - media-gfx/graphicsmagick:0/1.3[cxx] - net-libs/libvncserver - freetype? ( media-libs/freetype:2= ) - fontconfig? ( media-libs/fontconfig:1.0= ) - lcd_devices_ax206dpf? ( virtual/libusb:0 ) - lcd_devices_picolcd_256x64? ( virtual/libusb:0 ) -" - -DEPEND="${RDEPEND}" - -BDEPEND="virtual/pkgconfig" - -DOCS=( "HISTORY" "README" "TODO" "docs/." ) - -src_prepare() { - default - - # Change '/usr/local/' to '/usr' - # Change '/usr/lib' to '/usr/$(get_libdir)' - sed -e "34s:/usr/local:/usr:" -e "37s:/lib:/$(get_libdir):" -i Make.config || die - - # Fix newer GCC version with the Futaba MDM166A lcd driver - sed -e "s:0xff7f0004:(int) 0xff7f0004:" -i glcddrivers/futabaMDM166A.c || die - - tc-export CC CXX -} - -src_configure() { - # Use always GraphicsMagick - sed -e "69s:#::" -i Make.config || die - - # Build optional drivers - if use lcd_devices_ax206dpf; then - sed -e "78s:#::" -i Make.config || die - fi - if use lcd_devices_picolcd_256x64; then - sed -e "81s:#::" -i Make.config || die - fi - if ! use lcd_devices_vnc; then - sed -e "72s:1:0:" -i Make.config || die - fi - - # Build optional features - if ! use freetype; then - sed -e "59s:HAVE:#HAVE:" -i Make.config || die - fi - if ! use fontconfig; then - sed -e "62s:HAVE:#HAVE:" -i Make.config || die - fi -} - -src_install() { - emake DESTDIR="${D}" UDEVRULESDIR="$(get_udevdir)/rules.d" install - - einstalldocs -} - -pkg_postinst() { - udev_reload - - optfeature "supporting the logitech g15 keyboard lcd." app-misc/g15daemon -} - -pkg_postrm() { - udev_reload -} diff --git a/app-misc/graphlcd-base/graphlcd-base-2.0.3-r2.ebuild b/app-misc/graphlcd-base/graphlcd-base-2.0.3-r2.ebuild new file mode 100644 index 000000000000..60c8a72d6d96 --- /dev/null +++ b/app-misc/graphlcd-base/graphlcd-base-2.0.3-r2.ebuild @@ -0,0 +1,91 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit optfeature toolchain-funcs udev + +DESCRIPTION="Contains the lowlevel lcd drivers for GraphLCD" +HOMEPAGE="https://projects.vdr-developer.org/projects/graphlcd-base" +SRC_URI="https://projects.vdr-developer.org/git/${PN}.git/snapshot/${P}.tar.bz2" + +KEYWORDS="amd64 x86" +SLOT="0" +LICENSE="GPL-2" +IUSE="fontconfig freetype graphicsmagick imagemagick lcd_devices_ax206dpf lcd_devices_picolcd_256x64 lcd_devices_vnc" +REQUIRED_USE="?? ( graphicsmagick imagemagick )" + +RDEPEND=" + dev-libs/libhid + net-libs/libvncserver + freetype? ( media-libs/freetype:2= ) + fontconfig? ( media-libs/fontconfig:1.0= ) + graphicsmagick? ( media-gfx/graphicsmagick:0/1.3[cxx] ) + imagemagick? ( media-gfx/imagemagick:= ) + lcd_devices_ax206dpf? ( virtual/libusb:0 ) + lcd_devices_picolcd_256x64? ( virtual/libusb:0 ) +" + +DEPEND="${RDEPEND}" + +BDEPEND="virtual/pkgconfig" + +DOCS=( "HISTORY" "README" "TODO" "docs/." ) + +PATCHES=( "${FILESDIR}/${PN}-2.0.3-imagemagick7.patch" ) + +src_prepare() { + default + + # Change '/usr/local/' to '/usr' + # Change '/usr/lib' to '/usr/$(get_libdir)' + sed -e "34s:/usr/local:/usr:" -e "37s:/lib:/$(get_libdir):" -i Make.config || die + + # Fix newer GCC version with the Futaba MDM166A lcd driver + sed -e "s:0xff7f0004:(int) 0xff7f0004:" -i glcddrivers/futabaMDM166A.c || die + + tc-export CC CXX +} + +src_configure() { + # Build optional drivers + if use lcd_devices_ax206dpf; then + sed -e "78s:#::" -i Make.config || die + fi + if use lcd_devices_picolcd_256x64; then + sed -e "81s:#::" -i Make.config || die + fi + if ! use lcd_devices_vnc; then + sed -e "72s:1:0:" -i Make.config || die + fi + + # Build optional features + if ! use freetype; then + sed -e "59s:HAVE:#HAVE:" -i Make.config || die + fi + if ! use fontconfig; then + sed -e "62s:HAVE:#HAVE:" -i Make.config || die + fi + if use graphicsmagick; then + sed -e "69s:#::" -i Make.config || die + fi + if use imagemagick; then + sed -e "68s:#::" -i Make.config || die + fi +} + +src_install() { + emake DESTDIR="${D}" UDEVRULESDIR="$(get_udevdir)/rules.d" install + + einstalldocs +} + +pkg_postinst() { + udev_reload + + optfeature "supporting the logitech g15 keyboard lcd." app-misc/g15daemon +} + +pkg_postrm() { + udev_reload +} diff --git a/app-misc/graphlcd-base/metadata.xml b/app-misc/graphlcd-base/metadata.xml index 6d4dd80259e1..9d640b6cfa37 100644 --- a/app-misc/graphlcd-base/metadata.xml +++ b/app-misc/graphlcd-base/metadata.xml @@ -20,5 +20,7 @@ Add support for media-libs/fontconfig font names. Add support for media-libs/freetype. + Add support for media-gfx/graphicsmagick. + Add support for media-gfx/imagemagick. -- cgit v1.2.3-65-gdbad