diff options
Diffstat (limited to 'src/sim')
-rw-r--r-- | src/sim/sim_primitives.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/sim/sim_primitives.c b/src/sim/sim_primitives.c index 4b3ebf3..29fc6af 100644 --- a/src/sim/sim_primitives.c +++ b/src/sim/sim_primitives.c @@ -1316,6 +1316,29 @@ void cdSimPutImageRectRGBA(cdCanvas* canvas, int iw, int ih, const unsigned char free(fy); } +void cdSimPutImageRectRGB(cdCanvas* canvas, int iw, int ih, const unsigned char *r, const unsigned char *g, const unsigned char *b, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax) +{ + int height = ymax-ymin+1; + unsigned char* map; + int pal_size = 1L << canvas->bpp; + long colors[256]; + (void)ih; + + map = (unsigned char*)malloc(iw * height); + 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); +} + + /************************************************************************/ #include "cd_truetype.h" |