"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/SampledImageReader.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.

SampledImageReader.java  (pdfbox-2.0.23-src):SampledImageReader.java  (pdfbox-2.0.24-src)
skipping to change at line 201 skipping to change at line 201
throw new IOException("Image stream is empty"); throw new IOException("Image stream is empty");
} }
Rectangle clipped = clipRegion(pdImage, region); Rectangle clipped = clipRegion(pdImage, region);
// get parameters, they must be valid or have been repaired // get parameters, they must be valid or have been repaired
final PDColorSpace colorSpace = pdImage.getColorSpace(); final PDColorSpace colorSpace = pdImage.getColorSpace();
final int numComponents = colorSpace.getNumberOfComponents(); final int numComponents = colorSpace.getNumberOfComponents();
final int width = (int) Math.ceil(clipped.getWidth() / subsampling); final int width = (int) Math.ceil(clipped.getWidth() / subsampling);
final int height = (int) Math.ceil(clipped.getHeight() / subsampling); final int height = (int) Math.ceil(clipped.getHeight() / subsampling);
final int bitsPerComponent = pdImage.getBitsPerComponent(); final int bitsPerComponent = pdImage.getBitsPerComponent();
final float[] decode = getDecodeArray(pdImage);
if (width <= 0 || height <= 0 || pdImage.getWidth() <= 0 || pdImage.getH eight() <= 0) if (width <= 0 || height <= 0 || pdImage.getWidth() <= 0 || pdImage.getH eight() <= 0)
{ {
throw new IOException("image width and height must be positive"); throw new IOException("image width and height must be positive");
} }
try try
{ {
if (bitsPerComponent == 1 && colorKey == null && numComponents == 1) if (bitsPerComponent == 1 && colorKey == null && numComponents == 1)
{ {
skipping to change at line 223 skipping to change at line 222
} }
// An AWT raster must use 8/16/32 bits per component. Images with < 8bpc // An AWT raster must use 8/16/32 bits per component. Images with < 8bpc
// will be unpacked into a byte-backed raster. Images with 16bpc wil l be reduced // will be unpacked into a byte-backed raster. Images with 16bpc wil l be reduced
// in depth to 8bpc as they will be drawn to TYPE_INT_RGB images any way. All code // in depth to 8bpc as they will be drawn to TYPE_INT_RGB images any way. All code
// in PDColorSpace#toRGBImage expects an 8-bit range, i.e. 0-255. // in PDColorSpace#toRGBImage expects an 8-bit range, i.e. 0-255.
// Interleaved raster allows chunk-copying for 8-bit images. // Interleaved raster allows chunk-copying for 8-bit images.
WritableRaster raster = Raster.createInterleavedRaster(DataBuffer.TY PE_BYTE, width, height, WritableRaster raster = Raster.createInterleavedRaster(DataBuffer.TY PE_BYTE, width, height,
numComponents, new Point(0, 0)); numComponents, new Point(0, 0));
final float[] defaultDecode = pdImage.getColorSpace().getDefaultDeco de(8); final float[] defaultDecode = pdImage.getColorSpace().getDefaultDeco de(8);
if (bitsPerComponent == 8 && Arrays.equals(decode, defaultDecode) && final float[] decode = getDecodeArray(pdImage);
colorKey == null) if (bitsPerComponent == 8 && colorKey == null && Arrays.equals(decod
e, defaultDecode))
{ {
// convert image, faster path for non-decoded, non-colormasked 8 -bit images // convert image, faster path for non-decoded, non-colormasked 8 -bit images
return from8bit(pdImage, raster, clipped, subsampling, width, he ight); return from8bit(pdImage, raster, clipped, subsampling, width, he ight);
} }
return fromAny(pdImage, raster, colorKey, clipped, subsampling, widt h, height); return fromAny(pdImage, raster, colorKey, clipped, subsampling, widt h, height);
} }
catch (NegativeArraySizeException ex) catch (NegativeArraySizeException ex)
{ {
throw new IOException(ex); throw new IOException(ex);
} }
 End of changes. 2 change blocks. 
3 lines changed or deleted 3 lines changed or added

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