- int bitid = ++currentswfid;
- oldtag = tag;
- tag = swf_InsertTag(tag,ST_DEFINEBITSLOSSLESS);
- swf_SetU16(tag, bitid);
- if(swf_SetLosslessBits(tag,sizex,sizey,mem, BMF_32BIT)<0) {
- swf_DeleteTag(tag);
- tag = oldtag;
- return -1;
- }
-
- drawimage(obj, bitid, sizex, sizey, x1,y1,x2,y2,x3,y3,x4,y4);
- return bitid;
+ gfxbbox_t bbox = gfxline_getbbox(line);
+
+ int targetx = (int)(sqrt(matrix->m00*matrix->m00 + matrix->m01*matrix->m01)*img->width);
+ int targety = (int)(sqrt(matrix->m10*matrix->m10 + matrix->m11*matrix->m11)*img->height);
+
+ int newwidth=0,newheight=0;
+ int bitid = add_image(i, img, targetx, targety, &newwidth, &newheight);
+ double fx = (double)img->width / (double)newwidth;
+ double fy = (double)img->height / (double)newheight;
+
+ MATRIX m;
+ float m00,m10,tx;
+ float m01,m11,ty;
+ m.sx = (int)(65536*20*matrix->m00*fx);
+ m.r0 = (int)(65536*20*matrix->m01*fx);
+ m.r1 = (int)(65536*20*matrix->m10*fy);
+ m.sy = (int)(65536*20*matrix->m11*fy);
+ m.tx = (int)(matrix->tx*20);
+ m.ty = (int)(matrix->ty*20);
+
+ /* shape */
+ int myshapeid = ++i->currentswfid;
+ i->tag = swf_InsertTag(i->tag,ST_DEFINESHAPE);
+ SHAPE*shape;
+ swf_ShapeNew(&shape);
+ int fsid = swf_ShapeAddBitmapFillStyle(shape,&m,bitid,1);
+ SRECT r;
+ swf_SetU16(i->tag, myshapeid);
+ r.xmin = (int)(bbox.xmin*20);
+ r.ymin = (int)(bbox.ymin*20);
+ r.xmax = (int)(bbox.xmax*20);
+ r.ymax = (int)(bbox.ymax*20);
+ swf_SetRect(i->tag,&r);
+ swf_SetShapeStyles(i->tag,shape);
+ swf_ShapeCountBits(shape,NULL,NULL);
+ swf_SetShapeBits(i->tag,shape);
+ swf_ShapeSetAll(i->tag,shape,/*x*/0,/*y*/0,/*ls*/0,fsid,0);
+ i->swflastx = i->swflasty = 0;
+ drawgfxline(obj, line);
+ swf_ShapeSetEnd(i->tag);
+ swf_ShapeFree(shape);
+
+ i->tag = swf_InsertTag(i->tag,ST_PLACEOBJECT2);
+ CXFORM cxform2 = gfxcxform_to_cxform(cxform);
+ swf_ObjectPlace(i->tag,myshapeid,/*depth*/i->depth++,&i->page_matrix,&cxform2,NULL);