X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fdevices%2Fops.c;h=bda4742235e64c1a16e1212b4322ede12e09faba;hb=ad60d7e0a361c58fc9872753cfb872c3cc54b82f;hp=911bc477bad163493bbcc3c89305f83cdc4e790c;hpb=4c732fe232f3ce785cc1e553aaefbf0f24eabee4;p=swftools.git diff --git a/lib/devices/ops.c b/lib/devices/ops.c index 911bc47..bda4742 100644 --- a/lib/devices/ops.c +++ b/lib/devices/ops.c @@ -21,12 +21,16 @@ #include #include #include +#ifndef WIN32 #include +#endif #include +#include #include "../types.h" #include "../mem.h" #include "../gfxdevice.h" #include "../gfxtools.h" +#include "ops.h" typedef struct _internal { gfxdevice_t*out; @@ -42,7 +46,7 @@ static void dbg(char*format, ...) int l; va_list arglist; va_start(arglist, format); - vsprintf(buf, format, arglist); + vsnprintf(buf, sizeof(buf)-1, format, arglist); va_end(arglist); l = strlen(buf); while(l && buf[l-1]=='\n') { @@ -62,7 +66,7 @@ inline gfxcolor_t transform_color(internal_t*i, gfxcolor_t*col) col2.r = col->r; col2.g = col->g; col2.b = col->b; - col2.a = (col->a * i->alpha)>>8; + col2.a = (col->a * i->alpha)/255; return col2; } @@ -110,7 +114,7 @@ void ops_fillbitmap(struct _gfxdevice*dev, gfxline_t*line, gfximage_t*img, gfxma gfximage_t img2; img2.width = img->width; img2.height = img->height; - img2.data = malloc(img->width*img->height*4); + img2.data = (gfxcolor_t*)malloc(img->width*img->height*4); int x,y; for(y=0;yheight;y++) { gfxcolor_t*in = &img->data[y*img->width]; @@ -142,7 +146,7 @@ void ops_drawchar(struct _gfxdevice*dev, gfxfont_t*font, int glyphnr, gfxcolor_t i->out->drawchar(i->out, font, glyphnr, color, matrix); } -void ops_drawlink(struct _gfxdevice*dev, gfxline_t*line, char*action) +void ops_drawlink(struct _gfxdevice*dev, gfxline_t*line, const char*action) { internal_t*i = (internal_t*)dev->internal; i->out->drawlink(i->out, line, action); @@ -156,7 +160,9 @@ void ops_endpage(struct _gfxdevice*dev) gfxresult_t* ops_finish(struct _gfxdevice*dev) { - free(dev->internal);dev->internal = 0; + if(dev->internal) + free(dev->internal); + dev->internal = 0; return 0; }