Class OutputProfiler.ProcessColorAction
- java.lang.Object
-
- org.faceless.pdf2.OutputProfiler.ProcessColorAction
-
- All Implemented Interfaces:
OutputProfiler.ColorAction
- Enclosing class:
- OutputProfiler
public static class OutputProfiler.ProcessColorAction extends Object implements OutputProfiler.ColorAction
TheProcessColorAction
class is an implementation ofOutputProfiler.ColorAction
which will convert any process colors (i.e. RGB, CMYK) into the specified ColorSpace. This may optionally include Calibrated colors, ifsetAllowCalibrated(boolean)
is false. Separation colors (i.e. those from aSpotColorSpace
orDeviceNColorSpace
) may be replaced with an identical color with afallback
ColorSpace mapped to the new ColorSpace if required, or may be replaced by their process equivalent, depending onsetRemapNamedInks(boolean)
-
-
Field Summary
-
Fields inherited from interface org.faceless.pdf2.OutputProfiler.ColorAction
TYPE_ANNOTATION, TYPE_BITMAP, TYPE_CALIBRATED, TYPE_INDEXED, TYPE_INLINE, TYPE_PROCESS, TYPE_SEPARATION, TYPE_SHADING
-
-
Constructor Summary
Constructors Constructor Description ProcessColorAction(ColorSpace cs)
Create a newProcessColorAction
, and pass the single Colorspace supplied tosetColorSpaces(java.util.Collection<? extends java.awt.color.ColorSpace>)
.ProcessColorAction(OutputProfile target)
Create a newProcessColorAction
that will convert colors in the PDF to try and match the OutputProfile and its mainOutputIntent
.ProcessColorAction(OutputProfile target, Collection<? extends ColorSpace> colorspaces)
Create a newProcessColorAction
that will convert process colors to the ColorSpace specified in the supplied OutputProfile'sOutputIntent
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ColorSpace
changeColor(OutputProfiler profiler, ColorSpace csin, float[] src, float[] dst, boolean fill, int type)
Optionally converts a Color from one ColorSpace to another.boolean
getAllowCalibrated()
Return the value of the flag set bysetAllowCalibrated(boolean)
ColorSpace
getDefaultBlendingColorSpace()
Return the ColorSpace that should be used for blending operations, or null if unknownColorSpace
getDeviceCMYK()
Return the CMYK ColorSpace that should be used as the "DeviceCMYK" space, or null if none is set.ColorSpace
getDeviceGray()
Return the Gray ColorSpace that should be used as the "DeviceGray" space, or null if none is set.ColorSpace
getDeviceRGB()
Return the RGB ColorSpace that should be used as the "DeviceRGB" space, or null if none is set.boolean
getRemapNamedInks()
Return the value of the flag set bysetRemapNamedInks(boolean)
boolean
getUseDefaultColorSpaces()
Return the value of the flag set bysetUseDefaultColorSpaces(boolean)
ColorSpace
getUsedIntentColorSpace()
Return the ColorSpace which was extracted from theOutputProfile
supplied to the constructor, if any, that serves as the "intent" ColorSpace around which the algorithm used by this class is based.void
setAllowCalibrated(boolean flag)
Determines how process colors in a calibrated ColorSpace are modified.void
setColorSpaces(Collection<? extends ColorSpace> cslist)
Set a list ofColorSpace
objects which may be used by theOutputProfiler.apply(org.faceless.pdf2.OutputProfile)
method to to map a Device colorspace to a non-device ColorSpace.void
setRemapNamedInks(boolean flag)
When the input color is a Spot or DeviceN color and the input color needs to change, we can either remap the Spot/DeviceN color to a color in the destination process ColorSpace (set to true), or we can discard the Spot/DeviceN colorspace and replace it with the process color equivalent (set to false: the default).void
setRenderingIntent(OutputProfiler.RenderingIntent intent)
Set the rendering intent, to control how out-of-gamut colors are converted.void
setUseDefaultColorSpaces(boolean flag)
When the input color is a device color and the API needs to make it calibrated, the default method is to modify the color in the object itself.
-
-
-
Constructor Detail
-
ProcessColorAction
public ProcessColorAction(ColorSpace cs)
Create a newProcessColorAction
, and pass the single Colorspace supplied tosetColorSpaces(java.util.Collection<? extends java.awt.color.ColorSpace>)
.- Parameters:
cs
- the process ColorSpace to convert colors to
-
ProcessColorAction
public ProcessColorAction(OutputProfile target)
Create a new
ProcessColorAction
that will convert colors in the PDF to try and match the OutputProfile and its mainOutputIntent
.Here's an example showing how to use this constructor to simplify conversion of a PDF to a PDF/A document with all uncalibrated colors converted to the Output Intent specifed in the profile.
OutputProfiler profiler = new OutputProfiler(new PDFParser(pdf)); OutputProfile profile = profiler.getProfile(); ColorSpace icc = new ICCColorSpace("US_Web_Coated_SWOP.icm"); OutputProfile target = new OutputProfile(OutputProfile.PDFA1b_2005); target.getOutputIntents().add(new OutputIntent("GTS_PDFA1", "CGATS TR 001", icc)); profiler.setColorAction(new OutputProfiler.ProcessColorAction(target)); profiler.apply(target);
Note: if the target has a CMYK OutputIntent, this constructor will also set
setRemapNamedInks(boolean)
to true- Parameters:
target
- the OutputProfile to match and retrieve the OutputIntent from - typically a PDF/A or PDF/X profile.- See Also:
OutputProfile.getOutputIntents()
,OutputIntent.getColorSpace()
-
ProcessColorAction
public ProcessColorAction(OutputProfile target, Collection<? extends ColorSpace> colorspaces)
Create a new
ProcessColorAction
that will convert process colors to the ColorSpace specified in the supplied OutputProfile'sOutputIntent
. Calls the previous constructor thensetColorSpaces(java.util.Collection<? extends java.awt.color.ColorSpace>)
- Since:
- 2.26
-
-
Method Detail
-
setAllowCalibrated
public void setAllowCalibrated(boolean flag)
Determines how process colors in a calibrated ColorSpace are modified. If true, calibrated colors are allowed and will remain unchanged, but device-dependent colors will be changed to the specified process ColorSpace (appropriate for PDF/A and PDF/X-3). If false, calibrated colors are disallowed and will be converted as well (appropriate for PDF/X-1). The default is true.- Parameters:
flag
- whether calibrated process colors should remain unchanged
-
getAllowCalibrated
public boolean getAllowCalibrated()
Return the value of the flag set bysetAllowCalibrated(boolean)
- Since:
- 2.26
-
setRemapNamedInks
public void setRemapNamedInks(boolean flag)
When the input color is a Spot or DeviceN color and the input color needs to change, we can either remap the Spot/DeviceN color to a color in the destination process ColorSpace (set to true), or we can discard the Spot/DeviceN colorspace and replace it with the process color equivalent (set to false: the default).- Parameters:
flag
- whether Spot or DeviceN inks should be modified or replaced with process equivalents- Since:
- 2.23.2
-
getRemapNamedInks
public boolean getRemapNamedInks()
Return the value of the flag set bysetRemapNamedInks(boolean)
- Since:
- 2.26
-
setUseDefaultColorSpaces
public void setUseDefaultColorSpaces(boolean flag)
When the input color is a device color and the API needs to make it calibrated, the default method is to modify the color in the object itself. An alternative method is to use thePDFPage.setDefaultColorSpace(int, java.awt.color.ColorSpace)
method to set the appropriate "Default" colorspaces on the page/canvas etc. - this method controls whether that approach is selected.- Parameters:
flag
- whether the corrections should be made using the Default colorspaces- Since:
- 2.26
-
getUseDefaultColorSpaces
public boolean getUseDefaultColorSpaces()
Return the value of the flag set bysetUseDefaultColorSpaces(boolean)
- Since:
- 2.26
-
setRenderingIntent
public void setRenderingIntent(OutputProfiler.RenderingIntent intent)
Set the rendering intent, to control how out-of-gamut colors are converted. The default isPerceptual
, and other values may not be supported depending on the ColorSpace. If not, the process will fall back to Perceptual- Parameters:
intent
- the rendering intent for color conversion
-
changeColor
public ColorSpace changeColor(OutputProfiler profiler, ColorSpace csin, float[] src, float[] dst, boolean fill, int type)
Description copied from interface:OutputProfiler.ColorAction
Optionally converts a Color from one ColorSpace to another.
If the source Color is to be converted, this method should return the ColorSpace it will be converted to, and populate the dst array with the new color components if dst is not null. If dst is null, it is sufficient to just return the target ColorSpace (which may be the same as the source ColorSpace, for example if the Colors are simply being retinted).
If no change is to be made, this method should return
null
. If "dst" is not null and this method returns null, subsequent calls to changeColor will be skipped. This optimization can be used when the ColorSpace of an image has been changed, but the components remain identical.This method must be consistent and return the same output for the same input parameters. It must also be quick, as it may be called millions of times during preflighting (as it must be called once for each pixel).
- Specified by:
changeColor
in interfaceOutputProfiler.ColorAction
- Parameters:
profiler
- the OutputProfiler this action is being run oncsin
- the source ColorSpacesrc
- the source Color componentsdst
- if not null, should be updated with the target Color componentsfill
- true if the Color will be used for filling, false if for strokingtype
- the type of ColorSpace, which will be a bitmask possibly including one or more of #TYPE_PROCESS, #TYPE_CALIBRATED, #TYPE_SEPARATION, #TYPE_SHADING or #TYPE_BITMAP- Returns:
- the target ColorSpace or
null
for no change.
-
setColorSpaces
public void setColorSpaces(Collection<? extends ColorSpace> cslist)
Set a list ofColorSpace
objects which may be used by theOutputProfiler.apply(org.faceless.pdf2.OutputProfile)
method to to map a Device colorspace to a non-device ColorSpace. The supplied collection may containICC_ColorSpace
orICCColorSpace
objects, which may be grayscale, RGB or CMYK (others will be ignored). The first matching ColorSpace for each of these categories is used, where required, to "anchor" colors in the corresponding Device ColorSpace to a calibrated ColorSpace.- Parameters:
cslist
- a collection of 0 or more ColorSpaces. A null value is the same as an empty list.- Since:
- 2.26
-
getDeviceRGB
public ColorSpace getDeviceRGB()
Description copied from interface:OutputProfiler.ColorAction
Return the RGB ColorSpace that should be used as the "DeviceRGB" space, or null if none is set.- Specified by:
getDeviceRGB
in interfaceOutputProfiler.ColorAction
-
getDeviceCMYK
public ColorSpace getDeviceCMYK()
Description copied from interface:OutputProfiler.ColorAction
Return the CMYK ColorSpace that should be used as the "DeviceCMYK" space, or null if none is set.- Specified by:
getDeviceCMYK
in interfaceOutputProfiler.ColorAction
-
getDeviceGray
public ColorSpace getDeviceGray()
Description copied from interface:OutputProfiler.ColorAction
Return the Gray ColorSpace that should be used as the "DeviceGray" space, or null if none is set.- Specified by:
getDeviceGray
in interfaceOutputProfiler.ColorAction
-
getDefaultBlendingColorSpace
public ColorSpace getDefaultBlendingColorSpace()
Description copied from interface:OutputProfiler.ColorAction
Return the ColorSpace that should be used for blending operations, or null if unknown- Specified by:
getDefaultBlendingColorSpace
in interfaceOutputProfiler.ColorAction
-
getUsedIntentColorSpace
public ColorSpace getUsedIntentColorSpace()
Return the ColorSpace which was extracted from theOutputProfile
supplied to the constructor, if any, that serves as the "intent" ColorSpace around which the algorithm used by this class is based.- Specified by:
getUsedIntentColorSpace
in interfaceOutputProfiler.ColorAction
- Since:
- 2.26
-
-