Hi,

I doubt just changing the sizes would work. It would be a different image. Rather increase the -Xmx value.

That other products can handle this better might be because they use a different graphics engine, or a completely different program structure.

Tilman

Am 25.11.2016 um 09:40 schrieb [email protected]:

if a big image in pdf,  when save as image jpg, or png, will OutOfMemoryError


private static BufferedImage from8bit(PDImage pdImage, WritableRaster raster)
         throws IOException
{
     InputStream input = pdImage.createInputStream();
     try
     {
         // get the raster's underlying byte buffer
         byte[][] banks = ((DataBufferByte) 
raster.getDataBuffer()).getBankData();
         final int width = pdImage.getWidth();
         final int height = pdImage.getHeight();
         final int numComponents = 
pdImage.getColorSpace().getNumberOfComponents();
         int max = width * height;  // maybe a big image (10000x5000 px) but 
just 1080*1920 px can show on pdf
         byte[] tempBytes = new byte[numComponents];
         for (int i = 0; i < max; i++)
         {
             input.read(tempBytes);
             for (int c = 0; c < numComponents; c++)
             {
                 banks[c][i] = tempBytes[0+c];
             }
         }
         // use the color space to convert the image to RGB
         return pdImage.getColorSpace().toRGBImage(raster);
     }
     finally
     {
         IOUtils.closeQuietly(input);
     }
}




[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to