Skip to content

Commit

Permalink
codec: remove experimental methods PNGImage.toBufferedImage() and `…
Browse files Browse the repository at this point in the history
…PNGImageDecoder.decodeAsBufferedImage(int)`
  • Loading branch information
carlosame committed Aug 14, 2024
1 parent a31c966 commit 0d78bf4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@
package io.sf.carte.echosvg.ext.awt.image.codec.png;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Transparency;
import java.awt.color.ColorSpace;
import java.awt.color.ICC_ColorSpace;
import java.awt.color.ICC_Profile;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.ComponentColorModel;
import java.awt.image.DataBuffer;
Expand All @@ -48,7 +45,6 @@
import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Hashtable;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
Expand Down Expand Up @@ -1929,30 +1925,4 @@ private void decodeImage(boolean useInterlacing) {
}
}

/**
* Convert to a {@code BufferedImage}.
* <p>
* This method is experimental and could be removed without warning.
* </p>
*
* @return the {@code BufferedImage}.
*/
BufferedImage toBufferedImage() {
ColorModel cm = getColorModel();
SampleModel sm = getSampleModel();

Point loc = new Point(getMinX(), getMinY());

WritableRaster raster = Raster.createWritableRaster(sm, loc);
Hashtable<String, Object> props = new Hashtable<>(properties);

BufferedImage img = new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), props);

Graphics2D ig = img.createGraphics();
ig.drawRenderedImage(this, new AffineTransform());
ig.dispose();

return img;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package io.sf.carte.echosvg.ext.awt.image.codec.png;

import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -59,27 +58,4 @@ public RenderedImage decodeAsRenderedImage(int page) throws IOException {
return new PNGImage(input, (PNGDecodeParam) param);
}

/**
* Returns a <code>BufferedImage</code> that contains the decoded contents of
* the <code>SeekableStream</code> associated with this
* <code>ImageDecoder</code>. The given page of a multi-page image is decoded.
* Page numbering begins at zero.
* <p>
* This method is experimental and could be removed in the future.
* </p>
*
* @param page The page to be decoded.
* @throws IOException if the page does not exist.
*/
BufferedImage decodeAsBufferedImage(int page) throws IOException {
if (page != 0) {
throw new IOException(PropertyUtil.formatMessage("PNGImageDecoder.unknown.page",
new Object[] { page }));
}

PNGImage png = new PNGImage(input, (PNGDecodeParam) param);

return png.toBufferedImage();
}

}

0 comments on commit 0d78bf4

Please sign in to comment.