From 2303855238a45e033d50a751da4e637fc1d5aa80 Mon Sep 17 00:00:00 2001 From: jylam Date: Sun, 19 Oct 2008 11:05:47 +0000 Subject: [PATCH] * CoreImage loader fails cleanly when specified image doesn't exist git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@3020 92316355-f0b4-4df1-b90c-862c8a59935f --- pipi/codec/coreimage.m | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pipi/codec/coreimage.m b/pipi/codec/coreimage.m index 22d2d1c..b969e82 100644 --- a/pipi/codec/coreimage.m +++ b/pipi/codec/coreimage.m @@ -31,7 +31,11 @@ pipi_image_t *pipi_load_coreimage(const char *name) NSString *n = [NSString stringWithCString: name]; CIImage *source; NSURL *url = [NSURL fileURLWithPath:n]; + source = [CIImage imageWithContentsOfURL:url]; + + if(source == NULL) return NULL; + CGRect extent = [source extent]; size_t w = (size_t)extent.size.width; size_t h = (size_t)extent.size.height; @@ -43,12 +47,12 @@ pipi_image_t *pipi_load_coreimage(const char *name) pipi_image_t *img; img = pipi_new(w, h); img->p[PIPI_PIXELS_RGBA_C].pixels = [myImage bitmapData]; - img->p[PIPI_PIXELS_RGBA_C].w = w; - img->p[PIPI_PIXELS_RGBA_C].h = h; - img->p[PIPI_PIXELS_RGBA_C].pitch = ([myImage bytesPerRow]/8) * img->w; - img->p[PIPI_PIXELS_RGBA_C].bpp = [myImage bitsPerPixel]; - img->p[PIPI_PIXELS_RGBA_C].bytes = ([myImage bitsPerPixel]/8) * img->w * img->h; - img->last_modified = PIPI_PIXELS_RGBA_C; + img->p[PIPI_PIXELS_RGBA_C].w = w; + img->p[PIPI_PIXELS_RGBA_C].h = h; + img->p[PIPI_PIXELS_RGBA_C].pitch = ([myImage bytesPerRow]/8) * img->w; + img->p[PIPI_PIXELS_RGBA_C].bpp = [myImage bitsPerPixel]; + img->p[PIPI_PIXELS_RGBA_C].bytes = ([myImage bitsPerPixel]/8) * img->w * img->h; + img->last_modified = PIPI_PIXELS_RGBA_C; img->codec_priv = (struct pipi_codec_coreimage *) malloc(sizeof(struct pipi_codec_coreimage *)); struct pipi_codec_coreimage *infos = (struct pipi_codec_coreimage *) img->codec_priv;