void swf_stroke(gfxdevice_t*dev, gfxline_t*line, gfxcoord_t width, gfxcolor_t*color, gfx_capType cap_style, gfx_joinType joint_style, gfxcoord_t miterLimit);
void swf_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color);
void swf_fillbitmap(gfxdevice_t*dev, gfxline_t*line, gfximage_t*img, gfxmatrix_t*matrix, gfxcxform_t*cxform);
-void swf_fillgradient(gfxdevice_t*dev, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix);
+void swf_fillgradient(gfxdevice_t*dev, gfxline_t*line, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix);
static swfoutput_internal* init_internal_struct()
{
i->storefont = 0;
i->currentswfid = 0;
- i->depth = 1;
- i->startdepth = 1;
+ i->depth = 0;
+ i->startdepth = 0;
i->linewidth = 0;
i->shapeid = -1;
i->textid = -1;
return i;
};
+static int id_error = 0;
+
+static U16 getNewID(struct swfoutput* obj)
+{
+ swfoutput_internal*i = (swfoutput_internal*)obj->internal;
+ if(i->currentswfid == 65535) {
+ if(!id_error)
+ msg("<error> ID Table overflow");
+ id_error=1;
+ }
+ return ++i->currentswfid;
+}
+
static void startshape(struct swfoutput* obj);
static void starttext(struct swfoutput* obj);
static void endshape(struct swfoutput* obj);
}
return 0;
}
-static int moveto(struct swfoutput*obj, TAG*tag, float x, float y)
+static int moveto(struct swfoutput*obj, TAG*tag, double x, double y)
{
swfoutput_internal*i = (swfoutput_internal*)obj->internal;
plotxy p;
FIXNULL(character),charnr, u, FIXNULL((char*)swffont->name), swffont->numchars);
return 0;
}
+ /*if(swffont->glyph[charid].shape->bitlen <= 16) {
+ msg("<warning> Character '%s' (c=%d,u=%d), glyph %d in current charset (%s, %d characters) is empty",
+ FIXNULL(character),charnr, u, charid, FIXNULL((char*)swffont->name), swffont->numchars);
+ return 0;
+ }*/
+
if(i->shapeid>=0)
endshape(obj);
MATRIX m2;
swf_MatrixJoin(&m2,&obj->fontmatrix, &i->page_matrix);
- swf_ObjectPlace(i->tag,i->textid,/*depth*/i->depth++,&m2,NULL,NULL);
+ swf_ObjectPlace(i->tag,i->textid,/*depth*/++i->depth,&m2,NULL,NULL);
i->textid = -1;
}
}
}
- swf_FontSetID(swffont, ++i->currentswfid);
+ swf_FontSetID(swffont, getNewID(obj));
if(getScreenLogLevel() >= LOGLEVEL_DEBUG) {
// print font information
i->tag = swf_InsertTag(i->tag,ST_SHOWFRAME);
i->frameno ++;
- for(i->depth--;i->depth>=i->startdepth;i->depth--) {
+ for(i->depth;i->depth>i->startdepth;i->depth--) {
i->tag = swf_InsertTag(i->tag,ST_REMOVEOBJECT2);
swf_SetU16(i->tag,i->depth);
}
SRECT r;
SHAPE* s;
int ls1=0,fs1=0;
- int shapeid = ++i->currentswfid;
+ int shapeid = getNewID(obj);
r.xmin = x1;
r.ymin = y1;
r.xmax = x2;
swf_ShapeSetEnd(i->tag);
swf_ShapeFree(s);
i->tag = swf_InsertTag(i->tag, ST_PLACEOBJECT2);
- swf_ObjectPlace(i->tag,shapeid,i->depth++,0,0,0);
+ swf_ObjectPlace(i->tag,shapeid,++i->depth,0,0,0);
i->tag = swf_InsertTag(i->tag, ST_PLACEOBJECT2);
- swf_ObjectPlaceClip(i->tag,shapeid,i->depth++,0,0,0,65535);
+ swf_ObjectPlaceClip(i->tag,shapeid,++i->depth,0,0,0,65535);
i->cliptag = i->tag;
}
if(i->cliptag && i->frameno == i->lastframeno) {
SWFPLACEOBJECT obj;
swf_GetPlaceObject(i->cliptag, &obj);
- obj.clipdepth = i->depth++;
+ obj.clipdepth = i->depth;
swf_ResetTag(i->cliptag, i->cliptag->id);
swf_SetPlaceObject(i->cliptag, &obj);
swf_PlaceObjectFree(&obj);
rgb.a = rgb.r = rgb.g = rgb.b = 0xff;
swf_SetRGB(i->tag,&rgb);
- i->startdepth = i->depth = 3; /* leave room for clip and background rectangle */
+ i->startdepth = i->depth = 0;
if(config_protect)
i->tag = swf_InsertTag(i->tag, ST_PROTECT);
i->linestyleid = swf_ShapeAddLineStyle(i->shape,i->linewidth,&obj->strokergb);
i->fillstyleid = swf_ShapeAddSolidFillStyle(i->shape,&obj->fillrgb);
- i->shapeid = ++i->currentswfid;
+ i->shapeid = getNewID(obj);
msg("<debug> Using shape id %d", i->shapeid);
if(i->shapeid>=0)
endshape(obj);
- i->textid = ++i->currentswfid;
+ i->textid = getNewID(obj);
i->swflastx=i->swflasty=0;
}
msg("<trace> Placing shape id %d", i->shapeid);
i->tag = swf_InsertTag(i->tag,ST_PLACEOBJECT2);
- swf_ObjectPlace(i->tag,i->shapeid,/*depth*/i->depth++,&i->page_matrix,NULL,NULL);
+ swf_ObjectPlace(i->tag,i->shapeid,/*depth*/++i->depth,&i->page_matrix,NULL,NULL);
swf_ShapeFree(i->shape);
i->shape = 0;
double posx = 0;
double posy = 0;
int t;
- int buttonid = ++i->currentswfid;
+ int buttonid = getNewID(obj);
for(t=1;t<4;t++)
{
if(points[t].x>xmax) xmax=points[t].x;
xmax -= posx; ymax -= posy;
/* shape */
- myshapeid = ++i->currentswfid;
+ myshapeid = getNewID(obj);
i->tag = swf_InsertTag(i->tag,ST_DEFINESHAPE3);
swf_ShapeNew(&i->shape);
rgb.r = rgb.b = rgb.a = rgb.g = 0;
swf_ShapeSetEnd(i->tag);
/* shape2 */
- myshapeid2 = ++i->currentswfid;
+ myshapeid2 = getNewID(obj);
i->tag = swf_InsertTag(i->tag,ST_DEFINESHAPE3);
swf_ShapeNew(&i->shape);
rgb.r = rgb.b = rgb.a = rgb.g = 255;
m = i->page_matrix;
m.tx = p.x;
m.ty = p.y;
- swf_ObjectPlace(i->tag, buttonid, i->depth++,&m,0,0);
- }
- else {
- swf_ObjectPlace(i->tag, buttonid, i->depth++,&i->page_matrix,0,0);
+ swf_ObjectPlace(i->tag, buttonid, ++i->depth,&m,0,0);
+ } else {
+ swf_ObjectPlace(i->tag, buttonid, ++i->depth,&i->page_matrix,0,0);
}
}
}
}
-
-
static int add_image(swfoutput_internal*i, gfximage_t*img, int targetwidth, int targetheight, int* newwidth, int* newheight)
{
+ swfoutput*obj = i->obj;
RGBA*newpic = 0;
RGBA*mem = (RGBA*)img->data;
- int bitid = ++i->currentswfid;
+ int bitid = getNewID(obj);
int sizex = img->width;
int sizey = img->height;
*newheight = sizey;
if(newsizex<sizex || newsizey<sizey) {
+ msg("<notice> Scaling %dx%d image to %dx%d", sizex, sizey, newsizex, newsizey);
newpic = swf_ImageScale(mem, sizex, sizey, newsizex, newsizey);
*newwidth = sizex = newsizex;
*newheight = sizey = newsizey;
/*newsizex, newsizey,*/
num_colors>256?">":"", num_colors>256?256:num_colors);
- if(has_alpha) {
- if(num_colors<=256 || sizex<8 || sizey<8) {
- i->tag = swf_InsertTag(i->tag,ST_DEFINEBITSLOSSLESS2);
- swf_SetU16(i->tag, bitid);
- swf_SetLosslessImage(i->tag,mem,sizex,sizey);
- } else {
- /*TODO: check what is smaller */
- i->tag = swf_InsertTag(i->tag,ST_DEFINEBITSJPEG3);
- swf_SetU16(i->tag, bitid);
- swf_SetJPEGBits3(i->tag,sizex,sizey,mem,config_jpegquality);
- //swf_SetLosslessImage(i->tag,mem,sizex,sizey);
- }
- } else {
- if(num_colors<=256 || sizex<8 || sizey<8) {
- i->tag = swf_InsertTag(i->tag,ST_DEFINEBITSLOSSLESS);
- swf_SetU16(i->tag, bitid);
- swf_SetLosslessImage(i->tag,mem,sizex,sizey);
- } else {
- /*TODO: check what is smaller */
- i->tag = swf_InsertTag(i->tag,ST_DEFINEBITSJPEG2);
- swf_SetU16(i->tag, bitid);
- swf_SetJPEGBits2(i->tag,sizex,sizey,mem,config_jpegquality);
- //swf_SetLosslessImage(i->tag,mem,sizex,sizey);
- }
+ /*RGBA* pal = (RGBA*)rfx_alloc(sizeof(RGBA)*num_colors);
+ swf_ImageGetNumberOfPaletteEntries(mem,sizex,sizey,pal);
+ int t;
+ for(t=0;t<num_colors;t++) {
+ printf("%02x%02x%02x%02x ",
+ pal[t].r, pal[t].g, pal[t].b, pal[t].a);
+ if((t&7)==7)
+ printf("\n");
}
-
+ printf("\n");*/
+
+ i->tag = swf_AddImage(i->tag, bitid, mem, sizex, sizey, config_jpegquality);
+
if(newpic)
free(newpic);
m.ty = (int)(matrix->ty*20);
/* shape */
- int myshapeid = ++i->currentswfid;
+ int myshapeid = getNewID(obj);
i->tag = swf_InsertTag(i->tag,ST_DEFINESHAPE);
SHAPE*shape;
swf_ShapeNew(&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);
+ swf_ObjectPlace(i->tag,myshapeid,/*depth*/++i->depth,&i->page_matrix,&cxform2,NULL);
}
void swf_startclip(gfxdevice_t*dev, gfxline_t*line)
i->clippos --;
}
- int myshapeid = ++i->currentswfid;
+ int myshapeid = getNewID(obj);
i->tag = swf_InsertTag(i->tag,ST_DEFINESHAPE);
RGBA col;
memset(&col, 0, sizeof(RGBA));
i->tag = swf_InsertTag(i->tag,ST_PLACEOBJECT2);
i->cliptags[i->clippos] = i->tag;
i->clipshapes[i->clippos] = myshapeid;
- i->clipdepths[i->clippos] = i->depth++;
+ i->clipdepths[i->clippos] = ++i->depth;
i->clippos++;
}
return;
}
i->clippos--;
- swf_ObjectPlaceClip(i->cliptags[i->clippos],i->clipshapes[i->clippos],i->clipdepths[i->clippos],&i->page_matrix,NULL,NULL,i->depth++);
+ /*swf_ObjectPlaceClip(i->cliptags[i->clippos],i->clipshapes[i->clippos],i->clipdepths[i->clippos],&i->page_matrix,NULL,NULL,
+ / * clip to depth: * / i->depth <= i->clipdepths[i->clippos]? i->depth : i->depth - 1);
+ i->depth ++;*/
+ swf_ObjectPlaceClip(i->cliptags[i->clippos],i->clipshapes[i->clippos],i->clipdepths[i->clippos],&i->page_matrix,NULL,NULL,i->depth);
}
int swf_setparameter(gfxdevice_t*dev, const char*key, const char*value)
{
drawgfxline(obj, line);
msg("<trace> end of swf_fill (shapeid=%d)", i->shapeid);
}
-void swf_fillgradient(gfxdevice_t*dev, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix)
+void swf_fillgradient(gfxdevice_t*dev, gfxline_t*line, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix)
{
msg("<error> Gradient filling not implemented yet");
}