pivot-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Alegre (JIRA)" <j...@apache.org>
Subject [jira] Commented: (PIVOT-660) Picture resample fails on some BufferedImage
Date Thu, 28 Oct 2010 15:04:21 GMT

    [ https://issues.apache.org/jira/browse/PIVOT-660?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12925823#action_12925823

Andrew Alegre commented on PIVOT-660:

After checking out the code, an addition of an 'if' check below Picture.java:98 would help
avoid the problem in the future:

int type = bufferedImage.getType();

if(type == java.awt.image.BufferedImage.TYPE_CUSTOM)
    type = java.awt.image.BufferedImage.TYPE_INT_ARGB;

Currently, I'm using LTI-CIVIL (a webcam library) that passes a BufferedImage created with
a ColorModel and a Raster (its a faster method to making an image from a byte array) and instead
of using 2 BufferedImage for the pass (one from there then resample in the Picture class),
it's using up 3 with the workaround above.


> Picture resample fails on some BufferedImage
> --------------------------------------------
>                 Key: PIVOT-660
>                 URL: https://issues.apache.org/jira/browse/PIVOT-660
>             Project: Pivot
>          Issue Type: Bug
>    Affects Versions: 1.5.1
>         Environment: Windows 7 Ultimate, Java 1.6u20
>            Reporter: Andrew Alegre
>            Priority: Trivial
> Picture resampling fails if the BufferedImage supplied was created with a ColorModel
and Raster. (i.e. no type specified)
> java.lang.IllegalArgumentException: Unknown image type 0
>         at java.awt.image.BufferedImage.<init>(BufferedImage.java:490)
>         at org.apache.pivot.wtk.media.Picture.resample(Picture.java:101)
>         at org.apache.pivot.wtk.media.Picture.resample(Picture.java:83)
> Work around is simply to build a new BufferedImage with a specified type and draw the
last image onto it:
>         BufferedImage bimg = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_ARGB);
>         Graphics2D g2d = bimg.createGraphics();
>         g2d.drawImage(img, 0, 0, null);
>         Picture pic = new Picture(bimg);
>         pic.resample(200, 200);

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

View raw message