+ tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
+ swf_ObjectPlace(tag,myshapeid,/*depth*/depth++,NULL,NULL,NULL);
+}
+
+int swfoutput_drawimagejpeg_old(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(obj,0);
+ if(textid>=0)
+ endtext(obj);
+
+ 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;
+ }
+
+ drawimage(obj, bitid, sizex, sizey, x1,y1,x2,y2,x3,y3,x4,y4);
+ return bitid;
+}
+
+int 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)
+{
+ TAG*oldtag;
+ JPEGBITS*jpeg;
+
+ if(shapeid>=0)
+ endshape(obj,0);
+ if(textid>=0)
+ endtext(obj);
+
+ int bitid = ++currentswfid;
+ oldtag = tag;
+ tag = swf_InsertTag(tag,ST_DEFINEBITSJPEG2);
+ swf_SetU16(tag, bitid);
+ swf_SetJPEGBits2(tag,sizex,sizey,mem,jpegquality);
+ drawimage(obj, bitid, sizex, sizey, x1,y1,x2,y2,x3,y3,x4,y4);
+ return bitid;
+}
+
+int 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)
+{
+ TAG*oldtag;
+ if(shapeid>=0)
+ endshape(obj,0);
+ if(textid>=0)
+ endtext(obj);
+
+ 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;
+}
+
+int swfoutput_drawimagelosslessN(struct swfoutput*obj, U8*mem, RGBA*pal, int sizex,int sizey,
+ double x1,double y1,
+ double x2,double y2,
+ double x3,double y3,
+ double x4,double y4, int n)
+{
+ TAG*oldtag;
+ U8*mem2 = 0;
+ if(shapeid>=0)
+ endshape(obj,0);
+ if(textid>=0)
+ endtext(obj);
+
+ if(sizex&3)
+ {
+ /* SWF expects scanlines to be 4 byte aligned */
+ int x,y;
+ U8*ptr;
+ mem2 = (U8*)malloc(BYTES_PER_SCANLINE(sizex)*sizey);
+ ptr = mem2;
+ for(y=0;y<sizey;y++)
+ {
+ for(x=0;x<sizex;x++)
+ *ptr++ = mem[y*sizex+x];
+ ptr+= BYTES_PER_SCANLINE(sizex)-sizex;
+ }
+ mem = mem2;
+ }
+
+ int bitid = ++currentswfid;
+ oldtag = tag;
+ tag = swf_InsertTag(tag,ST_DEFINEBITSLOSSLESS2);
+ swf_SetU16(tag, bitid);
+ if(swf_SetLosslessBitsIndexed(tag,sizex,sizey,mem, pal, n)<0) {
+ swf_DeleteTag(tag);
+ tag = oldtag;
+ return -1;
+ }
+ if(mem2)
+ free(mem2);
+
+ drawimage(obj, bitid, sizex, sizey, x1,y1,x2,y2,x3,y3,x4,y4);
+ return bitid;
+}
+
+void swfoutput_drawimageagain(struct swfoutput*obj, int id, int sizex,int sizey,
+ double x1,double y1,
+ double x2,double y2,
+ double x3,double y3,
+ double x4,double y4)
+{
+ if(id<0) return;
+ if(shapeid>=0)
+ endshape(obj,0);
+ if(textid>=0)
+ endtext(obj);
+
+ drawimage(obj, id, sizex, sizey, x1,y1,x2,y2,x3,y3,x4,y4);
+}
+
+void swfoutput_setparameter(char*name, char*value)
+{
+ if(!strcmp(name, "drawonlyshapes")) {
+ drawonlyshapes = atoi(value);
+ } else if(!strcmp(name, "ignoredraworder")) {
+ ignoredraworder = atoi(value);
+ } else if(!strcmp(name, "filloverlap")) {
+ filloverlap = atoi(value);
+ } else if(!strcmp(name, "linksopennewwindow")) {
+ opennewwindow = atoi(value);
+ } else if(!strcmp(name, "opennewwindow")) {
+ opennewwindow = atoi(value);
+ } else if(!strcmp(name, "storeallcharacters")) {
+ storeallcharacters = atoi(value);
+ } else if(!strcmp(name, "enablezlib")) {
+ enablezlib = atoi(value);
+ } else if(!strcmp(name, "insertstop")) {
+ insertstoptag = atoi(value);
+ } else if(!strcmp(name, "flashversion")) {
+ flashversion = atoi(value);
+ } else if(!strcmp(name, "minlinewidth")) {
+ minlinewidth = atof(value);
+ } else if(!strcmp(name, "jpegquality")) {
+ int val = atoi(value);
+ if(val<0) val=0;
+ if(val>100) val=100;
+ 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;
+ 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;
+ fontsplinemaxerror = v;
+ } else {
+ fprintf(stderr, "unknown parameter: %s (=%s)\n", name, value);
+ }