summaryrefslogtreecommitdiff
path: root/splash
diff options
context:
space:
mode:
authorThomas Freitag <Thomas.Freitag@alfa.de>2012-11-02 22:44:27 +0100
committerAlbert Astals Cid <aacid@kde.org>2012-11-02 22:48:38 +0100
commitef11b4f0e642dff0be02bf3327eb56bf0b364847 (patch)
treed28489912c358202f52a51d7ecb19bd871fee735 /splash
parentae8fc0cbfc6123189e17b3cf1286e0540f181646 (diff)
Implement overprint in qt interface
With minor api fixes by me (Albert Astals Cid)
Diffstat (limited to 'splash')
-rw-r--r--splash/SplashBitmap.cc70
-rw-r--r--splash/SplashBitmap.h5
2 files changed, 74 insertions, 1 deletions
diff --git a/splash/SplashBitmap.cc b/splash/SplashBitmap.cc
index 5fe61a2e..996f0aa9 100644
--- a/splash/SplashBitmap.cc
+++ b/splash/SplashBitmap.cc
@@ -441,6 +441,76 @@ void SplashBitmap::getRGBLine(int yl, SplashColorPtr line) {
}
}
+void SplashBitmap::getXBGRLine(int yl, SplashColorPtr line) {
+ SplashColor col;
+ double c, m, y, k, c1, m1, y1, k1, r, g, b;
+
+ for (int x = 0; x < width; x++) {
+ getPixel(x, yl, col);
+ c = byteToDbl(col[0]);
+ m = byteToDbl(col[1]);
+ y = byteToDbl(col[2]);
+ k = byteToDbl(col[3]);
+#if SPLASH_CMYK
+ if (separationList->getLength() > 0) {
+ for (int i = 0; i < separationList->getLength(); i++) {
+ if (col[i+4] > 0) {
+ GfxCMYK cmyk;
+ GfxColor input;
+ input.c[0] = byteToCol(col[i+4]);
+ GfxSeparationColorSpace *sepCS = (GfxSeparationColorSpace *)separationList->get(i);
+ sepCS->getCMYK(&input, &cmyk);
+ col[0] = colToByte(cmyk.c);
+ col[1] = colToByte(cmyk.m);
+ col[2] = colToByte(cmyk.y);
+ col[3] = colToByte(cmyk.k);
+ c += byteToDbl(col[0]);
+ m += byteToDbl(col[1]);
+ y += byteToDbl(col[2]);
+ k += byteToDbl(col[3]);
+ }
+ }
+ if (c > 1) c = 1;
+ if (m > 1) m = 1;
+ if (y > 1) y = 1;
+ if (k > 1) k = 1;
+ }
+#endif
+ c1 = 1 - c;
+ m1 = 1 - m;
+ y1 = 1 - y;
+ k1 = 1 - k;
+ cmykToRGBMatrixMultiplication(c, m, y, k, c1, m1, y1, k1, r, g, b);
+ *line++ = dblToByte(clip01(b));
+ *line++ = dblToByte(clip01(g));
+ *line++ = dblToByte(clip01(r));
+ *line++ = 255;
+ }
+}
+
+GBool SplashBitmap::convertToXBGR() {
+ if (mode == splashModeXBGR8)
+ return gTrue;
+
+ int newrowSize = width * 4;
+ SplashColorPtr newdata = (SplashColorPtr)gmallocn_checkoverflow(newrowSize, height);
+ if (newdata != NULL) {
+ for (int y = 0; y < height; y++) {
+ unsigned char *row = newdata + y * newrowSize;
+ getXBGRLine(y, row);
+ }
+ if (rowSize < 0) {
+ gfree(data + (height - 1) * rowSize);
+ } else {
+ gfree(data);
+ }
+ data = newdata;
+ rowSize = newrowSize;
+ mode = splashModeXBGR8;
+ }
+ return newdata != NULL;
+}
+
#if SPLASH_CMYK
void SplashBitmap::getCMYKLine(int yl, SplashColorPtr line) {
SplashColor col;
diff --git a/splash/SplashBitmap.h b/splash/SplashBitmap.h
index 0bff2050..70509abc 100644
--- a/splash/SplashBitmap.h
+++ b/splash/SplashBitmap.h
@@ -13,7 +13,7 @@
//
// Copyright (C) 2007 Ilmari Heikkinen <ilmari.heikkinen@gmail.com>
// Copyright (C) 2009 Shen Liang <shenzhuxi@gmail.com>
-// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2009, 2012 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2009 Stefan Thomas <thomas@eload24.com>
// Copyright (C) 2010 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2010 Harry Roberts <harry.roberts@midnight-labs.org>
@@ -75,8 +75,11 @@ public:
SplashError writeImgFile(SplashImageFileFormat format, FILE *f, int hDPI, int vDPI, const char *compressionString = "");
SplashError writeImgFile(ImgWriter *writer, FILE *f, int hDPI, int vDPI);
+ GBool convertToXBGR();
+
void getPixel(int x, int y, SplashColorPtr pixel);
void getRGBLine(int y, SplashColorPtr line);
+ void getXBGRLine(int y, SplashColorPtr line);
#if SPLASH_CMYK
void getCMYKLine(int y, SplashColorPtr line);
#endif