diff options
author | scuri <scuri> | 2010-06-16 21:09:54 +0000 |
---|---|---|
committer | scuri <scuri> | 2010-06-16 21:09:54 +0000 |
commit | 483f59d3a55720c8c140aef863f4d34a0d90cca8 (patch) | |
tree | 914494291b1870c2b50e7c252c156c91133e9a62 /src/cd_image.c | |
parent | 72857b1207600b10bd73e9b1fee479438aae3ac9 (diff) |
*** empty log message ***
Diffstat (limited to 'src/cd_image.c')
-rw-r--r-- | src/cd_image.c | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/src/cd_image.c b/src/cd_image.c index 002d288..df79af6 100644 --- a/src/cd_image.c +++ b/src/cd_image.c @@ -86,26 +86,9 @@ void cdCanvasPutImageRectRGB(cdCanvas* canvas, int iw, int ih, const unsigned ch if (canvas->invert_yaxis) y = _cdInvertYAxis(canvas, y); - if (canvas->bpp <= 8) - { - int height = ymax-ymin+1; - unsigned char* map = (unsigned char*)malloc(iw * height); - int pal_size = 1L << canvas->bpp; - long colors[256]; - - if (!map) - return; - - if (pal_size == 2) /* probably a laser printer, use a gray image for better results */ - cdRGB2Gray(iw, height, r+ymin*iw, g+ymin*iw, b+ymin*iw, map, colors); - else - cdRGB2Map(iw, height, r+ymin*iw, g+ymin*iw, b+ymin*iw, map, pal_size, colors); - - canvas->cxPutImageRectMap(canvas->ctxcanvas, iw, height, map, colors, x, y, w, h, xmin, xmax, 0, height-1); - - free(map); - } - else + if (canvas->cxPutImageRectMap && (canvas->bpp <= 8 || !canvas->cxPutImageRectRGB)) + cdSimPutImageRectRGB(canvas, iw, ih, r, g, b, x, y, w, h, xmin, xmax, ymin, ymax); + else if (canvas->cxPutImageRectRGB) canvas->cxPutImageRectRGB(canvas->ctxcanvas, iw, ih, r, g, b, x, y, w, h, xmin, xmax, ymin, ymax); } @@ -142,6 +125,11 @@ void cdCanvasPutImageRectRGBA(cdCanvas* canvas, int iw, int ih, const unsigned c { if (canvas->cxGetImageRGB) cdSimPutImageRectRGBA(canvas, iw, ih, r, g, b, a, x, y, w, h, xmin, xmax, ymin, ymax); + else if (!canvas->cxPutImageRectRGB) + { + if (canvas->cxPutImageRectMap) + cdSimPutImageRectRGB(canvas, iw, ih, r, g, b, x, y, w, h, xmin, xmax, ymin, ymax); + } else canvas->cxPutImageRectRGB(canvas->ctxcanvas, iw, ih, r, g, b, x, y, w, h, xmin, xmax, ymin, ymax); } |