1
0
mirror of git://projects.qi-hardware.com/openwrt-packages.git synced 2024-11-10 22:39:43 +02:00

alpy: add support for loading jpeg and png files

This commit is contained in:
David Kühling 2012-03-31 02:03:24 +02:00
parent 186242d171
commit 74e63f2bd2
2 changed files with 50 additions and 4 deletions

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=alpy
PKG_VERSION:=0.1.5
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_SOURCE:=Alpy-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/project/pyallegro/alpy/alpy-$(PKG_VERSION)
PKG_MD5SUM:=862925d97931fc81d1e4c3b9159fe2b1
@ -24,7 +24,8 @@ define Package/alpy/Default
CATEGORY:=Languages
TITLE:=Alpy (Allegro bindings for Python)
URL:=https://sourceforge.net/projects/forth-alpy/
DEPENDS:=+python-mini +liballegro
DEPENDS:=+python-mini +liballegro +liballegro-png +liballegro-jpeg
endef
define Package/alpy/Default/description
@ -69,7 +70,15 @@ endef
# $(PKG_BUILD_DIR)/setup.py build
# endef
TARGET_LDFLAGS += -lm -lpthread -ldl -lrt -lalleg
# Note: this linking command will not work correctly when jpgalleg or loadpng
# are linked statically (Note how we patched allegro to make sure these are
# always compiled as dynamic libraries). The problem probably is, that
# Build/Compile adds these linking options to early in the command line, and
# static libraries won't resolve symbols of objects added later on.
#
# You won't even see a compiler error; the resulting _alpy.so would be going
# to segfault due to an unresolved (0-pointer) symbol.
TARGET_LDFLAGS += -ljpgalleg -lloadpng -lalleg -lpng -lz -lm -lpthread -ldl -lrt
define Build/Install
$(call Build/Compile/PyMod,, \

View File

@ -0,0 +1,37 @@
Index: Alpy-0.1.5/_alpymodule.c
===================================================================
--- Alpy-0.1.5.orig/_alpymodule.c 2012-03-31 01:15:51.052570081 +0200
+++ Alpy-0.1.5/_alpymodule.c 2012-03-31 01:20:50.874079951 +0200
@@ -27,6 +27,8 @@
#include "Python.h"
#include "allegro.h"
+#include "loadpng.h"
+#include "jpgalleg.h"
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
@@ -253,6 +255,10 @@
}
result = install_allegro(alpy_system, &errno, atexit);
+ if (result == 0)
+ result = loadpng_init();
+ if (result == 0)
+ result = jpgalleg_init();
return PyInt_FromLong(result);
}
@@ -2599,6 +2605,12 @@
else if(strcmp(type, "lbm")==0) {
bmp = Bitmap_Object_from_BITMAP(load_lbm(filename, PAL(pal)));
}
+ else if(strcmp(type, "png")==0) {
+ bmp = Bitmap_Object_from_BITMAP(load_png(filename, PAL(pal)));
+ }
+ else if(strcmp(type, "jpg")==0 || strcmp(type, "jpeg")==0) {
+ bmp = Bitmap_Object_from_BITMAP(load_jpg(filename, PAL(pal)));
+ }
else {
PyMem_Free(filename);
PyErr_SetString(AllegroError, "unknown image type");