X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fgfximage.c;h=661f9cd9db2a7981b63f3638f36b3079a00d6813;hp=58f18b3295aa83e811034c2c2431760e92e79d2d;hb=c63b2bf21dc1df9a736f0b4c08f6cba828cdab92;hpb=8f67c24d3250b417099a27525c3ef14ab1c7b3db diff --git a/lib/gfximage.c b/lib/gfximage.c index 58f18b3..661f9cd 100644 --- a/lib/gfximage.c +++ b/lib/gfximage.c @@ -1,3 +1,4 @@ +#include #include #include #include "jpeg.h" @@ -6,6 +7,15 @@ #include "gfximage.h" #include "types.h" +gfximage_t*gfximage_new(int width, int height) +{ + gfximage_t*i = rfx_calloc(sizeof(gfximage_t)); + i->data = rfx_calloc(width*height*4); + i->width = width; + i->height = height; + return i; +} + void gfximage_save_jpeg(gfximage_t*img, const char*filename, int quality) { int x,y; @@ -18,6 +28,7 @@ void gfximage_save_jpeg(gfximage_t*img, const char*filename, int quality) data[s+2] = img->data[t].b; } jpeg_save(data, img->width, img->height, quality, filename); + free(data); } void gfximage_save_png(gfximage_t*image, const char*filename) @@ -153,10 +164,10 @@ void blurImage(gfxcolor_t*src, int width, int height, int r) for(y=0;y> 16; d[x].a = a >> 16; } - for(x=width-range;x> 16; yy += width; } - for(y=0;ywidth; int height = image->height; @@ -340,3 +353,11 @@ gfximage_t* gfximage_rescale(gfximage_t*image, int newwidth, int newheight) image2->height = newheight; return image2; } + +void gfximage_free(gfximage_t*b) +{ + free(b->data); + b->data = 0; + free(b); +} +