- /* shape */
- myshapeid = ++currentswfid;
- tag = swf_InsertTag(tag,ST_DEFINESHAPE);
- swf_ShapeNew(&shape);
- //lsid = ShapeAddLineStyle(shape,obj->linewidth,&obj->strokergb);
- //fsid = ShapeAddSolidFillStyle(shape,&obj->fillrgb);
- fsid = swf_ShapeAddBitmapFillStyle(shape,&m,bitid,0);
- swf_SetU16(tag, myshapeid);
- r.xmin = (int)(xmin*20);
- r.ymin = (int)(ymin*20);
- r.xmax = (int)(xmax*20);
- r.ymax = (int)(ymax*20);
- swf_SetRect(tag,&r);
- swf_SetShapeStyles(tag,shape);
- swf_ShapeCountBits(shape,NULL,NULL);
- swf_SetShapeBits(tag,shape);
- swf_ShapeSetAll(tag,shape,/*x*/0,/*y*/0,lsid,fsid,0);
- swflastx = swflasty = 0;
- moveto(tag, p1);
- lineto(tag, p2);
- lineto(tag, p3);
- lineto(tag, p4);
- lineto(tag, p1);
- /*
- ShapeMoveTo (tag, shape, (int)(x1*20),(int)(y1*20));
- ShapeSetLine (tag, shape, (int)(x1*20);
- ShapeSetLine (tag, shape, x*20,0);
- ShapeSetLine (tag, shape, 0,-y*20);
- ShapeSetLine (tag, shape, -x*20,0);*/
- swf_ShapeSetEnd(tag);
-
- /* instance */
- tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
- swf_ObjectPlace(tag,myshapeid,/*depth*/depth++,NULL,NULL,NULL);
-}
-
-int swfoutput_drawimagejpeg(struct swfoutput*obj, char*filename, int sizex,int sizey,
- double x1,double y1,
- double x2,double y2,
- double x3,double y3,
- double x4,double y4)
-{
- TAG*oldtag;
- if(shapeid>=0)
- endshape();
- if(textid>=0)
- endtext();
-
- int bitid = ++currentswfid;
- oldtag = tag;
- tag = swf_InsertTag(tag,ST_DEFINEBITSJPEG2);
- swf_SetU16(tag, bitid);
- if(swf_SetJPEGBits(tag, filename, jpegquality)<0) {
- swf_DeleteTag(tag);
- tag = oldtag;
- return -1;
+ if(type == IMAGE_TYPE_JPEG)
+ /* TODO: pass image_dpi to device instead */
+ i->device.setparameter(&i->device, "next_bitmap_is_jpeg", "1");
+
+ i->device.fillbitmap(&i->device, &p1, &img, &m, 0);
+}
+
+void swfoutput_drawimagejpeg(struct swfoutput*obj, RGBA*mem, int sizex,int sizey,
+ double x1,double y1, double x2,double y2, double x3,double y3, double x4,double y4)
+{
+ swfoutput_drawimage(obj,mem,sizex,sizey,x1,y1,x2,y2,x3,y3,x4,y4, IMAGE_TYPE_JPEG);
+}
+
+void swfoutput_drawimagelossless(struct swfoutput*obj, RGBA*mem, int sizex,int sizey,
+ double x1,double y1, double x2,double y2, double x3,double y3, double x4,double y4)
+{
+ swfoutput_drawimage(obj,mem,sizex,sizey,x1,y1,x2,y2,x3,y3,x4,y4, IMAGE_TYPE_LOSSLESS);
+}
+
+void swfoutput_setparameter(char*name, char*value)
+{
+ if(!strcmp(name, "jpegsubpixels")) {
+ config_jpegsubpixels = atof(value);
+ } else if(!strcmp(name, "ppmsubpixels")) {
+ config_ppmsubpixels = atof(value);
+ } else if(!strcmp(name, "drawonlyshapes")) {
+ config_drawonlyshapes = atoi(value);
+ } else if(!strcmp(name, "ignoredraworder")) {
+ config_ignoredraworder = atoi(value);
+ } else if(!strcmp(name, "filloverlap")) {
+ config_filloverlap = atoi(value);
+ } else if(!strcmp(name, "linksopennewwindow")) {
+ config_opennewwindow = atoi(value);
+ } else if(!strcmp(name, "opennewwindow")) {
+ config_opennewwindow = atoi(value);
+ } else if(!strcmp(name, "storeallcharacters")) {
+ config_storeallcharacters = atoi(value);
+ } else if(!strcmp(name, "enablezlib")) {
+ config_enablezlib = atoi(value);
+ } else if(!strcmp(name, "insertstop")) {
+ config_insertstoptag = atoi(value);
+ } else if(!strcmp(name, "protected")) {
+ config_protect = atoi(value);
+ } else if(!strcmp(name, "flashversion")) {
+ config_flashversion = atoi(value);
+ } else if(!strcmp(name, "minlinewidth")) {
+ config_minlinewidth = atof(value);
+ } else if(!strcmp(name, "caplinewidth")) {
+ config_caplinewidth = atof(value);
+ } else if(!strcmp(name, "jpegquality")) {
+ int val = atoi(value);
+ if(val<0) val=0;
+ if(val>100) val=100;
+ config_jpegquality = val;
+ } else if(!strcmp(name, "splinequality")) {
+ int v = atoi(value);
+ v = 500-(v*5); // 100% = 0.25 pixel, 0% = 25 pixel
+ if(v<1) v = 1;
+ config_splinemaxerror = v;
+ } else if(!strcmp(name, "fontquality")) {
+ int v = atoi(value);
+ v = 500-(v*5); // 100% = 0.25 pixel, 0% = 25 pixel
+ if(v<1) v = 1;
+ config_fontsplinemaxerror = v;
+ } else {
+ fprintf(stderr, "unknown parameter: %s (=%s)\n", name, value);