typedef struct _internal_result {
gfximage_t img;
struct _internal_result*next;
+ char palette;
} internal_result_t;
typedef struct _clipbuffer {
int ymin, ymax;
int fillwhite;
+ char palette;
+
RGBA* img;
clipbuffer_t*clipbuf;
gfxmatrix_t*m = info->matrix;
gfximage_t*b = info->image;
- if(!b->width || !b->height) {
+ if(!b || !b->width || !b->height) {
gfxcolor_t red = {255,255,0,0};
fill_line_solid(line, z, y, x1, x2, red);
return;
} else if(!strcmp(key, "fillwhite")) {
i->fillwhite = atoi(value);
return 1;
+ } else if(!strcmp(key, "palette")) {
+ i->palette = atoi(value);
+ return 1;
}
return 0;
}
} else if(line->type == gfx_lineTo) {
double x1=x*i->zoom,y1=y*i->zoom;
double x3=line->x*i->zoom,y3=line->y*i->zoom;
- add_solidline(dev, x1, y1, x3, y3, width * i->multiply);
+ add_solidline(dev, x1, y1, x3, y3, width * i->zoom);
fill_solid(dev, color);
} else if(line->type == gfx_splineTo) {
int t,parts;
double nx = (double)(t*t*x3 + 2*t*(parts-t)*x2 + (parts-t)*(parts-t)*x1)/(double)(parts*parts);
double ny = (double)(t*t*y3 + 2*t*(parts-t)*y2 + (parts-t)*(parts-t)*y1)/(double)(parts*parts);
- add_solidline(dev, xx, yy, nx, ny, width * i->multiply);
+ add_solidline(dev, xx, yy, nx, ny, width * i->zoom);
fill_solid(dev, color);
xx = nx;
yy = ny;
}
while(i->next) {
sprintf(filenamebuf, "%s.%d.png", origname, nr);
- writePNG(filename, (unsigned char*)i->img.data, i->img.width, i->img.height);
+ if(!i->palette) {
+ writePNG(filename, (unsigned char*)i->img.data, i->img.width, i->img.height);
+ } else {
+ writePalettePNG(filename, (unsigned char*)i->img.data, i->img.width, i->img.height);
+ }
nr++;
}
free(origname);
} else {
- writePNG(filename, (unsigned char*)i->img.data, i->img.width, i->img.height);
+ if(!i->palette) {
+ writePNG(filename, (unsigned char*)i->img.data, i->img.width, i->img.height);
+ } else {
+ writePalettePNG(filename, (unsigned char*)i->img.data, i->img.width, i->img.height);
+ }
}
return 1;
}
}
endclip(dev, 1);
+ int unclosed = 0;
while(i->clipbuf) {
- fprintf(stderr, "Warning: unclosed clip while processing endpage()\n");
endclip(dev, 1);
+ unclosed++;
+ }
+
+ if(unclosed) {
+ fprintf(stderr, "Warning: %d unclosed clip(s) while processing endpage()\n", unclosed);
}
internal_result_t*ir= (internal_result_t*)rfx_calloc(sizeof(internal_result_t));
+ ir->palette = i->palette;
int y,x;
dev->finish = render_finish;
}
+
+gfxdevice_t* gfxdevice_render_new()
+{
+ gfxdevice_t* d = (gfxdevice_t*)malloc(sizeof(gfxdevice_t));
+ gfxdevice_render_init(d);
+ return d;
+}