You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xmlgraphics.apache.org by "simon steiner (JIRA)" <ji...@apache.org> on 2017/02/01 16:48:52 UTC

[jira] [Resolved] (XGC-106) java.lang.RuntimeException when writing BufferedImage to tiff

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

simon steiner resolved XGC-106.
-------------------------------
    Resolution: Not A Problem

> java.lang.RuntimeException when writing BufferedImage to tiff
> -------------------------------------------------------------
>
>                 Key: XGC-106
>                 URL: https://issues.apache.org/jira/browse/XGC-106
>             Project: XMLGraphicsCommons
>          Issue Type: Bug
>          Components: image writer
>    Affects Versions: 2.0.1
>         Environment: Ubuntu 64 bits
> java version "1.8.0_101"
> Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
> Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
>            Reporter: Andrea Vacondio
>
> Using the latest 2.1 I try to run this snipped to write a BufferedImage as a tif
> {code}
> public void myTest() throws IOException {
>         BufferedImage img = new BufferedImage(50, 50, BufferedImage.TYPE_INT_RGB);
>         Graphics2D g2d = img.createGraphics();
>         g2d.setBackground(Color.WHITE);
>         g2d.fillRect(0, 0, 50, 50);
>         g2d.setColor(new Color(20, 23, 54));
>         BasicStroke bs = new BasicStroke(2);
>         g2d.setStroke(bs);
>         g2d.drawLine(0, 0, 25, 25);
>         g2d.drawLine(10, 10, 5, 5);
>         g2d.dispose();
>         TIFFImageWriter writer = new TIFFImageWriter();
>         writer.writeImage(img, new ByteArrayOutputStream(), null);
>     }
> {code}
> but I get the following
> {code}
> java.lang.RuntimeException: Int or float buffers require 32-bit data.
> 	at org.apache.xmlgraphics.image.codec.tiff.TIFFImageEncoder.validateImage(TIFFImageEncoder.java:983)
> 	at org.apache.xmlgraphics.image.codec.tiff.TIFFImageEncoder.encode(TIFFImageEncoder.java:198)
> 	at org.apache.xmlgraphics.image.codec.tiff.TIFFImageEncoder.encode(TIFFImageEncoder.java:112)
> 	at org.apache.xmlgraphics.image.writer.internal.TIFFImageWriter.writeImage(TIFFImageWriter.java:55)
> {code}
> The same code works using TwelveMonkeys



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org