X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fgfxtools.c;h=d8aef3f099c7341af079b6f6d6a1d84782897c28;hb=0e9d27093c3e6e8e316fbc08bb9d422d74da2fd1;hp=239ba6fe137a7e3b54649c909c599d8d93f0a319;hpb=5ecffaed1b9b648c52ddd99d8c879f6ab1280575;p=swftools.git diff --git a/lib/gfxtools.c b/lib/gfxtools.c index 239ba6f..d8aef3f 100644 --- a/lib/gfxtools.c +++ b/lib/gfxtools.c @@ -28,6 +28,7 @@ #include #include "gfxtools.h" #include "gfxfont.h" +#include "jpeg.h" typedef struct _linedraw_internal { @@ -794,7 +795,18 @@ char gfxfontlist_hasfont(gfxfontlist_t*list, gfxfont_t*font) } return 0; } -gfxfontlist_t*gfxfontlist_addfont(gfxfontlist_t*list, gfxfont_t*font) +void*gfxfontlist_getuserdata(gfxfontlist_t*list, const char*id) +{ + gfxfontlist_t*l = list; + while(l) { + if(!strcmp((char*)l->font->id, id)) { + return l->user; + } + l = l->next; + } + return 0; +} +gfxfontlist_t*gfxfontlist_addfont2(gfxfontlist_t*list, gfxfont_t*font, void*user) { gfxfontlist_t*last=0,*l = list; while(l) { @@ -809,6 +821,7 @@ gfxfontlist_t*gfxfontlist_addfont(gfxfontlist_t*list, gfxfont_t*font) } l = (gfxfontlist_t*)rfx_calloc(sizeof(gfxfontlist_t)); l->font = font; + l->user = user; l->next = 0; if(last) { last->next = l; @@ -817,6 +830,10 @@ gfxfontlist_t*gfxfontlist_addfont(gfxfontlist_t*list, gfxfont_t*font) return l; } } +gfxfontlist_t*gfxfontlist_addfont(gfxfontlist_t*list, gfxfont_t*font) +{ + return gfxfontlist_addfont2(list, font, 0); +} void gfxfontlist_free(gfxfontlist_t*list, char deletefonts) { gfxfontlist_t*l = list; @@ -987,3 +1004,18 @@ void gfxline_dump(gfxline_t*line, FILE*fi, char*prefix) } } +void gfximage_save_jpeg(gfximage_t*img, char*filename, int quality) +{ + unsigned char*data = malloc(img->width*img->height*3); + int t; + int size = img->width*img->height; + int s = 0; + for(t=0;tdata[t].r; + data[s+1] = img->data[t].g; + data[s+2] = img->data[t].b; + s+=3; + } + jpeg_save(data, img->width, img->height, quality, filename); +} +