Commit c5613ab5 authored by Albert Astals Cid's avatar Albert Astals Cid

* poppler/SplashOutputDev.cc:

        * qt/poppler-private.h:
        * qt4/src/poppler-private.h:
        * splash/Splash.cc:
        * splash/SplashBitmap.cc:
        * splash/SplashTypes.h: Rename splashModeRGBX8 to splashModeXBGR8 and
        hopefully fix qt frontends image generation
parent 6479ce22
2007-04-29 Albert Astals Cid <aacid@kde.org>
* poppler/SplashOutputDev.cc:
* qt/poppler-private.h:
* qt4/src/poppler-private.h:
* splash/Splash.cc:
* splash/SplashBitmap.cc:
* splash/SplashTypes.h: Rename splashModeRGBX8 to splashModeXBGR8 and
hopefully fix qt frontends image generation
2007-04-28 Albert Astals Cid <aacid@kde.org>
* qt4/src/Makefile.am:
......
......@@ -244,7 +244,7 @@ static void splashOutBlendHue(SplashColorPtr src, SplashColorPtr dest,
case splashModeMono8:
blend[0] = dest[0];
break;
case splashModeRGBX8:
case splashModeXBGR8:
src[3] = 255;
case splashModeRGB8:
case splashModeBGR8:
......@@ -285,7 +285,7 @@ static void splashOutBlendSaturation(SplashColorPtr src, SplashColorPtr dest,
case splashModeMono8:
blend[0] = dest[0];
break;
case splashModeRGBX8:
case splashModeXBGR8:
src[3] = 255;
case splashModeRGB8:
case splashModeBGR8:
......@@ -325,7 +325,7 @@ static void splashOutBlendColor(SplashColorPtr src, SplashColorPtr dest,
case splashModeMono8:
blend[0] = dest[0];
break;
case splashModeRGBX8:
case splashModeXBGR8:
src[3] = 255;
case splashModeRGB8:
case splashModeBGR8:
......@@ -366,7 +366,7 @@ static void splashOutBlendLuminosity(SplashColorPtr src, SplashColorPtr dest,
case splashModeMono8:
blend[0] = dest[0];
break;
case splashModeRGBX8:
case splashModeXBGR8:
src[3] = 255;
case splashModeRGB8:
case splashModeBGR8:
......@@ -722,7 +722,7 @@ void SplashOutputDev::startPage(int pageNum, GfxState *state) {
case splashModeMono8:
color[0] = 0;
break;
case splashModeRGBX8:
case splashModeXBGR8:
color[3] = 255;
case splashModeRGB8:
case splashModeBGR8:
......@@ -900,7 +900,7 @@ SplashPattern *SplashOutputDev::getColor(GfxGray gray, GfxRGB *rgb) {
color[0] = colToByte(gray);
pattern = new SplashSolidColor(color);
break;
case splashModeRGBX8:
case splashModeXBGR8:
color[3] = 255;
case splashModeRGB8:
case splashModeBGR8:
......@@ -1720,7 +1720,6 @@ GBool SplashOutputDev::imageSrc(void *data, SplashColorPtr colorLine,
*q++ = imgData->lookup[*p];
}
break;
case splashModeRGBX8:
case splashModeRGB8:
case splashModeBGR8:
for (x = 0, p = imgData->imgStr->getLine(), q = colorLine;
......@@ -1730,9 +1729,19 @@ GBool SplashOutputDev::imageSrc(void *data, SplashColorPtr colorLine,
*q++ = col[0];
*q++ = col[1];
*q++ = col[2];
if (imgData->colorMode == splashModeRGBX8) *q++ = 255;
}
break;
case splashModeXBGR8:
for (x = 0, p = imgData->imgStr->getLine(), q = colorLine;
x < imgData->width;
++x, ++p) {
col = &imgData->lookup[4 * *p];
*q++ = col[0];
*q++ = col[1];
*q++ = col[2];
*q++ = col[3];
}
break;
#if SPLASH_CMYK
case splashModeCMYK8:
for (x = 0, p = imgData->imgStr->getLine(), q = colorLine;
......@@ -1758,7 +1767,7 @@ GBool SplashOutputDev::imageSrc(void *data, SplashColorPtr colorLine,
*q++ = colToByte(gray);
}
break;
case splashModeRGBX8:
case splashModeXBGR8:
case splashModeRGB8:
case splashModeBGR8:
for (x = 0, p = imgData->imgStr->getLine(), q = colorLine;
......@@ -1768,7 +1777,7 @@ GBool SplashOutputDev::imageSrc(void *data, SplashColorPtr colorLine,
*q++ = colToByte(rgb.r);
*q++ = colToByte(rgb.g);
*q++ = colToByte(rgb.b);
if (imgData->colorMode == splashModeRGBX8) *q++ = 255;
if (imgData->colorMode == splashModeXBGR8) *q++ = 255;
}
break;
#if SPLASH_CMYK
......@@ -1828,14 +1837,20 @@ GBool SplashOutputDev::alphaImageSrc(void *data, SplashColorPtr colorLine,
*q++ = imgData->lookup[*p];
*aq++ = alpha;
break;
case splashModeRGBX8:
case splashModeRGB8:
case splashModeBGR8:
col = &imgData->lookup[3 * *p];
*q++ = col[0];
*q++ = col[1];
*q++ = col[2];
if (imgData->colorMode == splashModeRGBX8) *q++ = 255;
*aq++ = alpha;
break;
case splashModeXBGR8:
col = &imgData->lookup[4 * *p];
*q++ = col[0];
*q++ = col[1];
*q++ = col[2];
*q++ = 255;
*aq++ = alpha;
break;
#if SPLASH_CMYK
......@@ -1857,14 +1872,14 @@ GBool SplashOutputDev::alphaImageSrc(void *data, SplashColorPtr colorLine,
*q++ = colToByte(gray);
*aq++ = alpha;
break;
case splashModeRGBX8:
case splashModeXBGR8:
case splashModeRGB8:
case splashModeBGR8:
imgData->colorMap->getRGB(p, &rgb);
*q++ = colToByte(rgb.r);
*q++ = colToByte(rgb.g);
*q++ = colToByte(rgb.b);
if (imgData->colorMode == splashModeRGBX8) *q++ = 255;
if (imgData->colorMode == splashModeXBGR8) *q++ = 255;
*aq++ = alpha;
break;
#if SPLASH_CMYK
......@@ -1936,7 +1951,6 @@ void SplashOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
imgData.lookup[i] = colToByte(gray);
}
break;
case splashModeRGBX8:
case splashModeRGB8:
case splashModeBGR8:
imgData.lookup = (SplashColorPtr)gmalloc(3 * n);
......@@ -1946,7 +1960,17 @@ void SplashOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
imgData.lookup[3*i] = colToByte(rgb.r);
imgData.lookup[3*i+1] = colToByte(rgb.g);
imgData.lookup[3*i+2] = colToByte(rgb.b);
if (colorMode == splashModeRGBX8) imgData.lookup[3*i+3] = 255;
}
break;
case splashModeXBGR8:
imgData.lookup = (SplashColorPtr)gmalloc(4 * n);
for (i = 0; i < n; ++i) {
pix = (Guchar)i;
colorMap->getRGB(&pix, &rgb);
imgData.lookup[4*i] = colToByte(rgb.r);
imgData.lookup[4*i+1] = colToByte(rgb.g);
imgData.lookup[4*i+2] = colToByte(rgb.b);
imgData.lookup[4*i+3] = 255;
}
break;
#if SPLASH_CMYK
......@@ -2027,14 +2051,20 @@ GBool SplashOutputDev::maskedImageSrc(void *data, SplashColorPtr colorLine,
*q++ = imgData->lookup[*p];
*aq++ = alpha;
break;
case splashModeRGBX8:
case splashModeRGB8:
case splashModeBGR8:
col = &imgData->lookup[3 * *p];
*q++ = col[0];
*q++ = col[1];
*q++ = col[2];
if (imgData->colorMode == splashModeRGBX8) *q++ = 255;
*aq++ = alpha;
break;
case splashModeXBGR8:
col = &imgData->lookup[4 * *p];
*q++ = col[0];
*q++ = col[1];
*q++ = col[2];
*q++ = 255;
*aq++ = alpha;
break;
#if SPLASH_CMYK
......@@ -2056,14 +2086,14 @@ GBool SplashOutputDev::maskedImageSrc(void *data, SplashColorPtr colorLine,
*q++ = colToByte(gray);
*aq++ = alpha;
break;
case splashModeRGBX8:
case splashModeXBGR8:
case splashModeRGB8:
case splashModeBGR8:
imgData->colorMap->getRGB(p, &rgb);
*q++ = colToByte(rgb.r);
*q++ = colToByte(rgb.g);
*q++ = colToByte(rgb.b);
if (imgData->colorMode == splashModeRGBX8) *q++ = 255;
if (imgData->colorMode == splashModeXBGR8) *q++ = 255;
*aq++ = alpha;
break;
#if SPLASH_CMYK
......@@ -2186,7 +2216,6 @@ void SplashOutputDev::drawMaskedImage(GfxState *state, Object *ref,
imgData.lookup[i] = colToByte(gray);
}
break;
case splashModeRGBX8:
case splashModeRGB8:
case splashModeBGR8:
imgData.lookup = (SplashColorPtr)gmalloc(3 * n);
......@@ -2196,7 +2225,17 @@ void SplashOutputDev::drawMaskedImage(GfxState *state, Object *ref,
imgData.lookup[3*i] = colToByte(rgb.r);
imgData.lookup[3*i+1] = colToByte(rgb.g);
imgData.lookup[3*i+2] = colToByte(rgb.b);
if (colorMode == splashModeRGBX8) imgData.lookup[3*i+2] = 255;
}
break;
case splashModeXBGR8:
imgData.lookup = (SplashColorPtr)gmalloc(4 * n);
for (i = 0; i < n; ++i) {
pix = (Guchar)i;
colorMap->getRGB(&pix, &rgb);
imgData.lookup[4*i] = colToByte(rgb.r);
imgData.lookup[4*i+1] = colToByte(rgb.g);
imgData.lookup[4*i+2] = colToByte(rgb.b);
imgData.lookup[4*i+3] = 255;
}
break;
#if SPLASH_CMYK
......@@ -2321,7 +2360,6 @@ void SplashOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref,
}
break;
case splashModeRGB8:
case splashModeRGBX8:
case splashModeBGR8:
imgData.lookup = (SplashColorPtr)gmalloc(3 * n);
for (i = 0; i < n; ++i) {
......@@ -2330,7 +2368,17 @@ void SplashOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref,
imgData.lookup[3*i] = colToByte(rgb.r);
imgData.lookup[3*i+1] = colToByte(rgb.g);
imgData.lookup[3*i+2] = colToByte(rgb.b);
if (colorMode == splashModeRGBX8) imgData.lookup[3*i+2] = 255;
}
break;
case splashModeXBGR8:
imgData.lookup = (SplashColorPtr)gmalloc(4 * n);
for (i = 0; i < n; ++i) {
pix = (Guchar)i;
colorMap->getRGB(&pix, &rgb);
imgData.lookup[4*i] = colToByte(rgb.r);
imgData.lookup[4*i+1] = colToByte(rgb.g);
imgData.lookup[4*i+2] = colToByte(rgb.b);
imgData.lookup[4*i+3] = 255;
}
break;
#if SPLASH_CMYK
......@@ -2461,7 +2509,7 @@ void SplashOutputDev::beginTransparencyGroup(GfxState *state, double *bbox,
case splashModeMono8:
color[0] = 0;
break;
case splashModeRGBX8:
case splashModeXBGR8:
color[3] = 255;
case splashModeRGB8:
case splashModeBGR8:
......@@ -2559,7 +2607,7 @@ void SplashOutputDev::setSoftMask(GfxState * /*state*/, double * /*bbox*/,
color[0] = colToByte(gray);
tSplash->compositeBackground(color);
break;
case splashModeRGBX8:
case splashModeXBGR8:
color[3] = 255;
case splashModeRGB8:
case splashModeBGR8:
......@@ -2601,7 +2649,7 @@ void SplashOutputDev::setSoftMask(GfxState * /*state*/, double * /*bbox*/,
case splashModeMono8:
lum = color[0] / 255.0;
break;
case splashModeRGBX8:
case splashModeXBGR8:
case splashModeRGB8:
case splashModeBGR8:
lum = (0.3 / 255.0) * color[0] +
......
......@@ -114,7 +114,7 @@ class DocumentData {
white[0] = 255;
white[1] = 255;
white[2] = 255;
m_outputDev = new SplashOutputDev(splashModeRGBX8, 4, gFalse, white);
m_outputDev = new SplashOutputDev(splashModeXBGR8, 4, gFalse, white);
m_outputDev->startDoc(doc.getXRef());
}
#endif
......
......@@ -163,7 +163,7 @@ namespace Poppler {
bgColor[1] = paperColor.green();
bgColor[2] = paperColor.blue();
GBool AA = m_hints & Document::TextAntialiasing ? gTrue : gFalse;
SplashOutputDev * splashOutputDev = new SplashOutputDev(splashModeRGBX8, 4, gFalse, bgColor, gTrue, AA);
SplashOutputDev * splashOutputDev = new SplashOutputDev(splashModeXBGR8, 4, gFalse, bgColor, gTrue, AA);
splashOutputDev->startDoc(doc->getXRef());
m_outputDev = splashOutputDev;
#endif
......
......@@ -84,6 +84,7 @@ SplashPipeResultColorCtrl Splash::pipeResultColorNoAlphaBlend[] = {
splashPipeResultColorNoAlphaBlendMono,
splashPipeResultColorNoAlphaBlendMono,
splashPipeResultColorNoAlphaBlendRGB,
splashPipeResultColorNoAlphaBlendRGB,
splashPipeResultColorNoAlphaBlendRGB
#if SPLASH_CMYK
,
......@@ -95,6 +96,7 @@ SplashPipeResultColorCtrl Splash::pipeResultColorAlphaNoBlend[] = {
splashPipeResultColorAlphaNoBlendMono,
splashPipeResultColorAlphaNoBlendMono,
splashPipeResultColorAlphaNoBlendRGB,
splashPipeResultColorNoAlphaBlendRGB,
splashPipeResultColorAlphaNoBlendRGB
#if SPLASH_CMYK
,
......@@ -106,6 +108,7 @@ SplashPipeResultColorCtrl Splash::pipeResultColorAlphaBlend[] = {
splashPipeResultColorAlphaBlendMono,
splashPipeResultColorAlphaBlendMono,
splashPipeResultColorAlphaBlendRGB,
splashPipeResultColorNoAlphaBlendRGB,
splashPipeResultColorAlphaBlendRGB
#if SPLASH_CMYK
,
......@@ -253,10 +256,10 @@ inline void Splash::pipeRun(SplashPipe *pipe) {
*pipe->destColorPtr++ = pipe->cSrc[1];
*pipe->destColorPtr++ = pipe->cSrc[2];
break;
case splashModeRGBX8:
*pipe->destColorPtr++ = pipe->cSrc[0];
*pipe->destColorPtr++ = pipe->cSrc[1];
case splashModeXBGR8:
*pipe->destColorPtr++ = pipe->cSrc[2];
*pipe->destColorPtr++ = pipe->cSrc[1];
*pipe->destColorPtr++ = pipe->cSrc[0];
*pipe->destColorPtr++ = 255;
break;
case splashModeBGR8:
......@@ -293,10 +296,10 @@ inline void Splash::pipeRun(SplashPipe *pipe) {
cDest[1] = pipe->destColorPtr[1];
cDest[2] = pipe->destColorPtr[2];
break;
case splashModeRGBX8:
cDest[0] = pipe->destColorPtr[0];
case splashModeXBGR8:
cDest[0] = pipe->destColorPtr[2];
cDest[1] = pipe->destColorPtr[1];
cDest[2] = pipe->destColorPtr[2];
cDest[2] = pipe->destColorPtr[0];
cDest[3] = 255;
break;
case splashModeBGR8:
......@@ -519,10 +522,10 @@ inline void Splash::pipeRun(SplashPipe *pipe) {
*pipe->destColorPtr++ = cResult1;
*pipe->destColorPtr++ = cResult2;
break;
case splashModeRGBX8:
*pipe->destColorPtr++ = cResult0;
*pipe->destColorPtr++ = cResult1;
case splashModeXBGR8:
*pipe->destColorPtr++ = cResult2;
*pipe->destColorPtr++ = cResult1;
*pipe->destColorPtr++ = cResult0;
*pipe->destColorPtr++ = 255;
break;
case splashModeBGR8:
......@@ -567,7 +570,7 @@ inline void Splash::pipeSetXY(SplashPipe *pipe, int x, int y) {
case splashModeBGR8:
pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + 3 * x];
break;
case splashModeRGBX8:
case splashModeXBGR8:
pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + 4 * x];
break;
#if SPLASH_CMYK
......@@ -609,7 +612,7 @@ inline void Splash::pipeIncX(SplashPipe *pipe) {
case splashModeBGR8:
pipe->destColorPtr += 3;
break;
case splashModeRGBX8:
case splashModeXBGR8:
pipe->destColorPtr += 4;
break;
#if SPLASH_CMYK
......@@ -1087,7 +1090,7 @@ void Splash::clear(SplashColorPtr color, Guchar alpha) {
}
}
break;
case splashModeRGBX8:
case splashModeXBGR8:
if (color[0] == color[1] && color[1] == color[2]) {
if (bitmap->rowSize < 0) {
memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1),
......@@ -1100,9 +1103,9 @@ void Splash::clear(SplashColorPtr color, Guchar alpha) {
for (y = 0; y < bitmap->height; ++y) {
p = row;
for (x = 0; x < bitmap->width; ++x) {
*p++ = color[2];
*p++ = color[1];
*p++ = color[0];
*p++ = color[1];
*p++ = color[2];
*p++ = 255;
}
row += bitmap->rowSize;
......@@ -2144,8 +2147,8 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData,
ok = srcMode == splashModeRGB8;
nComps = 3;
break;
case splashModeRGBX8:
ok = srcMode == splashModeRGBX8;
case splashModeXBGR8:
ok = srcMode == splashModeXBGR8;
nComps = 4;
break;
case splashModeBGR8:
......@@ -2486,9 +2489,8 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData,
}
break;
case splashModeRGBX8:
case splashModeXBGR8:
for (x = 0; x < scaledWidth; ++x) {
// x scale Bresenham
xStep = xp;
xt += xq;
......@@ -2817,7 +2819,7 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData,
}
break;
case splashModeRGBX8:
case splashModeXBGR8:
for (x = 0; x < scaledWidth; ++x) {
// x scale Bresenham
......@@ -3067,7 +3069,7 @@ void Splash::compositeBackground(SplashColorPtr color) {
}
}
break;
case splashModeRGBX8:
case splashModeXBGR8:
color0 = color[0];
color1 = color[1];
color2 = color[2];
......@@ -3161,7 +3163,7 @@ SplashError Splash::blitTransparent(SplashBitmap *src, int xSrc, int ySrc,
}
}
break;
case splashModeRGBX8:
case splashModeXBGR8:
for (y = 0; y < h; ++y) {
p = &bitmap->data[(yDest + y) * bitmap->rowSize + 4 * xDest];
for (x = 0; x < w; ++x) {
......
......@@ -36,7 +36,7 @@ SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPad,
case splashModeBGR8:
rowSize = width * 3;
break;
case splashModeRGBX8:
case splashModeXBGR8:
rowSize = width * 4;
break;
#if SPLASH_CMYK
......@@ -121,15 +121,15 @@ SplashError SplashBitmap::writePNMFile(char *fileName) {
}
break;
case splashModeRGBX8:
case splashModeXBGR8:
fprintf(f, "P6\n%d %d\n255\n", width, height);
row = data;
for (y = 0; y < height; ++y) {
p = row;
for (x = 0; x < width; ++x) {
fputc(splashRGB8R(p), f);
fputc(splashRGB8G(p), f);
fputc(splashRGB8B(p), f);
fputc(splashBGR8R(p), f);
fputc(splashBGR8G(p), f);
fputc(splashBGR8B(p), f);
p += 4;
}
row += rowSize;
......@@ -184,11 +184,11 @@ void SplashBitmap::getPixel(int x, int y, SplashColorPtr pixel) {
pixel[1] = p[1];
pixel[2] = p[2];
break;
case splashModeRGBX8:
case splashModeXBGR8:
p = &data[y * rowSize + 4 * x];
pixel[0] = p[0];
pixel[0] = p[2];
pixel[1] = p[1];
pixel[2] = p[2];
pixel[2] = p[0];
pixel[3] = p[3];
break;
case splashModeBGR8:
......
......@@ -38,8 +38,8 @@ enum SplashColorMode {
// RGBRGB...
splashModeBGR8, // 1 byte per component, 3 bytes per pixel:
// BGRBGR...
splashModeRGBX8, // 1 byte per component, 4 bytes per pixel:
// RGBXRGBX...
splashModeXBGR8, // 1 byte per component, 4 bytes per pixel:
// XBGRXBGR...
#if SPLASH_CMYK
,
splashModeCMYK8 // 1 byte per component, 4 bytes per pixel:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment