From e9070b6571e0fffb70b5a7f0625906d1627b37c1 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Sat, 29 Sep 2018 05:17:45 +0300 Subject: [PATCH] hacked image loading to use assman --- Makefile | 2 +- src/image.cc | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 370828e..a7334ee 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ warn = -pedantic -Wall CFLAGS = $(warn) $(opt) $(dbg) $(incpath) -fopenmp CXXFLAGS = -std=c++11 $(warn) $(opt) $(dbg) $(incpath) -fopenmp LDFLAGS = $(libpath) -ldrawtext $(libgl_$(sys)) $(libal_$(sys)) -lm -lgmath -lvmath \ - -limago -lresman -lpthread -lassimp -ltreestore -lgoatvr \ + -limago -lresman -lpthread -lassimp -ltreestore -lgoatvr -lassman \ `pkg-config --libs sdl2 freetype2` -lpng -ljpeg -lz -lvorbisfile -lgomp sys ?= $(shell uname -s | sed 's/MINGW.*/mingw/') diff --git a/src/image.cc b/src/image.cc index 57817ca..ce930f3 100644 --- a/src/image.cc +++ b/src/image.cc @@ -7,6 +7,7 @@ #endif #include "imago2.h" +#include "assman.h" #include "image.h" static int pixel_elements(Image::Format fmt); @@ -171,12 +172,30 @@ void Image::resize_half() height = newysz; } +static size_t io_read(void *buf, size_t bytes, void *fp) +{ + return ass_fread(buf, 1, bytes, fp); +} + +static long io_seek(long offs, int whence, void *fp) +{ + ass_fseek(fp, offs, whence); + return ass_ftell(fp); +} + bool Image::load(const char *fname) { struct img_pixmap pixmap; + struct img_io io = {0, io_read, 0, io_seek}; + ass_file *fp; + + if(!(fp = ass_fopen(fname, "rb"))) { + return false; + } + io.uptr = fp; img_init(&pixmap); - if(img_load(&pixmap, fname) == -1) { + if(img_read(&pixmap, &io) == -1) { return false; } -- 1.7.10.4