renamed png functions
[swftools.git] / lib / readers / swf.c
index 5bff2a1..bf95022 100644 (file)
@@ -92,7 +92,7 @@ void map16_free(map16_t*map)
 void map16_add_id(map16_t*map, int nr, void*id)
 {
     if(map->ids[nr])
-       fprintf(stderr, "Warning: ID %d defined more than once\n");
+       fprintf(stderr, "Warning: ID %d defined more than once\n", nr);
     map->ids[nr] = id;
 }
 void map16_remove_id(map16_t*map, int nr)
@@ -183,7 +183,7 @@ gfxline_t* swfline_to_gfxline(SHAPELINE*line, int linestyle, int fillstyle0)
 
 //---- bitmap handling ----
 
-gfximage_t* gfximage_new(RGBA*data, int width, int height)
+static gfximage_t* gfximage_new(RGBA*data, int width, int height)
 {
     gfximage_t* b = (gfximage_t*)rfx_calloc(sizeof(gfximage_t));
     b->data = (gfxcolor_t*)data;
@@ -192,13 +192,6 @@ gfximage_t* gfximage_new(RGBA*data, int width, int height)
     return b;
 }
 
-void gfximage_free(gfximage_t*b)
-{
-    free(b->data); //!
-    b->data = 0;
-    free(b);
-}
-
 static gfximage_t* findimage(render_t*r, U16 id)
 {
     character_t*c = (character_t*)map16_get_id(r->id2char, id);
@@ -207,7 +200,7 @@ static gfximage_t* findimage(render_t*r, U16 id)
 
     /*char filename[80];
     sprintf(filename, "bitmap%d.png", id);
-    writePNG(filename, (unsigned char*)img->data, img->width, img->height);
+    png_write(filename, (unsigned char*)img->data, img->width, img->height);
     printf("saving bitmap %d to %s\n", id, filename);*/
 
     return c->data;
@@ -347,7 +340,8 @@ static map16_t* extractDefinitions(SWF*swf)
            map16_add_id(map, id, c);
        }
        else if(tag->id == ST_DEFINEFONT ||
-               tag->id == ST_DEFINEFONT2) {
+               tag->id == ST_DEFINEFONT2 ||
+               tag->id == ST_DEFINEFONT3) {
            character_t*c = rfx_calloc(sizeof(character_t));
            SWFFONT*swffont = 0;
            font_t*font = (font_t*)rfx_calloc(sizeof(font_t));
@@ -362,6 +356,10 @@ static map16_t* extractDefinitions(SWF*swf)
                 }
                 SHAPE2*s2 = swf_ShapeToShape2(swffont->glyph[t].shape);
                 font->glyphs[t] = swfline_to_gfxline(s2->lines, 0, 1);
+               if(tag->id==ST_DEFINEFONT3) {
+                   gfxmatrix_t m = {1/20.0,0,0, 0,1/20.0,0};
+                   gfxline_transform(font->glyphs[t], &m);
+               }
                 swf_Shape2Free(s2);
             }
             swf_FontFree(swffont);
@@ -567,7 +565,7 @@ static void placeObject(void*self, int id, void*data)
 
         sprite_t* s = (sprite_t*)c->data;
 
-        map16_t* depths = extractFrame(c->tag->next, p->age % s->frameCount);
+        map16_t* depths = extractFrame(c->tag->next, s->frameCount>0? p->age % s->frameCount : 0);
         map16_enumerate(depths, placeObject, r);
        
         int t;