Uploaded image for project: 'XMLGraphicsCommons'
  1. XMLGraphicsCommons
  2. XGC-106

java.lang.RuntimeException when writing BufferedImage to tiff

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Not A Problem
    • 2.0.1
    • None
    • image writer
    • None
    • 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)

    Description

      Using the latest 2.1 I try to run this snipped to write a BufferedImage as a tif

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

      but I get the following

      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)
      

      The same code works using TwelveMonkeys

      Attachments

        Activity

          People

            Unassigned Unassigned
            torakiki Andrea Vacondio
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: