You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Andreas Lehmkühler (JIRA)" <ji...@apache.org> on 2010/06/03 13:01:14 UTC

[jira] Resolved: (PDFBOX-738) Preserve transparency when converting to image with rgba

     [ https://issues.apache.org/jira/browse/PDFBOX-738?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Lehmkühler resolved PDFBOX-738.
---------------------------------------

    Fix Version/s: 1.2.0
       Resolution: Fixed

I've applied the patch with version 950951.

Thanks to Armando for the contribution.

> Preserve transparency when converting to image with rgba
> --------------------------------------------------------
>
>                 Key: PDFBOX-738
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-738
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 1.2.0
>         Environment: all
>            Reporter: Armando Singer
>            Priority: Minor
>             Fix For: 1.2.0
>
>         Attachments: hello-DroidSans-Identity-H-rgba.png, hello-DroidSans-Identity-H.pdf, hello-DroidSans-Identity-H1-rgb.jpg, hello-DroidSans-Identity-H1-rgb.png, pdfbox-r945442.patch
>
>   Original Estimate: 0.08h
>  Remaining Estimate: 0.08h
>
> When converting a pdf page to an image, the transparency is lost because PDPage.drawImage() sets the background color to white: graphics.setBackground( Color.WHITE );
> The desired behavior is to preserve transparency when rgba color is set, and to fall back to white when rgb is used.
> The following change works with either color mode:
> +
> +    /**
> +     * Fully transparent that can fall back to white when image type has no alpha.
> +     */
> +    private static final Color TRANSPARENT_WHITE = new Color( 255, 255, 255, 0 );
> +
>     private COSDictionary page;
>     /**
> @@ -706,7 +711,7 @@
>         BufferedImage retval = new BufferedImage( widthPx, heightPx, imageType );
>         Graphics2D graphics = (Graphics2D)retval.getGraphics();
> -        graphics.setBackground( Color.WHITE );
> +        graphics.setBackground( TRANSPARENT_WHITE );
> Attached is a patch and some sample pdfs and images.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.