*/
#include <stdio.h>
+#include <cups/raster.h>
unsigned int dither1[16][16] = {
{0,128,32,160,8,136,40,168,2,130,34,162,10,138,42,170},
{15,7,13,5}
};
-
-unsigned char *convertBitsNoop(unsigned char *src, unsigned char *dst,
- unsigned int x, unsigned int y, unsigned int cupsNumColors)
+unsigned char *convertbits(unsigned char *src, unsigned char *dst,
+ unsigned int x, unsigned int y, unsigned int cupsNumColors, unsigned int bitspercolor)
{
- return src;
-}
-
-unsigned char *convert8to1(unsigned char *src, unsigned char *dst,
- unsigned int x, unsigned int y, unsigned int cupsNumColors)
-{
- unsigned char c = 0;
/* assumed that max number of colors is 4 */
- for (unsigned int i = 0;i < cupsNumColors; i++) {
- c <<= 1;
- /* ordered dithering */
- if (src[i] > dither1[y & 0xf][x & 0xf]) {
- c |= 0x1;
- }
- }
- *dst = c;
- return dst;
-}
-
-unsigned char *convert8to2(unsigned char *src, unsigned char *dst,
- unsigned int x, unsigned int y, unsigned int cupsNumColors)
-{
unsigned char c = 0;
- /* assumed that max number of colors is 4 */
- for (unsigned int i = 0;i < cupsNumColors;i++) {
- unsigned int d;
-
- c <<= 2;
- /* ordered dithering */
- d = src[i] + dither2[y & 0x7][x & 0x7];
- if (d > 255) d = 255;
- c |= d >> 6;
- }
- *dst = c;
- return dst;
-}
-
-unsigned char *convert8to4(unsigned char *src, unsigned char *dst,
- unsigned int x, unsigned int y, unsigned int cupsNumColors)
-{
- unsigned short c = 0;
-
- /* assumed that max number of colors is 4 */
- for (unsigned int i = 0;i < cupsNumColors;i++) {
- unsigned int d;
-
- c <<= 4;
- /* ordered dithering */
- d = src[i] + dither4[y & 0x3][x & 0x3];
- if (d > 255) d = 255;
- c |= d >> 4;
- }
- if (cupsNumColors < 3) {
- dst[0] = c;
- } else {
- dst[0] = c >> 8;
- dst[1] = c;
- }
- return dst;
-}
-
-unsigned char *convert8to16(unsigned char *src, unsigned char *dst,
- unsigned int x, unsigned int y, unsigned int cupsNumColors)
-{
- /* assumed that max number of colors is 4 */
- for (unsigned int i = 0;i < cupsNumColors;i++) {
- dst[i*2] = src[i];
- dst[i*2+1] = src[i];
- }
- return dst;
-}
-
-void writePixel1(unsigned char *dst,
- unsigned int plane, unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors)
-{
- switch (cupsNumColors) {
+ unsigned short s = 0;
+ switch (bitspercolor) {
case 1:
- {
- unsigned int bo = pixeli & 0x7;
- if ((pixeli & 7) == 0) dst[pixeli/8] = 0;
- dst[pixeli/8] |= *pixelBuf << (7-bo);
- }
- break;
- case 6:
- dst[pixeli] = *pixelBuf;
- break;
- case 3:
+ if (cupsNumColors != 1) {
+ for (unsigned int i = 0;i < cupsNumColors; i++) {
+ c <<= 1;
+ /* ordered dithering */
+ if (src[i] > dither1[y & 0xf][x & 0xf]) {
+ c |= 0x1;
+ }
+ }
+ *dst = c;
+ }
+ else {
+ return src; /*Do not convert bits if both bitspercolor and numcolors are 1*/
+ }
+ break;
+ case 2:
+ for (unsigned int i = 0;i < cupsNumColors;i++) {
+ unsigned int d;
+ c <<= 2;
+ /* ordered dithering */
+ d = src[i] + dither2[y & 0x7][x & 0x7];
+ if (d > 255) d = 255;
+ c |= d >> 6;
+ }
+ *dst = c;
+ break;
case 4:
+ for (unsigned int i = 0;i < cupsNumColors;i++) {
+ unsigned int d;
+ s <<= 4;
+ /* ordered dithering */
+ d = src[i] + dither4[y & 0x3][x & 0x3];
+ if (d > 255) d = 255;
+ s |= d >> 4;
+ }
+ if (cupsNumColors < 3) {
+ dst[0] = s;
+ } else {
+ dst[0] = s >> 8;
+ dst[1] = s;
+ }
+ break;
+ case 16:
+ for (unsigned int i = 0;i < cupsNumColors;i++) {
+ dst[i*2] = src[i];
+ dst[i*2+1] = src[i];
+ }
+ break;
+ case 8:
+ case 0:
default:
- {
- unsigned int qo = (pixeli & 0x1)*4;
- if ((pixeli & 1) == 0) dst[pixeli/2] = 0;
- dst[pixeli/2] |= *pixelBuf << (4-qo);
- }
- break;
+ return src;
+ break;
}
+ return dst;
}
-void writePlanePixel1(unsigned char *dst, unsigned int plane,
- unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors)
-{
- unsigned int bo = pixeli & 0x7;
- unsigned char so = cupsNumColors - plane - 1;
- if ((pixeli & 7) == 0) dst[pixeli/8] = 0;
- dst[pixeli/8] |= ((*pixelBuf >> so) & 1) << (7-bo);
-}
-
-void writePixel2(unsigned char *dst, unsigned int plane,
- unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors)
+void writepixel(unsigned char *dst,
+ unsigned int plane, unsigned int pixeli, unsigned char *pixelBuf,
+ unsigned int cupsNumColors, unsigned int bitspercolor, cups_order_t colororder)
{
- switch (cupsNumColors) {
- case 1:
- {
- unsigned int bo = (pixeli & 0x3)*2;
- if ((pixeli & 3) == 0) dst[pixeli/4] = 0;
- dst[pixeli/4] |= *pixelBuf << (6-bo);
- }
- break;
- case 3:
- case 4:
+ unsigned int bo;
+ unsigned char so;
+ switch (colororder) {
+ case CUPS_ORDER_PLANAR:
+ case CUPS_ORDER_BANDED:
+ if (cupsNumColors != 1) {
+ switch (bitspercolor) {
+ case 1:
+ bo = pixeli & 0x7;
+ so = cupsNumColors - plane - 1;
+ if ((pixeli & 7) == 0) dst[pixeli/8] = 0;
+ dst[pixeli/8] |= ((*pixelBuf >> so) & 1) << (7-bo);
+ break;
+ case 2:
+ bo = (pixeli & 0x3)*2;
+ so = (cupsNumColors - plane - 1)*2;
+ if ((pixeli & 3) == 0) dst[pixeli/4] = 0;
+ dst[pixeli/4] |= ((*pixelBuf >> so) & 3) << (6-bo);
+ break;
+ case 4:
+ {
+ unsigned short c = (pixelBuf[0] << 8) | pixelBuf[1];
+ bo = (pixeli & 0x1)*4;
+ so = (cupsNumColors - plane - 1)*4;
+ if ((pixeli & 1) == 0) dst[pixeli/2] = 0;
+ dst[pixeli/2] |= ((c >> so) & 0xf) << (4-bo);
+ }
+ break;
+ case 8:
+ dst[pixeli] = pixelBuf[plane];
+ break;
+ case 16:
+ default:
+ dst[pixeli*2] = pixelBuf[plane*2];
+ dst[pixeli*2+1] = pixelBuf[plane*2+1];
+ break;
+ }
+ break;
+ }
+ case CUPS_ORDER_CHUNKED:
default:
- dst[pixeli] = *pixelBuf;
- break;
- }
-}
-
-void writePlanePixel2(unsigned char *dst, unsigned int plane,
- unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors)
-{
- unsigned int bo = (pixeli & 0x3)*2;
- unsigned char so = (cupsNumColors - plane - 1)*2;
- if ((pixeli & 3) == 0) dst[pixeli/4] = 0;
- dst[pixeli/4] |= ((*pixelBuf >> so) & 3) << (6-bo);
-}
-
-void writePixel4(unsigned char *dst, unsigned int plane,
- unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors)
-{
- switch (cupsNumColors) {
- case 1:
+ switch (bitspercolor)
{
- unsigned int bo = (pixeli & 0x1)*4;
- if ((pixeli & 1) == 0) dst[pixeli/2] = 0;
- dst[pixeli/2] |= *pixelBuf << (4-bo);
+ case 1:
+ switch (cupsNumColors) {
+ case 1:
+ {
+ unsigned int bo = pixeli & 0x7;
+ if ((pixeli & 7) == 0) dst[pixeli/8] = 0;
+ dst[pixeli/8] |= *pixelBuf << (7-bo);
+ }
+ break;
+ case 6:
+ dst[pixeli] = *pixelBuf;
+ break;
+ case 3:
+ case 4:
+ default:
+ {
+ unsigned int qo = (pixeli & 0x1)*4;
+ if ((pixeli & 1) == 0) dst[pixeli/2] = 0;
+ dst[pixeli/2] |= *pixelBuf << (4-qo);
+ }
+ break;
+ }
+ break;
+ case 2:
+ switch (cupsNumColors) {
+ case 1:
+ {
+ unsigned int bo = (pixeli & 0x3)*2;
+ if ((pixeli & 3) == 0) dst[pixeli/4] = 0;
+ dst[pixeli/4] |= *pixelBuf << (6-bo);
+ }
+ break;
+ case 3:
+ case 4:
+ default:
+ dst[pixeli] = *pixelBuf;
+ break;
+ }
+ break;
+ case 4:
+ switch (cupsNumColors) {
+ case 1:
+ {
+ unsigned int bo = (pixeli & 0x1)*4;
+ if ((pixeli & 1) == 0) dst[pixeli/2] = 0;
+ dst[pixeli/2] |= *pixelBuf << (4-bo);
+ }
+ break;
+ case 3:
+ case 4:
+ default:
+ dst[pixeli*2] = pixelBuf[0];
+ dst[pixeli*2+1] = pixelBuf[1];
+ break;
+ }
+ break;
+ case 8:
+ {
+ unsigned char *dp = dst + pixeli*cupsNumColors;
+ for (unsigned int i = 0;i < cupsNumColors;i++) {
+ dp[i] = pixelBuf[i];
+ }
+ }
+ break;
+ case 16:
+ default:
+ {
+ unsigned char *dp = dst + pixeli*cupsNumColors*2;
+ for (unsigned int i = 0;i < cupsNumColors*2;i++) {
+ dp[i] = pixelBuf[i];
+ }
+ }
+ break;
}
- break;
- case 3:
- case 4:
- default:
- dst[pixeli*2] = pixelBuf[0];
- dst[pixeli*2+1] = pixelBuf[1];
- break;
- }
-}
-
-void writePlanePixel4(unsigned char *dst, unsigned int plane,
- unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors)
-{
- unsigned short c = (pixelBuf[0] << 8) | pixelBuf[1];
- unsigned int bo = (pixeli & 0x1)*4;
- unsigned char so = (cupsNumColors - plane - 1)*4;
- if ((pixeli & 1) == 0) dst[pixeli/2] = 0;
- dst[pixeli/2] |= ((c >> so) & 0xf) << (4-bo);
-}
-
-void writePixel8(unsigned char *dst, unsigned int plane,
- unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors)
-{
- unsigned char *dp = dst + pixeli*cupsNumColors;
- for (unsigned int i = 0;i < cupsNumColors;i++) {
- dp[i] = pixelBuf[i];
- }
-}
-
-void writePlanePixel8(unsigned char *dst, unsigned int plane,
- unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors)
-{
- dst[pixeli] = pixelBuf[plane];
-}
-
-void writePixel16(unsigned char *dst, unsigned int plane,
- unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors)
-{
- unsigned char *dp = dst + pixeli*cupsNumColors*2;
- for (unsigned int i = 0;i < cupsNumColors*2;i++) {
- dp[i] = pixelBuf[i];
+ break;
}
}
-
-void writePlanePixel16(unsigned char *dst, unsigned int plane,
- unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors)
-{
- dst[pixeli*2] = pixelBuf[plane*2];
- dst[pixeli*2+1] = pixelBuf[plane*2+1];
-}
extern "C" {
# endif /* __cplusplus */
-/* Common routines for accessing the colord CMS framework */
-
-unsigned char *convertBitsNoop (unsigned char *src, unsigned char *dst,
- unsigned int x, unsigned int y, unsigned int cupsNumColors);
-unsigned char *convert8to1 (unsigned char *src, unsigned char *dst,
- unsigned int x, unsigned int y, unsigned int cupsNumColors);
-unsigned char *convert8to2 (unsigned char *src, unsigned char *dst,
- unsigned int x, unsigned int y, unsigned int cupsNumColors);
-unsigned char *convert8to4 (unsigned char *src, unsigned char *dst,
- unsigned int x, unsigned int y, unsigned int cupsNumColors);
-unsigned char *convert8to16 (unsigned char *src, unsigned char *dst,
- unsigned int x, unsigned int y, unsigned int cupsNumColors);
-void writePixel1 (unsigned char *dst, unsigned int plane,
- unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors);
-void writePlanePixel1 (unsigned char *dst, unsigned int plane,
- unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors);
-void writePixel2 (unsigned char *dst, unsigned int plane,
- unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors);
-void writePlanePixel2 (unsigned char *dst, unsigned int plane,
- unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors);
-void writePixel4 (unsigned char *dst, unsigned int plane,
- unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors);
-void writePlanePixel4 (unsigned char *dst, unsigned int plane,
- unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors);
-void writePixel8 (unsigned char *dst, unsigned int plane,
- unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors);
-void writePlanePixel8 (unsigned char *dst, unsigned int plane,
- unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors);
-void writePixel16 (unsigned char *dst, unsigned int plane,
- unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors);
-void writePlanePixel16 (unsigned char *dst, unsigned int plane,
- unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors);
+#include <cups/raster.h>
+unsigned char *convertbits (unsigned char *src, unsigned char *dst,
+ unsigned int x, unsigned int y, unsigned int cupsNumColors,unsigned int m);
+void writepixel (unsigned char *dst, unsigned int plane, unsigned int pixeli, unsigned char *pixelBuf,
+ unsigned int cupsNumColors, unsigned int bits, cups_order_t colororder);
# ifdef __cplusplus
}
# endif /* __cplusplus */
namespace {
typedef unsigned char *(*ConvertCSpace)(unsigned char *src, unsigned char *dst, unsigned int row, unsigned int pixels);
- typedef void (*WritePixelFunc)(unsigned char *dst, unsigned int plane, unsigned int pixeli, unsigned char *pixelBuf, unsigned int cupsNumColors);
- typedef unsigned char *(*ConvertBitsFunc)(unsigned char *src, unsigned char *dst, unsigned int x, unsigned int y, unsigned int cupsNumColors);
ConvertCSpace convertcspace;
- ConvertBitsFunc convertBits;
- WritePixelFunc writePixel;
int pwgraster = 0;
int numcolors = 0;
cups_page_header2_t header;
unsigned char pixelBuf2[MAX_BYTES_PER_PIXEL];
unsigned char *pb;
pb = convertcspace(src + i*numcolors, pixelBuf1, row, 1);
- pb = convertBits(pb, pixelBuf2, i, row, header.cupsNumColors);
- writePixel(dst, plane, i, pb, header.cupsNumColors);
+ pb = convertbits(pb, pixelBuf2, i, row, header.cupsNumColors, header.cupsBitsPerColor);
+ writepixel(dst, plane, i, pb, header.cupsNumColors, header.cupsBitsPerColor, header.cupsColorOrder);
}
}
return dst;
else if (colorspace == "/DeviceGray") convertcspace = GraytoRGBLine;
break;
}
-
- switch (header.cupsBitsPerColor) {
- case 2:
- convertBits = convert8to2;
- break;
- case 4:
- convertBits = convert8to4;
- break;
- case 16:
- convertBits = convert8to16;
- break;
- case 1:
- if (header.cupsNumColors == 1) {
- convertBits = convertBitsNoop;
- } else {
- convertBits = convert8to1;
- }
- break;
- case 8:
- default:
- convertBits = convertBitsNoop;
- break;
- }
-
- switch (header.cupsBitsPerColor) {
- case 2:
- if (header.cupsColorOrder == CUPS_ORDER_CHUNKED
- || header.cupsNumColors == 1) {
- writePixel = writePixel2;
- } else {
- writePixel = writePlanePixel2;
- }
- break;
- case 4:
- if (header.cupsColorOrder == CUPS_ORDER_CHUNKED
- || header.cupsNumColors == 1) {
- writePixel = writePixel4;
- } else {
- writePixel = writePlanePixel4;
- }
- break;
- case 16:
- if (header.cupsColorOrder == CUPS_ORDER_CHUNKED
- || header.cupsNumColors == 1) {
- writePixel = writePixel16;
- } else {
- writePixel = writePlanePixel16;
- }
- break;
- case 1:
- if (header.cupsColorOrder == CUPS_ORDER_CHUNKED
- || header.cupsNumColors == 1) {
- writePixel = writePixel1;
- } else {
- writePixel = writePlanePixel1;
- }
- break;
- case 8:
- default:
- if (header.cupsColorOrder == CUPS_ORDER_CHUNKED
- || header.cupsNumColors == 1) {
- writePixel = writePixel8;
- } else {
- writePixel = writePlanePixel8;
- }
- break;
- }
}
static void outPage(cups_raster_t *raster, QPDFObjectHandle page, int pgno) {
convertcspace = convertcspaceNoop;
- convertBits = convertBitsNoop;
if (page.getKey("/Rotate").isInteger())
rotate = page.getKey("/Rotate").getIntValueAsInt();
unsigned int pixels, unsigned int size);
typedef unsigned char *(*ConvertCSpaceFunc)(unsigned char *src,
unsigned char *pixelBuf, unsigned int x, unsigned int y);
- typedef unsigned char *(*ConvertBitsFunc)(unsigned char *src,
- unsigned char *dst, unsigned int x, unsigned int y, unsigned int numcolors);
- typedef void (*WritePixelFunc)(unsigned char *dst,
- unsigned int plane, unsigned int pixeli, unsigned char *pixelBuf, unsigned int numcolors);
int exitCode = 0;
int pwgraster = 0;
unsigned int bitmapoffset[2];
unsigned int popplerBitsPerPixel;
unsigned int popplerNumColors;
+ unsigned int bitspercolor;
/* image swapping */
bool swap_image_x = false;
bool swap_image_y = false;
ConvertLineFunc convertLineOdd;
ConvertLineFunc convertLineEven;
ConvertCSpaceFunc convertCSpace;
- ConvertBitsFunc convertBits;
- WritePixelFunc writePixel;
unsigned int nplanes;
unsigned int nbands;
unsigned int bytesPerLine; /* number of bytes per line */
unsigned char *pb;
pb = convertCSpace(src+i*popplerNumColors,pixelBuf1,i,row);
- pb = convertBits(pb,pixelBuf2,i,row,header.cupsNumColors);
- writePixel(dst,0,i,pb,header.cupsNumColors);
+ pb = convertbits(pb,pixelBuf2,i,row, header.cupsNumColors, bitspercolor);
+ writepixel(dst,0,i,pb, header.cupsNumColors, header.cupsBitsPerColor, header.cupsColorOrder);
}
return dst;
}
unsigned char *pb;
pb = convertCSpace(src+(pixels-i-1)*popplerNumColors,pixelBuf1,i,row);
- pb = convertBits(pb,pixelBuf2,i,row,header.cupsNumColors);
- writePixel(dst,0,i,pb,header.cupsNumColors);
+ pb = convertbits(pb,pixelBuf2,i,row, header.cupsNumColors, bitspercolor);
+ writepixel(dst,0,i,pb, header.cupsNumColors, header.cupsBitsPerColor, header.cupsColorOrder);
}
return dst;
}
unsigned char *pb;
pb = convertCSpace(src+i*popplerNumColors,pixelBuf1,i,row);
- pb = convertBits(pb,pixelBuf2,i,row,header.cupsNumColors);
- writePixel(dst,plane,i,pb,header.cupsNumColors);
+ pb = convertbits(pb,pixelBuf2,i,row, header.cupsNumColors, bitspercolor);
+ writepixel(dst,plane,i,pb, header.cupsNumColors, header.cupsBitsPerColor, header.cupsColorOrder);
}
return dst;
}
unsigned char *pb;
pb = convertCSpace(src+(pixels-i-1)*popplerNumColors,pixelBuf1,i,row);
- pb = convertBits(pb,pixelBuf2,i,row,header.cupsNumColors);
- writePixel(dst,plane,i,pb,header.cupsNumColors);
+ pb = convertbits(pb,pixelBuf2,i,row, header.cupsNumColors, bitspercolor);
+ writepixel(dst,plane,i,pb, header.cupsNumColors, header.cupsBitsPerColor, header.cupsColorOrder);
}
return dst;
}
bytes = header.cupsBitsPerColor/8;
break;
}
- convertBits = convertBitsNoop; /* convert bits in convertCSpace */
+ bitspercolor = 0; /* convert bits in convertCSpace */
if (popplerColorProfile == NULL) {
popplerColorProfile = cmsCreate_sRGBProfile();
}
exit(1);
break;
}
- /* select convertBits function */
- switch (header.cupsBitsPerColor) {
- case 2:
- convertBits = convert8to2;
- break;
- case 4:
- convertBits = convert8to4;
- break;
- case 16:
- convertBits = convert8to16;
- break;
- case 1:
- if (header.cupsNumColors == 1
- || header.cupsColorSpace == CUPS_CSPACE_KCMYcm) {
- convertBits = convertBitsNoop;
- } else {
- convertBits = convert8to1;
- }
- break;
- case 8:
- default:
- convertBits = convertBitsNoop;
- break;
- }
- }
- /* select writePixel function */
- switch (header.cupsBitsPerColor) {
- case 2:
- if (header.cupsColorOrder == CUPS_ORDER_CHUNKED
- || header.cupsNumColors == 1) {
- writePixel = writePixel2;
- } else {
- writePixel = writePlanePixel2;
- }
- break;
- case 4:
- if (header.cupsColorOrder == CUPS_ORDER_CHUNKED
- || header.cupsNumColors == 1) {
- writePixel = writePixel4;
- } else {
- writePixel = writePlanePixel4;
- }
- break;
- case 16:
- if (header.cupsColorOrder == CUPS_ORDER_CHUNKED
- || header.cupsNumColors == 1) {
- writePixel = writePixel16;
- } else {
- writePixel = writePlanePixel16;
- }
- break;
- case 1:
- if (header.cupsColorOrder == CUPS_ORDER_CHUNKED
- || header.cupsNumColors == 1) {
- writePixel = writePixel1;
- } else {
- writePixel = writePlanePixel1;
- }
- break;
- case 8:
- default:
- if (header.cupsColorOrder == CUPS_ORDER_CHUNKED
- || header.cupsNumColors == 1) {
- writePixel = writePixel8;
- } else {
- writePixel = writePlanePixel8;
- }
- break;
}
+
+ if (header.cupsBitsPerColor == 1 &&
+ (header.cupsNumColors == 1 ||
+ header.cupsColorSpace == CUPS_CSPACE_KCMYcm ))
+ bitspercolor = 0; /*Do not convertbits*/
+ else
+ bitspercolor = header.cupsBitsPerColor;
+
}
static unsigned char *onebitpixel(unsigned char *src, unsigned char *dst, unsigned int width, unsigned int height){