"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/TriangleBasedShadingContext.java" between
pdfbox-2.0.23-src.zip and pdfbox-2.0.24-src.zip

About: Apache PDFBox is a Java PDF library tool that allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents.

TriangleBasedShadingContext.java  (pdfbox-2.0.23-src):TriangleBasedShadingContext.java  (pdfbox-2.0.24-src)
skipping to change at line 28 skipping to change at line 28
import java.awt.PaintContext; import java.awt.PaintContext;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import java.awt.image.ColorModel; import java.awt.image.ColorModel;
import java.awt.image.Raster; import java.awt.image.Raster;
import java.awt.image.WritableRaster; import java.awt.image.WritableRaster;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.pdfbox.util.Matrix; import org.apache.pdfbox.util.Matrix;
/** /**
* Intermediate class extended by the shading types 4,5,6 and 7 that contains th e common methods * Intermediate class extended by the shading types 4,5,6 and 7 that contains th e common methods
* used by these classes. * used by these classes.
* *
* @author Shaola Ren * @author Shaola Ren
* @author Tilman Hausherr * @author Tilman Hausherr
*/ */
abstract class TriangleBasedShadingContext extends ShadingContext implements Pai ntContext abstract class TriangleBasedShadingContext extends ShadingContext implements Pai ntContext
{ {
private static final Log LOG = LogFactory.getLog(TriangleBasedShadingContext
.class);
protected int bitsPerCoordinate;
protected int bitsPerColorComponent;
protected int numberOfColorComponents;
private final boolean hasFunction;
// map of pixels within triangles to their RGB color // map of pixels within triangles to their RGB color
private Map<Point, Integer> pixelTable; private Map<Point, Integer> pixelTable;
/** /**
* Constructor. * Constructor.
* *
* @param shading the shading type to be used * @param shading the shading type to be used
* @param cm the color model to be used * @param cm the color model to be used
* @param xform transformation for user to device space * @param xform transformation for user to device space
* @param matrix the pattern matrix concatenated with that of the parent con tent stream * @param matrix the pattern matrix concatenated with that of the parent con tent stream
* @throws IOException if there is an error getting the color space or doing background color conversion. * @throws IOException if there is an error getting the color space or doing background color conversion.
*/ */
TriangleBasedShadingContext(PDShading shading, ColorModel cm, AffineTransfor m xform, TriangleBasedShadingContext(PDShading shading, ColorModel cm, AffineTransfor m xform,
Matrix matrix) throws IOException Matrix matrix) throws IOException
{ {
super(shading, cm, xform, matrix); super(shading, cm, xform, matrix);
PDTriangleBasedShadingType triangleBasedShadingType = (PDTriangleBasedSh
adingType) shading;
hasFunction = shading.getFunction() != null;
bitsPerCoordinate = triangleBasedShadingType.getBitsPerCoordinate();
LOG.debug("bitsPerCoordinate: " + (Math.pow(2, bitsPerCoordinate) - 1));
bitsPerColorComponent = triangleBasedShadingType.getBitsPerComponent();
LOG.debug("bitsPerColorComponent: " + bitsPerColorComponent);
numberOfColorComponents = hasFunction ? 1 : getShadingColorSpace().getNu
mberOfComponents();
LOG.debug("numberOfColorComponents: " + numberOfColorComponents);
} }
/** /**
* Creates the pixel table. * Creates the pixel table.
*/ */
protected final void createPixelTable(Rectangle deviceBounds) throws IOExcep tion protected final void createPixelTable(Rectangle deviceBounds) throws IOExcep tion
{ {
pixelTable = calcPixelTable(deviceBounds); pixelTable = calcPixelTable(deviceBounds);
} }
skipping to change at line 159 skipping to change at line 142
} }
} }
} }
/** /**
* Convert color to RGB color value, using function if required, then conver t from the shading * Convert color to RGB color value, using function if required, then conver t from the shading
* color space to an RGB value, which is encoded into an integer. * color space to an RGB value, which is encoded into an integer.
*/ */
private int evalFunctionAndConvertToRGB(float[] values) throws IOException private int evalFunctionAndConvertToRGB(float[] values) throws IOException
{ {
if (hasFunction) if (getShading().getFunction() != null)
{ {
values = getShading().evalFunction(values); values = getShading().evalFunction(values);
} }
return convertToRGB(values); return convertToRGB(values);
} }
/** /**
* Returns true if the shading has an empty data stream. * Returns true if the shading has an empty data stream.
*/ */
abstract boolean isDataEmpty(); abstract boolean isDataEmpty();
 End of changes. 4 change blocks. 
22 lines changed or deleted 2 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)