From 3b6859a3668624f49a7bcc7fe53d41cb5f4be243 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Mon, 12 Nov 2018 16:14:31 -0500 Subject: begin integrating ImageMagick --- .gitmodules | 3 +++ ImageMagick | 1 + Makefile | 5 +++-- fb.c | 35 ++++++++++++++++++++++++++++++++++- 4 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 .gitmodules create mode 160000 ImageMagick diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..0d711dc --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "ImageMagick"] + path = ImageMagick + url = git@github.com:ImageMagick/ImageMagick.git diff --git a/ImageMagick b/ImageMagick new file mode 160000 index 0000000..20f093b --- /dev/null +++ b/ImageMagick @@ -0,0 +1 @@ +Subproject commit 20f093b8865ea6c35f36128ae0ba47cc56e699b0 diff --git a/Makefile b/Makefile index 212172e..8692a6d 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ CC=arm-linux-gnueabihf-gcc -CFLAGS=-Wall -Wextra -I. -LDFLAGS=-lpthread +CFLAGS=-Wall -Wextra -I. -IImageMagick +LDFLAGS=-lpthread -LImageMagick/MagickCore/.libs +LDLIBS=-lMagickCore-7.Q8 -lm freeonebook: freeonebook.o gpio.o fb.o diff --git a/fb.c b/fb.c index 8fbb156..7981961 100644 --- a/fb.c +++ b/fb.c @@ -10,6 +10,10 @@ #include #include +#define MAGICKCORE_QUANTUM_DEPTH 8 +#define MAGICKCORE_HDRI_ENABLE 0 +#include + #include "fb.h" #include "gpio.h" @@ -66,7 +70,34 @@ void fb_loadimage(int screen, const char *path) printf("loading image %s\n", path); fflush(NULL); sync(); - int fd = open(path, O_RDONLY); + ExceptionInfo *exception = AcquireExceptionInfo(); + + printf("reading original image\n"); + ImageInfo *info = CloneImageInfo((ImageInfo*)NULL); + strcpy(info->filename, path); + Image *images = ReadImage(info, exception); + + printf("resizing\n"); + Image *original = RemoveFirstImageFromList(&images); + Image *resized = ResizeImage(original, fb.vsi.xres, fb.vsi.yres, LanczosFilter, exception); + DestroyImage(original); + + printf("rotating\n"); + Image *rotated = IntegralRotateImage(resized, 3, exception); + DestroyImage(rotated); + + printf("writing grayscale\n"); + AppendImageToList(&images, rotated); + strcpy(info->filename, "/tmp/converted.gray"); + WriteImage(info, images, exception); + + printf("cleaning up\n"); + DestroyImageList(images); + DestroyImage(rotated); + DestroyImageInfo(info); + DestroyExceptionInfo(exception); + + int fd = open("/tmp/converted.gray", O_RDONLY); if (fd == -1) { printf("not found\n"); fflush(NULL); @@ -98,6 +129,8 @@ void fb_loadimage(int screen, const char *path) void fb_init(void) { + MagickCoreGenesis(NULL, MagickFalse); + fb.fd = open("/dev/fb0", O_RDWR); ioctl(fb.fd, FBIOGET_FSCREENINFO, &fb.fsi); -- cgit v1.2.1