diff options
author | Thomas Freitag <Thomas.Freitag@alfa.de> | 2012-02-14 19:37:21 +0100 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2012-02-14 19:37:21 +0100 |
commit | 59946e0c34e762eb5f5a13b4ae8c9ec7fb21379a (patch) | |
tree | 05ee7bd5f927621d1677f3013105832ca97aecb0 /splash | |
parent | b505920db6d3dac58c7e9f4f8917f4c4449b08a0 (diff) |
Overprint implementation in postscript and splash device
It is an enhancement patch, a
merge fix and a bug fix in one: an enhancement, because it now completes
the implementation overprint mode and devicen in postscript, a merge
fix, because it fixes some bugs in the overprint implementation in
splash of xpdf 3.0.3 and has now the complete functionality (and more!)
of my implementation back again and a bug fix, because it fixes the use
of splash cmyk in postscript which never had worked.
1. Overprint implementation in postscript
To have a complete overprint implementation in the (pure) postscript
device there were just two things missing: overprint mode and the
implementation of the DeviceN colorspace in PostScript. I double checked
my implementation with the Ghent Test Suite with GhostScript (device
pdfwrite) and Acrobat X distiller, and all the tests now succeeds,
either in Acrobat X distiller or in GhostScript. As overprint is a
device dependent feature, it is up to the output device if it supports
overprint and what features of overprint are supported, and often You
have various configuration possibilities there. Nearly all PostScript
output of the Ghent tests show now the desired results if converting it
back to PDF with ghostscript pdfwrite, the implementation in ghostscript
is complete. On the other hand a few tests failed when using Acrobat X
distiller, all of them with the overprint mode switch. Funny, because
overprint mode 1 is often also called the illustrator overprint mode
because it was introduced by illustrator, but probably the destiller
only handles EPS correctly which comes from illustrator
2. Overprint implementation in postscript if using splash rasterization
Of course the postscript overprint implementation will only work if
pdftops doesn't decide to use splash to rasterize it because of the use
of transparencies in the PDF. But because overprint is device dependent
I decided to spend an additional parameter "overprint" to pdftops
(simular to pdftoppm). Switching it on (only available if compiled with
SPLASH_CMYK, because overprint is only in CMYK colorspace showable) will
use the overprint implementation in splash also if rasterizing the PDF.
3. Overprint implementation in splash
The overprint implementation in splash now uses the better designed
interface of xpdf and therefore now also works in transparency groups.
Thanks to the developper team of xpdf. I just fixed a small bug in it,
where it defies the technical specification. Of course it is still in
the nature of the splash implementation that it fails if CMYK values
should overprint spot colors, because spot colors are converted
immediately in their CMYK alternates. And in the implementation of
overprinting spot colors over CMYK colors I made a small assumption to
get it running which causes undesired results if this assumption fails,
but I didn't want to implement more and more configuration switches. I
still plan to implement a DeviceN output in splash and make a complete
implementation there, but this is of course a bigger task (but doable).
The overprint switch in pdftoppm is still only available if compiled
with the SPLASH_CMYK directive.
Diffstat (limited to 'splash')
-rw-r--r-- | splash/Splash.cc | 70 | ||||
-rw-r--r-- | splash/Splash.h | 4 | ||||
-rw-r--r-- | splash/SplashState.cc | 5 | ||||
-rw-r--r-- | splash/SplashState.h | 247 |
4 files changed, 182 insertions, 144 deletions
diff --git a/splash/Splash.cc b/splash/Splash.cc index fcab28c3..76a80f70 100644 --- a/splash/Splash.cc +++ b/splash/Splash.cc @@ -13,7 +13,7 @@ // // Copyright (C) 2005-2011 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> -// Copyright (C) 2010, 2011 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2010-2012 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> // Copyright (C) 2011 William Bader <williambader@hotmail.com> // @@ -48,6 +48,7 @@ #include "SplashFont.h" #include "SplashGlyphBitmap.h" #include "Splash.h" +#include <algorithm> //------------------------------------------------------------------------ @@ -383,16 +384,24 @@ void Splash::pipeRun(SplashPipe *pipe) { #if SPLASH_CMYK case splashModeCMYK8: if (state->overprintMask & 1) { - pipe->destColorPtr[0] = state->cmykTransferC[pipe->cSrc[0]]; + pipe->destColorPtr[0] = (state->overprintAdditive) ? + std::min<int>(pipe->destColorPtr[0] + state->cmykTransferC[pipe->cSrc[0]], 255) : + state->cmykTransferC[pipe->cSrc[0]]; } if (state->overprintMask & 2) { - pipe->destColorPtr[1] = state->cmykTransferM[pipe->cSrc[1]]; + pipe->destColorPtr[1] = (state->overprintAdditive) ? + std::min<int>(pipe->destColorPtr[1] + state->cmykTransferM[pipe->cSrc[1]], 255) : + state->cmykTransferC[pipe->cSrc[1]]; } if (state->overprintMask & 4) { - pipe->destColorPtr[2] = state->cmykTransferY[pipe->cSrc[2]]; + pipe->destColorPtr[2] = (state->overprintAdditive) ? + std::min<int>(pipe->destColorPtr[2] + state->cmykTransferY[pipe->cSrc[2]], 255) : + state->cmykTransferC[pipe->cSrc[2]]; } if (state->overprintMask & 8) { - pipe->destColorPtr[3] = state->cmykTransferK[pipe->cSrc[3]]; + pipe->destColorPtr[3] = (state->overprintAdditive) ? + std::min<int>(pipe->destColorPtr[3] + state->cmykTransferK[pipe->cSrc[3]], 255) : + state->cmykTransferC[pipe->cSrc[3]]; } pipe->destColorPtr += 4; break; @@ -708,16 +717,24 @@ void Splash::pipeRun(SplashPipe *pipe) { #if SPLASH_CMYK case splashModeCMYK8: if (state->overprintMask & 1) { - pipe->destColorPtr[0] = cResult0; + pipe->destColorPtr[0] = (state->overprintAdditive) ? + std::min<int>(pipe->destColorPtr[0] + cResult0, 255) : + cResult0; } if (state->overprintMask & 2) { - pipe->destColorPtr[1] = cResult1; + pipe->destColorPtr[1] = (state->overprintAdditive) ? + std::min<int>(pipe->destColorPtr[1] + cResult1, 255) : + cResult1; } if (state->overprintMask & 4) { - pipe->destColorPtr[2] = cResult2; + pipe->destColorPtr[2] = (state->overprintAdditive) ? + std::min<int>(pipe->destColorPtr[2] + cResult2, 255) : + cResult2; } if (state->overprintMask & 8) { - pipe->destColorPtr[3] = cResult3; + pipe->destColorPtr[3] = (state->overprintAdditive) ? + std::min<int>(pipe->destColorPtr[3] + cResult3, 255) : + cResult3; } pipe->destColorPtr += 4; break; @@ -811,16 +828,24 @@ void Splash::pipeRunSimpleBGR8(SplashPipe *pipe) { void Splash::pipeRunSimpleCMYK8(SplashPipe *pipe) { //----- write destination pixel if (state->overprintMask & 1) { - pipe->destColorPtr[0] = state->cmykTransferC[pipe->cSrc[0]]; + pipe->destColorPtr[0] = (state->overprintAdditive) ? + std::min<int>(pipe->destColorPtr[0] + state->cmykTransferC[pipe->cSrc[0]], 255) : + state->cmykTransferC[pipe->cSrc[0]]; } if (state->overprintMask & 2) { - pipe->destColorPtr[1] = state->cmykTransferM[pipe->cSrc[1]]; + pipe->destColorPtr[1] = (state->overprintAdditive) ? + std::min<int>(pipe->destColorPtr[1] + state->cmykTransferM[pipe->cSrc[1]], 255) : + state->cmykTransferC[pipe->cSrc[1]]; } if (state->overprintMask & 4) { - pipe->destColorPtr[2] = state->cmykTransferY[pipe->cSrc[2]]; + pipe->destColorPtr[2] = (state->overprintAdditive) ? + std::min<int>(pipe->destColorPtr[2] + state->cmykTransferY[pipe->cSrc[2]], 255) : + state->cmykTransferC[pipe->cSrc[2]]; } if (state->overprintMask & 8) { - pipe->destColorPtr[3] = state->cmykTransferK[pipe->cSrc[3]]; + pipe->destColorPtr[3] = (state->overprintAdditive) ? + std::min<int>(pipe->destColorPtr[3] + state->cmykTransferK[pipe->cSrc[3]], 255) : + state->cmykTransferC[pipe->cSrc[3]]; } pipe->destColorPtr += 4; *pipe->destAlphaPtr++ = 255; @@ -1084,16 +1109,24 @@ void Splash::pipeRunAACMYK8(SplashPipe *pipe) { //----- write destination pixel if (state->overprintMask & 1) { - pipe->destColorPtr[0] = cResult0; + pipe->destColorPtr[0] = (state->overprintAdditive && pipe->shape != 0) ? + std::min<int>(pipe->destColorPtr[0] + cResult0, 255) : + cResult0; } if (state->overprintMask & 2) { - pipe->destColorPtr[1] = cResult1; + pipe->destColorPtr[1] = (state->overprintAdditive && pipe->shape != 0) ? + std::min<int>(pipe->destColorPtr[1] + cResult1, 255) : + cResult1; } if (state->overprintMask & 4) { - pipe->destColorPtr[2] = cResult2; + pipe->destColorPtr[2] = (state->overprintAdditive && pipe->shape != 0) ? + std::min<int>(pipe->destColorPtr[2] + cResult2, 255) : + cResult2; } if (state->overprintMask & 8) { - pipe->destColorPtr[3] = cResult3; + pipe->destColorPtr[3] = (state->overprintAdditive && pipe->shape != 0) ? + std::min<int>(pipe->destColorPtr[3] + cResult3, 255) : + cResult3; } pipe->destColorPtr += 4; *pipe->destAlphaPtr++ = aResult; @@ -1606,8 +1639,9 @@ void Splash::setTransfer(Guchar *red, Guchar *green, Guchar *blue, state->setTransfer(red, green, blue, gray); } -void Splash::setOverprintMask(Guint overprintMask) { +void Splash::setOverprintMask(Guint overprintMask, GBool additive) { state->overprintMask = overprintMask; + state->overprintAdditive = additive; } //------------------------------------------------------------------------ diff --git a/splash/Splash.h b/splash/Splash.h index 3c2bf9f1..53bfa81a 100644 --- a/splash/Splash.h +++ b/splash/Splash.h @@ -13,7 +13,7 @@ // // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // Copyright (C) 2007, 2011 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2010, 2011 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2010-2012 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> // // To see a description of the changes please see the Changelog file that @@ -146,7 +146,7 @@ public: void setInNonIsolatedGroup(SplashBitmap *alpha0BitmapA, int alpha0XA, int alpha0YA); void setTransfer(Guchar *red, Guchar *green, Guchar *blue, Guchar *gray); - void setOverprintMask(Guint overprintMask); + void setOverprintMask(Guint overprintMask, GBool additive); //----- state save/restore diff --git a/splash/SplashState.cc b/splash/SplashState.cc index 7b632b84..e258f668 100644 --- a/splash/SplashState.cc +++ b/splash/SplashState.cc @@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2009, 2011 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2009, 2011, 2012 Thomas Freitag <Thomas.Freitag@alfa.de> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -86,6 +86,7 @@ SplashState::SplashState(int width, int height, GBool vectorAntialias, cmykTransferK[i] = (Guchar)i; } overprintMask = 0xffffffff; + overprintAdditive = gFalse; next = NULL; } @@ -131,6 +132,7 @@ SplashState::SplashState(int width, int height, GBool vectorAntialias, cmykTransferK[i] = (Guchar)i; } overprintMask = 0xffffffff; + overprintAdditive = gFalse; next = NULL; } @@ -173,6 +175,7 @@ SplashState::SplashState(SplashState *state) { memcpy(cmykTransferY, state->cmykTransferY, 256); memcpy(cmykTransferK, state->cmykTransferK, 256); overprintMask = state->overprintMask; + overprintAdditive = state->overprintAdditive; next = NULL; } diff --git a/splash/SplashState.h b/splash/SplashState.h index 214bffa1..01e77720 100644 --- a/splash/SplashState.h +++ b/splash/SplashState.h @@ -1,122 +1,122 @@ -//======================================================================== -// -// SplashState.h -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2011 Thomas Freitag <Thomas.Freitag@alfa.de> -// -// To see a description of the changes please see the Changelog file that -// came with your tarball or type make ChangeLog if you are building from git -// -//======================================================================== - -#ifndef SPLASHSTATE_H -#define SPLASHSTATE_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "SplashTypes.h" - -class SplashPattern; -class SplashScreen; -class SplashClip; -class SplashBitmap; - -//------------------------------------------------------------------------ -// line cap values -//------------------------------------------------------------------------ - -#define splashLineCapButt 0 -#define splashLineCapRound 1 -#define splashLineCapProjecting 2 - -//------------------------------------------------------------------------ -// line join values -//------------------------------------------------------------------------ - -#define splashLineJoinMiter 0 -#define splashLineJoinRound 1 -#define splashLineJoinBevel 2 - -//------------------------------------------------------------------------ -// SplashState -//------------------------------------------------------------------------ - -class SplashState { -public: - - // Create a new state object, initialized with default settings. - SplashState(int width, int height, GBool vectorAntialias, - SplashScreenParams *screenParams); - SplashState(int width, int height, GBool vectorAntialias, - SplashScreen *screenA); - - // Copy a state object. - SplashState *copy() { return new SplashState(this); } - - ~SplashState(); - - // Set the stroke pattern. This does not copy <strokePatternA>. - void setStrokePattern(SplashPattern *strokePatternA); - - // Set the fill pattern. This does not copy <fillPatternA>. - void setFillPattern(SplashPattern *fillPatternA); - - // Set the screen. This does not copy <screenA>. - void setScreen(SplashScreen *screenA); - - // Set the line dash pattern. This copies the <lineDashA> array. - void setLineDash(SplashCoord *lineDashA, int lineDashLengthA, - SplashCoord lineDashPhaseA); - - // Set the soft mask bitmap. - void setSoftMask(SplashBitmap *softMaskA); - - // Set the overprint parametes. - void setFillOverprint(GBool fillOverprintA) { fillOverprint = fillOverprintA; } - void setStrokeOverprint(GBool strokeOverprintA) { strokeOverprint = strokeOverprintA; } - void setOverprintMode(int overprintModeA) { overprintMode = overprintModeA; } - +//========================================================================
+//
+// SplashState.h
+//
+//========================================================================
+
+//========================================================================
+//
+// Modified under the Poppler project - http://poppler.freedesktop.org
+//
+// All changes made under the Poppler project to this file are licensed
+// under GPL version 2 or later
+//
+// Copyright (C) 2011, 2012 Thomas Freitag <Thomas.Freitag@alfa.de>
+//
+// To see a description of the changes please see the Changelog file that
+// came with your tarball or type make ChangeLog if you are building from git
+//
+//========================================================================
+
+#ifndef SPLASHSTATE_H
+#define SPLASHSTATE_H
+
+#ifdef USE_GCC_PRAGMAS
+#pragma interface
+#endif
+
+#include "SplashTypes.h"
+
+class SplashPattern;
+class SplashScreen;
+class SplashClip;
+class SplashBitmap;
+
+//------------------------------------------------------------------------
+// line cap values
+//------------------------------------------------------------------------
+
+#define splashLineCapButt 0
+#define splashLineCapRound 1
+#define splashLineCapProjecting 2
+
+//------------------------------------------------------------------------
+// line join values
+//------------------------------------------------------------------------
+
+#define splashLineJoinMiter 0
+#define splashLineJoinRound 1
+#define splashLineJoinBevel 2
+
+//------------------------------------------------------------------------
+// SplashState
+//------------------------------------------------------------------------
+
+class SplashState {
+public:
+
+ // Create a new state object, initialized with default settings.
+ SplashState(int width, int height, GBool vectorAntialias,
+ SplashScreenParams *screenParams);
+ SplashState(int width, int height, GBool vectorAntialias,
+ SplashScreen *screenA);
+
+ // Copy a state object.
+ SplashState *copy() { return new SplashState(this); }
+
+ ~SplashState();
+
+ // Set the stroke pattern. This does not copy <strokePatternA>.
+ void setStrokePattern(SplashPattern *strokePatternA);
+
+ // Set the fill pattern. This does not copy <fillPatternA>.
+ void setFillPattern(SplashPattern *fillPatternA);
+
+ // Set the screen. This does not copy <screenA>.
+ void setScreen(SplashScreen *screenA);
+
+ // Set the line dash pattern. This copies the <lineDashA> array.
+ void setLineDash(SplashCoord *lineDashA, int lineDashLengthA,
+ SplashCoord lineDashPhaseA);
+
+ // Set the soft mask bitmap.
+ void setSoftMask(SplashBitmap *softMaskA);
+
+ // Set the overprint parametes.
+ void setFillOverprint(GBool fillOverprintA) { fillOverprint = fillOverprintA; }
+ void setStrokeOverprint(GBool strokeOverprintA) { strokeOverprint = strokeOverprintA; }
+ void setOverprintMode(int overprintModeA) { overprintMode = overprintModeA; }
+
// Set the transfer function.
void setTransfer(Guchar *red, Guchar *green, Guchar *blue, Guchar *gray);
-private: - - SplashState(SplashState *state); - - SplashCoord matrix[6]; - SplashPattern *strokePattern; - SplashPattern *fillPattern; - SplashScreen *screen; - SplashBlendFunc blendFunc; - SplashCoord strokeAlpha; - SplashCoord fillAlpha; - SplashCoord lineWidth; - int lineCap; - int lineJoin; - SplashCoord miterLimit; - SplashCoord flatness; - SplashCoord *lineDash; - int lineDashLength; - SplashCoord lineDashPhase; - GBool strokeAdjust; - SplashClip *clip; - SplashBitmap *softMask; - GBool deleteSoftMask; - GBool inNonIsolatedGroup; - GBool fillOverprint; - GBool strokeOverprint; - int overprintMode; +private:
+
+ SplashState(SplashState *state);
+
+ SplashCoord matrix[6];
+ SplashPattern *strokePattern;
+ SplashPattern *fillPattern;
+ SplashScreen *screen;
+ SplashBlendFunc blendFunc;
+ SplashCoord strokeAlpha;
+ SplashCoord fillAlpha;
+ SplashCoord lineWidth;
+ int lineCap;
+ int lineJoin;
+ SplashCoord miterLimit;
+ SplashCoord flatness;
+ SplashCoord *lineDash;
+ int lineDashLength;
+ SplashCoord lineDashPhase;
+ GBool strokeAdjust;
+ SplashClip *clip;
+ SplashBitmap *softMask;
+ GBool deleteSoftMask;
+ GBool inNonIsolatedGroup;
+ GBool fillOverprint;
+ GBool strokeOverprint;
+ int overprintMode;
Guchar rgbTransferR[256],
rgbTransferG[256],
rgbTransferB[256];
@@ -126,10 +126,11 @@ private: cmykTransferY[256],
cmykTransferK[256];
Guint overprintMask;
- - SplashState *next; // used by Splash class - - friend class Splash; -}; - -#endif + GBool overprintAdditive;
+
+ SplashState *next; // used by Splash class
+
+ friend class Splash;
+};
+
+#endif
|