You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by "Stefan Quandt (JIRA)" <ji...@apache.org> on 2015/09/18 10:18:04 UTC
[jira] [Updated] (FOP-2512) java.lang.NullPointerException:
Parameter alpha must not be null
[ https://issues.apache.org/jira/browse/FOP-2512?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stefan Quandt updated FOP-2512:
-------------------------------
Attachment: 22x22.png
19x13.png
16x16.png
Three examples PNGs which cannot be processed by fop.
> java.lang.NullPointerException: Parameter alpha must not be null
> ----------------------------------------------------------------
>
> Key: FOP-2512
> URL: https://issues.apache.org/jira/browse/FOP-2512
> Project: FOP
> Issue Type: Bug
> Affects Versions: 2.0
> Reporter: Mathieu Malaterre
> Attachments: 16x16.png, 19x13.png, 22x22.png
>
>
> fop is not capable of dealing with some PNG, it keeps on failing with:
> Error while rendering page 9
> java.lang.NullPointerException: Parameter alpha must not be null
> Exception
> java.lang.NullPointerException: Parameter alpha must not be null
> Input is:
> $ pnginfo test.png
> test.png...
> Image Width: 411 Image Length: 225
> Bitdepth (Bits/Sample): 8
> Channels (Samples/Pixel): 1
> Pixel depth (Pixel Depth): 8
> Colour Type (Photometric Interpretation): PALETTED COLOUR with alpha (18 colours, 17 transparent)
> Image filter: Single row per byte filter
> Interlacing: No interlacing
> Compression Scheme: Deflate method 8, 32k window
> Resolution: 0, 0 (unit unknown)
> FillOrder: msb-to-lsb
> Byte Order: Network (Big Endian)
> Number of text strings: 0 of 0
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
Re: [jira] [Updated] (FOP-2512) java.lang.NullPointerException:
Parameter alpha must not be null
Posted by "dvineshkumar@gmail.com" <dv...@gmail.com>.
Update the AlphaRasterImage class constructor like below to fix the issue.
Existing:
=====
public AlphaRasterImage(String k, RenderedImage image) {
this(k, GraphicsUtil.getAlphaRaster(image));
}
Updated:
=====
/**
* Create a alpha channel image.
* Extracts the alpha channel from the RenderedImage and creates a new
bitmap image
* with the given data.
*
* @param k the key to be used to lookup the image
* @param image the image (must have an alpha channel)
*/
public AlphaRasterImage(String k, RenderedImage image) {
this(k, getAlphaRaster(image));
}
/**
*
*
* Fix for Alpha Raster Image Issue.
*
* Extracts the Alpha Raster for the given image.
*
*/
private static java.awt.image.Raster getAlphaRaster(RenderedImage image)
{
java.awt.image.Raster alphaRaster = GraphicsUtil.getAlphaRaster(image);
/*
* If alphaRaster is null from the above call, then create the image
with
* alpha channel and return the alphaRaster.
*/
if (alphaRaster == null)
{
BufferedImage bufferedImage = (BufferedImage)image;
int w = bufferedImage.getWidth();
int h = bufferedImage.getHeight();
int type = BufferedImage.TYPE_INT_ARGB;
BufferedImage bia = new BufferedImage(w,h,type);
Graphics2D g = bia.createGraphics();
ImageObserver imo = null;
g.drawImage(bufferedImage, 0, 0, imo);
g.dispose();
alphaRaster = GraphicsUtil.getAlphaRaster(bia);
}
return alphaRaster;
}
--
View this message in context: http://apache-fop.1065347.n5.nabble.com/jira-Updated-FOP-2512-java-lang-NullPointerException-Parameter-alpha-must-not-be-null-tp42911p42965.html
Sent from the FOP - Dev mailing list archive at Nabble.com.