-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8, 11, 17
-
x86_64
-
windows_10
A DESCRIPTION OF THE PROBLEM :
Scenario:
Error occurs on printing of a PDF document with embedded image mask of 1x1 Pixel.
Due to fitting to printable area PDF document is downscaled with a scale factor of 0.9.
Thus image mask has a size of 0.9x0.9 Pixel.
Code producing error is:
// Try to limit the amount of memory used to 8Mb, so
// if at device resolution this exceeds a certain
// image size then scale down the region to fit in
// that memory, but never to less than 72 dpi.
int w = (int)region.getWidth();
int h = (int)region.getHeight();
int nbytes = w * h * 3;
int maxBytes = 8 * 1024 * 1024;
double origDpi = (devResX < devResY) ? devResX : devResY;
int dpi = (int)origDpi;
double scaleFactor = 1;
double maxSFX = w/(double)boundsWidth;
double maxSFY = h/(double)boundsHeight;
double maxSF = (maxSFX > maxSFY) ? maxSFY : maxSFX;
int minDpi = (int)(dpi/maxSF);
Analysis:
- region.getWidth() and region.getHeight() return a value of 0.9
- Value of variables w and h is 0 (cast to int)
- Value of double maxSFX and double maxSFY is 0.0
- Value of double maxSF is 0.0
- Value of int minDpi is MAX_INT (division by zero and cast to int)
--------------------------------------------------------------------------
- method saveState of WPrinterJob is called with a region with width 3248928.1765086283 and height 3248928.176508832
Code: wPrinterJob.saveState(getTransform(), getClip(), region, scaleFactor, scaleFactor);
-------------------------------------------------------
- In method printPage of class RasterPrintJob a GraphicsState is fetched with a region of width 3248928.1765086283 and height 3248928.176508832
Code:
for (int i=0;i<redrawList.size();i++) {
GraphicsState gstate = redrawList.get(i);
pathGraphics.setTransform(initialTx);
((PathGraphics)pathGraphics).redrawRegion(
gstate.region,
gstate.sx,
gstate.sy,
gstate.theClip,
gstate.theTransform);
}
--------------------------------------------------------
- In method redrawRegion of class WPathGraphics a BufferedImage should be created
with width 3248928.1765086283 and height 3248928.176508832 and imagetype TYPE_3BYTE_BGR
Code:
BufferedImage deepImage = new BufferedImage(
(int) region.getWidth(),
(int) region.getHeight(),
BufferedImage.TYPE_3BYTE_BGR);
-------------------------------------------------------------------------
- In constructor of buffered image a WritableRaster should be created with width 3248928.1765086283 and height 3248928.176508832
Code:
case TYPE_3BYTE_BGR:
{
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
int[] nBits = {8, 8, 8};
int[] bOffs = {2, 1, 0};
colorModel = new ComponentColorModel(cs, nBits, false, false,
Transparency.OPAQUE,
DataBuffer.TYPE_BYTE);
raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,
width, height,
width*3, 3,
bOffs, null);
---------------------------------------------------------------------
- In method createInterleavedRaster of class Raster size of new Bytebuffer is set to value -194425856
which causes NegativeArraySizeException
value of scanlineStride is 9746784 and value of pixelStride is 3
Code:
int size = scanlineStride * (h - 1) + // fisrt (h - 1) scans
pixelStride * w; // last scan
switch(dataType) {
case DataBuffer.TYPE_BYTE:
d = new DataBufferByte(size);
break;
FREQUENCY : always
Scenario:
Error occurs on printing of a PDF document with embedded image mask of 1x1 Pixel.
Due to fitting to printable area PDF document is downscaled with a scale factor of 0.9.
Thus image mask has a size of 0.9x0.9 Pixel.
Code producing error is:
// Try to limit the amount of memory used to 8Mb, so
// if at device resolution this exceeds a certain
// image size then scale down the region to fit in
// that memory, but never to less than 72 dpi.
int w = (int)region.getWidth();
int h = (int)region.getHeight();
int nbytes = w * h * 3;
int maxBytes = 8 * 1024 * 1024;
double origDpi = (devResX < devResY) ? devResX : devResY;
int dpi = (int)origDpi;
double scaleFactor = 1;
double maxSFX = w/(double)boundsWidth;
double maxSFY = h/(double)boundsHeight;
double maxSF = (maxSFX > maxSFY) ? maxSFY : maxSFX;
int minDpi = (int)(dpi/maxSF);
Analysis:
- region.getWidth() and region.getHeight() return a value of 0.9
- Value of variables w and h is 0 (cast to int)
- Value of double maxSFX and double maxSFY is 0.0
- Value of double maxSF is 0.0
- Value of int minDpi is MAX_INT (division by zero and cast to int)
--------------------------------------------------------------------------
- method saveState of WPrinterJob is called with a region with width 3248928.1765086283 and height 3248928.176508832
Code: wPrinterJob.saveState(getTransform(), getClip(), region, scaleFactor, scaleFactor);
-------------------------------------------------------
- In method printPage of class RasterPrintJob a GraphicsState is fetched with a region of width 3248928.1765086283 and height 3248928.176508832
Code:
for (int i=0;i<redrawList.size();i++) {
GraphicsState gstate = redrawList.get(i);
pathGraphics.setTransform(initialTx);
((PathGraphics)pathGraphics).redrawRegion(
gstate.region,
gstate.sx,
gstate.sy,
gstate.theClip,
gstate.theTransform);
}
--------------------------------------------------------
- In method redrawRegion of class WPathGraphics a BufferedImage should be created
with width 3248928.1765086283 and height 3248928.176508832 and imagetype TYPE_3BYTE_BGR
Code:
BufferedImage deepImage = new BufferedImage(
(int) region.getWidth(),
(int) region.getHeight(),
BufferedImage.TYPE_3BYTE_BGR);
-------------------------------------------------------------------------
- In constructor of buffered image a WritableRaster should be created with width 3248928.1765086283 and height 3248928.176508832
Code:
case TYPE_3BYTE_BGR:
{
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
int[] nBits = {8, 8, 8};
int[] bOffs = {2, 1, 0};
colorModel = new ComponentColorModel(cs, nBits, false, false,
Transparency.OPAQUE,
DataBuffer.TYPE_BYTE);
raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,
width, height,
width*3, 3,
bOffs, null);
---------------------------------------------------------------------
- In method createInterleavedRaster of class Raster size of new Bytebuffer is set to value -194425856
which causes NegativeArraySizeException
value of scanlineStride is 9746784 and value of pixelStride is 3
Code:
int size = scanlineStride * (h - 1) + // fisrt (h - 1) scans
pixelStride * w; // last scan
switch(dataType) {
case DataBuffer.TYPE_BYTE:
d = new DataBufferByte(size);
break;
FREQUENCY : always
- duplicates
-
JDK-8314112 NegativeArraySizeException during print when scaling causes w and h to be 0
-
- Open
-