[ 
https://issues.apache.org/jira/browse/FOP-2512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14980165#comment-14980165
 ] 

Vinesh Kumar commented on FOP-2512:
-----------------------------------

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; 
    } 

> 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)

Reply via email to