Commit 0d311518 authored by Albert Astals Cid's avatar Albert Astals Cid

* splash/Splash.cc:

        * splash/SplashBitmap.cc: Make Splashbitmap RGB8 use 32bits internally
        * qt/poppler-page.cc:
        * qt4/src/poppler-page.cc: Adapt to splashbitmap change so copying to
        QImage is faster.
        Patch by Frank Meerkötter slightly modified by Albert Astals Cid

I'll leave adapting the glib frontend for you guys, i tried to adapt it but i got lost at gdk_pixbuf_get_n_channels (pixbuf);
parent 888bd41b
2006-04-04 Albert Astals Cid <aacid@kde.org>
* splash/Splash.cc:
* splash/SplashBitmap.cc: Make Splashbitmap RGB8 use 32bits internally
* qt/poppler-page.cc:
* qt4/src/poppler-page.cc: Adapt to splashbitmap change so copying to
QImage is faster.
Patch by Frank Meerkötter slightly modified by Albert Astals Cid
2006-04-04 Albert Astals Cid <aacid@kde.org>
* splash/SplashFTFont.cc: Fix crash when using fixedpoint math. Patch
......
......@@ -76,18 +76,12 @@ QImage Page::renderToImage(double xres, double yres) const
color_ptr = bitmap->getDataPtr ();
int bw = output_dev->getBitmap()->getWidth();
int bh = output_dev->getBitmap()->getHeight();
QImage img( bw, bh, 32 );
SplashColorPtr pixel = new Guchar[4];
for (int i = 0; i < bw; i++)
{
for (int j = 0; j < bh; j++)
{
output_dev->getBitmap()->getPixel(i, j, pixel);
img.setPixel( i, j, qRgb( pixel[0], pixel[1], pixel[2] ) );
}
}
delete[] pixel;
SplashColorPtr dataPtr = output_dev->getBitmap()->getDataPtr();
// construct a qimage SHARING the raw bitmap data in memory
QImage img( dataPtr, bw, bh, 32, 0, 0, QImage::IgnoreEndian );
img = img.copy();
// unload underlying xpdf bitmap
output_dev->startPage( 0, NULL );
return img;
}
......
......@@ -76,15 +76,12 @@ QImage Page::splashRenderToImage(double xres, double yres, int x, int y, int w,
// QImage *img = new QImage( (uchar*)color_ptr, bw, bh, QImage::Format_RGB32 );
// --------
QImage img( bw, bh, QImage::Format_RGB32 );
SplashColorPtr pixel = new Guchar[4];
for (int i = 0; i < bw; i++) {
for (int j = 0; j < bh; j++) {
output_dev->getBitmap()->getPixel(i, j, pixel);
img.setPixel( i, j, qRgb( pixel[0], pixel[1], pixel[2] ) );
}
}
delete[] pixel;
SplashColorPtr dataPtr = output_dev->getBitmap()->getDataPtr();
// construct a qimage SHARING the raw bitmap data in memory
QImage img( dataPtr, bw, bh, QImage::Format_RGB32 );
img = img.copy();
// unload underlying xpdf bitmap
output_dev->startPage( 0, NULL );
return img;
}
......
......@@ -319,9 +319,10 @@ void Splash::clear(SplashColorPtr color) {
for (y = 0; y < bitmap->height; ++y) {
p = row;
for (x = 0; x < bitmap->width; ++x) {
*p++ = color[0];
*p++ = color[1];
*p++ = color[2];
*p++ = color[1];
*p++ = color[0];
*p++ = 255;
}
row += bitmap->rowSize;
}
......@@ -963,11 +964,11 @@ void Splash::drawPixel(int x, int y, SplashColorPtr color,
break;
case splashModeRGB8:
case splashModeBGR8:
p = &bitmap->data[y * bitmap->rowSize + 3 * x];
p = &bitmap->data[y * bitmap->rowSize + 4 * x];
(*blendFunc)(color, p, blend, bitmap->mode);
p[0] = (alpha2 * blend[0] + ialpha2 * p[0]) >> 8;
p[0] = (alpha2 * blend[2] + ialpha2 * p[0]) >> 8;
p[1] = (alpha2 * blend[1] + ialpha2 * p[1]) >> 8;
p[2] = (alpha2 * blend[2] + ialpha2 * p[2]) >> 8;
p[2] = (alpha2 * blend[0] + ialpha2 * p[2]) >> 8;
break;
case splashModeARGB8:
case splashModeBGRA8:
......@@ -1014,10 +1015,10 @@ void Splash::drawPixel(int x, int y, SplashColorPtr color,
break;
case splashModeRGB8:
case splashModeBGR8:
p = &bitmap->data[y * bitmap->rowSize + 3 * x];
p[0] = color[0];
p = &bitmap->data[y * bitmap->rowSize + 4 * x];
p[0] = color[2];
p[1] = color[1];
p[2] = color[2];
p[2] = color[0];
break;
case splashModeARGB8:
case splashModeBGRA8:
......@@ -1092,11 +1093,11 @@ void Splash::drawPixel(int x, int y, SplashPattern *pattern,
break;
case splashModeRGB8:
case splashModeBGR8:
p = &bitmap->data[y * bitmap->rowSize + 3 * x];
p = &bitmap->data[y * bitmap->rowSize + 4 * x];
(*blendFunc)(color, p, blend, bitmap->mode);
p[0] = (alpha2 * blend[0] + ialpha2 * p[0]) >> 8;
p[0] = (alpha2 * blend[2] + ialpha2 * p[0]) >> 8;
p[1] = (alpha2 * blend[1] + ialpha2 * p[1]) >> 8;
p[2] = (alpha2 * blend[2] + ialpha2 * p[2]) >> 8;
p[2] = (alpha2 * blend[0] + ialpha2 * p[2]) >> 8;
break;
case splashModeARGB8:
case splashModeBGRA8:
......@@ -1144,10 +1145,10 @@ void Splash::drawPixel(int x, int y, SplashPattern *pattern,
break;
case splashModeRGB8:
case splashModeBGR8:
p = &bitmap->data[y * bitmap->rowSize + 3 * x];
p[0] = color[0];
p = &bitmap->data[y * bitmap->rowSize + 4 * x];
p[0] = color[2];
p[1] = color[1];
p[2] = color[2];
p[2] = color[0];
break;
case splashModeARGB8:
case splashModeBGRA8:
......@@ -1405,7 +1406,7 @@ void Splash::drawSpan(int x0, int x1, int y, SplashPattern *pattern,
case splashModeRGB8:
case splashModeBGR8:
p = &bitmap->data[y * bitmap->rowSize + 3 * x0];
p = &bitmap->data[y * bitmap->rowSize + 4 * x0];
if (pattern->isStatic()) {
pattern->getColor(0, 0, color);
for (i = 0; i < n; ++i) {
......@@ -1416,15 +1417,15 @@ void Splash::drawSpan(int x0, int x1, int y, SplashPattern *pattern,
ialpha2 = 255 - alpha2;
}
(*blendFunc)(color, p, blend, bitmap->mode);
p[0] = (alpha2 * blend[0] + ialpha2 * p[0]) >> 8;
p[0] = (alpha2 * blend[2] + ialpha2 * p[0]) >> 8;
p[1] = (alpha2 * blend[1] + ialpha2 * p[1]) >> 8;
p[2] = (alpha2 * blend[2] + ialpha2 * p[2]) >> 8;
p[2] = (alpha2 * blend[0] + ialpha2 * p[2]) >> 8;
if (!noClip) {
updateModX(x0 + i);
updateModY(y);
}
}
p += 3;
p += 4;
}
} else {
for (i = 0; i < n; ++i) {
......@@ -1444,7 +1445,7 @@ void Splash::drawSpan(int x0, int x1, int y, SplashPattern *pattern,
updateModY(y);
}
}
p += 3;
p += 4;
}
}
break;
......@@ -1698,20 +1699,20 @@ void Splash::drawSpan(int x0, int x1, int y, SplashPattern *pattern,
case splashModeRGB8:
case splashModeBGR8:
p = &bitmap->data[y * bitmap->rowSize + 3 * x0];
p = &bitmap->data[y * bitmap->rowSize + 4 * x0];
if (pattern->isStatic()) {
pattern->getColor(0, 0, color);
for (i = 0; i < n; ++i) {
if (noClip || state->clip->test(x0 + i, y)) {
p[0] = color[0];
p[0] = color[2];
p[1] = color[1];
p[2] = color[2];
p[2] = color[0];
if (!noClip) {
updateModX(x0 + i);
updateModY(y);
}
}
p += 3;
p += 4;
}
} else {
for (i = 0; i < n; ++i) {
......@@ -1725,7 +1726,7 @@ void Splash::drawSpan(int x0, int x1, int y, SplashPattern *pattern,
updateModY(y);
}
}
p += 3;
p += 4;
}
}
break;
......@@ -1898,19 +1899,19 @@ void Splash::xorSpan(int x0, int x1, int y, SplashPattern *pattern,
case splashModeRGB8:
case splashModeBGR8:
p = &bitmap->data[y * bitmap->rowSize + 3 * x0];
p = &bitmap->data[y * bitmap->rowSize + 4 * x0];
for (i = 0; i < n; ++i) {
if (noClip || state->clip->test(x0 + i, y)) {
pattern->getColor(x0 + i, y, color);
p[0] ^= color[0];
p[0] ^= color[2];
p[1] ^= color[1];
p[2] ^= color[2];
p[2] ^= color[0];
if (!noClip) {
updateModX(x0 + i);
updateModY(y);
}
}
p += 3;
p += 4;
}
break;
......@@ -2055,11 +2056,11 @@ SplashError Splash::fillGlyph(SplashCoord x, SplashCoord y,
break;
case splashModeRGB8:
case splashModeBGR8:
pix = &bitmap->data[y1 * bitmap->rowSize + 3 * x1];
pix = &bitmap->data[y1 * bitmap->rowSize + 4 * x1];
(*blendFunc)(fg, pix, blend, bitmap->mode);
pix[0] = (alpha * blend[0] + ialpha * pix[0]) >> 8;
pix[0] = (alpha * blend[2] + ialpha * pix[0]) >> 8;
pix[1] = (alpha * blend[1] + ialpha * pix[1]) >> 8;
pix[2] = (alpha * blend[2] + ialpha * pix[2]) >> 8;
pix[2] = (alpha * blend[0] + ialpha * pix[2]) >> 8;
break;
case splashModeARGB8:
case splashModeBGRA8:
......@@ -2136,11 +2137,11 @@ SplashError Splash::fillGlyph(SplashCoord x, SplashCoord y,
break;
case splashModeRGB8:
case splashModeBGR8:
pix = &bitmap->data[y1 * bitmap->rowSize + 3 * x1];
pix = &bitmap->data[y1 * bitmap->rowSize + 4 * x1];
(*blendFunc)(fg, pix, blend, bitmap->mode);
pix[0] = (alpha * blend[0] + ialpha * pix[0]) >> 8;
pix[0] = (alpha * blend[2] + ialpha * pix[0]) >> 8;
pix[1] = (alpha * blend[1] + ialpha * pix[1]) >> 8;
pix[2] = (alpha * blend[2] + ialpha * pix[2]) >> 8;
pix[2] = (alpha * blend[0] + ialpha * pix[2]) >> 8;
break;
case splashModeARGB8:
case splashModeBGRA8:
......@@ -2211,10 +2212,10 @@ SplashError Splash::fillGlyph(SplashCoord x, SplashCoord y,
break;
case splashModeRGB8:
case splashModeBGR8:
pix = &bitmap->data[y1 * bitmap->rowSize + 3 * x1];
pix[0] = (alpha * fg[0] + ialpha * pix[0]) >> 8;
pix = &bitmap->data[y1 * bitmap->rowSize + 4 * x1];
pix[0] = (alpha * fg[2] + ialpha * pix[0]) >> 8;
pix[1] = (alpha * fg[1] + ialpha * pix[1]) >> 8;
pix[2] = (alpha * fg[2] + ialpha * pix[2]) >> 8;
pix[2] = (alpha * fg[0] + ialpha * pix[2]) >> 8;
break;
case splashModeARGB8:
case splashModeBGRA8:
......@@ -2276,10 +2277,10 @@ SplashError Splash::fillGlyph(SplashCoord x, SplashCoord y,
break;
case splashModeRGB8:
case splashModeBGR8:
pix = &bitmap->data[y1 * bitmap->rowSize + 3 * x1];
pix[0] = fg[0];
pix = &bitmap->data[y1 * bitmap->rowSize + 4 * x1];
pix[0] = fg[2];
pix[1] = fg[1];
pix[2] = fg[2];
pix[2] = fg[0];
break;
case splashModeARGB8:
case splashModeBGRA8:
......
......@@ -36,7 +36,7 @@ SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPad,
break;
case splashModeRGB8:
case splashModeBGR8:
rowSize = width * 3;
rowSize = width * 4;
break;
case splashModeARGB8:
case splashModeBGRA8:
......@@ -128,7 +128,7 @@ SplashError SplashBitmap::writePNMFile(char *fileName) {
fputc(splashRGB8R(p), f);
fputc(splashRGB8G(p), f);
fputc(splashRGB8B(p), f);
p += 3;
p += 4;
}
row += rowSize;
}
......@@ -213,10 +213,10 @@ void SplashBitmap::getPixel(int x, int y, SplashColorPtr pixel) {
break;
case splashModeRGB8:
case splashModeBGR8:
p = &data[y * rowSize + 3 * x];
pixel[0] = p[0];
p = &data[y * rowSize + 4 * x];
pixel[0] = p[2];
pixel[1] = p[1];
pixel[2] = p[2];
pixel[2] = p[0];
break;
case splashModeARGB8:
case splashModeBGRA8:
......
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