renamed png functions
[swftools.git] / lib / devices / render.c
index 8e0ada0..c1c803c 100644 (file)
@@ -25,9 +25,8 @@
 #include "../gfxdevice.h"
 #include "../gfxtools.h"
 #include "../mem.h"
-#define PNG_INLINE_EXPORTS
 #include "../types.h"
-#include "../png.c"
+#include "../png.h"
 #include "../log.h"
 #include "render.h"
 
@@ -275,16 +274,16 @@ static void fill_line_solid(RGBA*line, U32*z, int y, int x1, int x2, RGBA col)
 
     if(col.a!=255) {
         int ainv = 255-col.a;
-        col.r = (col.r*col.a)>>8;
-        col.g = (col.g*col.a)>>8;
-        col.b = (col.b*col.a)>>8;
+        col.r = (col.r*col.a)/255;
+        col.g = (col.g*col.a)/255;
+        col.b = (col.b*col.a)/255;
         do {
            if(z[bitpos]&bit) {
-               line[x].r = ((line[x].r*ainv)>>8)+col.r;
-               line[x].g = ((line[x].g*ainv)>>8)+col.g;
-               line[x].b = ((line[x].b*ainv)>>8)+col.b;
+               line[x].r = ((line[x].r*ainv)/255)+col.r;
+               line[x].g = ((line[x].g*ainv)/255)+col.g;
+               line[x].b = ((line[x].b*ainv)/255)+col.b;
                //line[x].a = 255;
-               line[x].a = ((line[x].a*ainv)>>8)+col.a;
+               line[x].a = ((line[x].a*ainv)/255)+col.a;
            }
            bit <<= 1;
            if(!bit) {
@@ -354,9 +353,9 @@ static void fill_line_bitmap(RGBA*line, U32*z, int y, int x1, int x2, fillinfo_t
            ainv = 255-col.a;
 
            /* needs bitmap with premultiplied alpha */
-           line[x].r = ((line[x].r*ainv)>>8)+col.r;
-           line[x].g = ((line[x].g*ainv)>>8)+col.g;
-           line[x].b = ((line[x].b*ainv)>>8)+col.b;
+           line[x].r = ((line[x].r*ainv)/255)+col.r;
+           line[x].g = ((line[x].g*ainv)/255)+col.g;
+           line[x].b = ((line[x].b*ainv)/255)+col.b;
            line[x].a = 255;
        }
        bit <<= 1;
@@ -609,7 +608,7 @@ void render_stroke(struct _gfxdevice*dev, gfxline_t*line, gfxcoord_t width, gfxc
 static void draw_line(gfxdevice_t*dev, gfxline_t*line)
 {
     internal_t*i = (internal_t*)dev->internal;
-    double x,y;
+    double x=0,y=0;
 
     while(line)
     {
@@ -801,18 +800,18 @@ int render_result_save(gfxresult_t*r, const char*filename)
        while(i->next) {
            sprintf(filenamebuf, "%s.%d.png", origname, nr);
             if(!i->palette) {
-               writePNG(filename, (unsigned char*)i->img.data, i->img.width, i->img.height);
+               png_write(filename, (unsigned char*)i->img.data, i->img.width, i->img.height);
             } else {
-               writePalettePNG(filename, (unsigned char*)i->img.data, i->img.width, i->img.height);
+               png_write_palette_based_2(filename, (unsigned char*)i->img.data, i->img.width, i->img.height);
             }
            nr++;
        }
        free(origname);
     } else {
         if(!i->palette) {
-           writePNG(filename, (unsigned char*)i->img.data, i->img.width, i->img.height);
+           png_write(filename, (unsigned char*)i->img.data, i->img.width, i->img.height);
        } else {
-           writePalettePNG(filename, (unsigned char*)i->img.data, i->img.width, i->img.height);
+           png_write_palette_based_2(filename, (unsigned char*)i->img.data, i->img.width, i->img.height);
        }
     }
     return 1;