X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2Fswfoutput.cc;h=1890e97f4048835b112b497f63bf8be6ad6fcc9b;hb=6b6dbbd49f51d7ca661a4ee8eba96426f288b177;hp=f009e287df8ea831adb779347a91bb61735835e8;hpb=547b043e6c1c987f89ab49c1735f49bb5e88c6d4;p=swftools.git diff --git a/pdf2swf/swfoutput.cc b/pdf2swf/swfoutput.cc index f009e28..1890e97 100644 --- a/pdf2swf/swfoutput.cc +++ b/pdf2swf/swfoutput.cc @@ -168,7 +168,6 @@ void drawpath(TAG*tag, T1_OUTLINE*outline, struct swfmatrix*m) double lastx=0,lasty=0; double firstx=0,firsty=0; int init=1; - if(log) printf("shape-start %d\n", fill); while (outline) { @@ -178,7 +177,7 @@ void drawpath(TAG*tag, T1_OUTLINE*outline, struct swfmatrix*m) { if(((int)(lastx*20) != (int)(firstx*20) || (int)(lasty*20) != (int)(firsty*20)) && - fill) + fill && !init) { plotxy p0; plotxy p1; @@ -191,6 +190,7 @@ void drawpath(TAG*tag, T1_OUTLINE*outline, struct swfmatrix*m) } firstx=x; firsty=y; + init = 0; } else if(outline->type == T1_PATHTYPE_LINE) { @@ -241,7 +241,6 @@ void drawpath(TAG*tag, T1_OUTLINE*outline, struct swfmatrix*m) if(log) printf("fix: %f,%f -> %f,%f\n",p0.x,p0.y,p1.x,p1.y); line(tag, p0, p1, m); } - if(log) printf("shape-end\n"); } int colorcompare(RGBA*a,RGBA*b) @@ -442,7 +441,7 @@ void drawchar(struct swfoutput*obj, SWFFont*font, char*character, swfmatrix*m) char* charname = character; if(!outline) { - logf("Didn't find %s in current charset (%s)", + logf(" Didn't find %s in current charset (%s)", character,font->getName()); return; } @@ -990,11 +989,13 @@ void swfoutput_startclip(swfoutput*obj, T1_OUTLINE*outline, struct swfmatrix*m) logf(" Too many clip levels."); clippos --; } - + startshape(obj); + int olddrawmode = drawmode; swfoutput_setdrawmode(obj, DRAWMODE_CLIP); swfoutput_drawpath(obj, outline, m); ShapeSetEnd(tag); + swfoutput_setdrawmode(obj, olddrawmode); tag = InsertTag(tag,ST_PLACEOBJECT2); cliptags[clippos] = tag; @@ -1019,22 +1020,17 @@ void swfoutput_endclip(swfoutput*obj) PlaceObject(cliptags[clippos],clipshapes[clippos],clipdepths[clippos],NULL,NULL,NULL,depth++); } -void swfoutput_drawimagefile(struct swfoutput*, char*filename, int sizex,int sizey, + +void drawimage(struct swfoutput*obj, int bitid, int sizex,int sizey, double x1,double y1, double x2,double y2, double x3,double y3, double x4,double y4) { - if(shapeid>=0) - endshape(); - if(textid>=0) - endtext(); - RGBA rgb; SRECT r; int lsid=0; int fsid; - int bitid; struct plotxy p1,p2,p3,p4; int myshapeid; double xmax=x1,ymax=y1,xmin=x1,ymin=y1; @@ -1067,14 +1063,7 @@ void swfoutput_drawimagefile(struct swfoutput*, char*filename, int sizex,int siz m.tx = (int)(x1*20); m.ty = (int)(y1*20); - - bitid = ++currentswfid; - /* bitmap */ - tag = InsertTag(tag,ST_DEFINEBITSJPEG2); - SetU16(tag, bitid); - SetJPEGBits(tag, filename, jpegquality); - /* shape */ myshapeid = ++currentswfid; tag = InsertTag(tag,ST_DEFINESHAPE); @@ -1111,3 +1100,77 @@ void swfoutput_drawimagefile(struct swfoutput*, char*filename, int sizex,int siz 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) +{ + if(shapeid>=0) + endshape(); + if(textid>=0) + endtext(); + + int bitid = ++currentswfid; + tag = InsertTag(tag,ST_DEFINEBITSJPEG2); + SetU16(tag, bitid); + SetJPEGBits(tag, filename, 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) +{ + if(shapeid>=0) + endshape(); + if(textid>=0) + endtext(); + + int bitid = ++currentswfid; + tag = InsertTag(tag,ST_DEFINEBITSLOSSLESS); + SetU16(tag, bitid); + SetLosslessBits(tag,sizex,sizey,mem, BMF_32BIT); + + drawimage(obj, bitid, sizex, sizey, x1,y1,x2,y2,x3,y3,x4,y4); + return bitid; +} + +int swfoutput_drawimagelossless256(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) +{ + if(shapeid>=0) + endshape(); + if(textid>=0) + endtext(); + + int bitid = ++currentswfid; + tag = InsertTag(tag,ST_DEFINEBITSLOSSLESS2); + SetU16(tag, bitid); + SetLosslessBitsIndexed(tag,sizex,sizey,mem, pal, 256); + + 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(shapeid>=0) + endshape(); + if(textid>=0) + endtext(); + + drawimage(obj, id, sizex, sizey, x1,y1,x2,y2,x3,y3,x4,y4); +} +