From 483f59d3a55720c8c140aef863f4d34a0d90cca8 Mon Sep 17 00:00:00 2001 From: scuri Date: Wed, 16 Jun 2010 21:09:54 +0000 Subject: *** empty log message *** --- src/cd_image.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'src/cd_image.c') 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); } -- cgit v1.2.3