+ swfoutput_internal*i = (swfoutput_internal*)obj->internal;
+ while(line) {
+ if(line->type == gfx_moveTo) {
+ moveto(obj, i->tag, line->x, line->y);
+ } if(line->type == gfx_lineTo) {
+ lineto(obj, i->tag, line->x, line->y);
+ } else if(line->type == gfx_splineTo) {
+ plotxy s,p;
+ s.x = line->sx;p.x = line->x;
+ s.y = line->sy;p.y = line->y;
+ splineto(obj, i->tag, s, p);
+ }
+ line = line->next;
+ }
+}
+static CXFORM gfxcxform_to_cxform(gfxcxform_t* c)
+{
+ CXFORM cx;
+ swf_GetCXForm(0, &cx, 1);
+ if(!c)
+ return cx;
+ if(c->rg!=0 || c->rb!=0 || c->ra!=0 ||
+ c->gr!=0 || c->gb!=0 || c->ga!=0 ||
+ c->br!=0 || c->bg!=0 || c->ba!=0 ||
+ c->ar!=0 || c->ag!=0 || c->ab!=0)
+ msg("<warning> CXForm not SWF-compatible");
+
+ cx.a0 = (S16)(c->aa*256);
+ cx.r0 = (S16)(c->rr*256);
+ cx.g0 = (S16)(c->gg*256);
+ cx.b0 = (S16)(c->bb*256);
+ cx.a1 = c->t.a;
+ cx.r1 = c->t.r;
+ cx.g1 = c->t.g;
+ cx.b1 = c->t.b;
+ return cx;
+}
+
+static int add_image(swfoutput_internal*i, gfximage_t*img, int targetwidth, int targetheight, int* newwidth, int* newheight)
+{
+ RGBA*newpic = 0;
+ RGBA*mem = (RGBA*)img->data;
+ int bitid = ++i->currentswfid;
+
+ int sizex = img->width;
+ int sizey = img->height;
+ int num_colors = swf_ImageGetNumberOfPaletteEntries(mem,sizex,sizey,0);
+ int has_alpha = swf_ImageHasAlpha(mem,sizex,sizey);
+ int is_jpeg = i->jpeg;
+ i->jpeg = 0;
+
+ int newsizex=sizex, newsizey=sizey;
+
+ /// {
+ if(is_jpeg && config_jpegsubpixels) {
+ newsizex = (int)(targetwidth*config_jpegsubpixels+0.5);
+ newsizey = (int)(targetheight*config_jpegsubpixels+0.5);
+ } else if(!is_jpeg && config_ppmsubpixels) {
+ newsizex = (int)(targetwidth*config_ppmsubpixels+0.5);
+ newsizey = (int)(targetheight*config_ppmsubpixels+0.5);
+ }
+ /// }
+
+ *newwidth = newsizex;
+ *newheight = newsizey;
+
+
+ /* TODO: cache images */
+
+ msg("<verbose> Drawing %dx%d %s%simage at size %dx%d (%dx%d), %s%d colors",
+ sizex, sizey,
+ has_alpha?(has_alpha==2?"semi-transparent ":"transparent "):"",
+ is_jpeg?"jpeg-":"",
+ newsizex, newsizey,
+ targetwidth, targetheight,
+ /*newsizex, newsizey,*/
+ num_colors>256?">":"", num_colors>256?256:num_colors);
+
+ if(newsizex!=sizex || newsizey!=sizey) {
+ newpic = swf_ImageScale(mem, sizex, sizey, newsizex, newsizey);
+ sizex = newsizex;
+ sizey = newsizey;
+ mem = newpic;
+ }