You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2016/01/04 18:33:19 UTC
svn commit: r1722924 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
Author: tilman
Date: Mon Jan 4 17:33:19 2016
New Revision: 1722924
URL: http://svn.apache.org/viewvc?rev=1722924&view=rev
Log:
PDFBOX-3181: use width and height directly from raster
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java?rev=1722924&r1=1722923&r2=1722924&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java Mon Jan 4 17:33:19 2016
@@ -128,10 +128,10 @@ public final class LosslessFactory
private static PDImageXObject createAlphaFromARGBImage(PDDocument document, BufferedImage image)
throws IOException
{
- // this implementation makes the assumption that the raster uses
- // SinglePixelPackedSampleModel, i.e. the values can be used 1:1 for
+ // this implementation makes the assumption that the raster values can be used 1:1 for
// the stream.
- // Sadly the type of the databuffer is TYPE_INT and not TYPE_BYTE.
+ // Sadly the type of the databuffer is usually TYPE_INT and not TYPE_BYTE so we can't just
+ // save it directly
if (!image.getColorModel().hasAlpha())
{
return null;
@@ -146,8 +146,8 @@ public final class LosslessFactory
}
int[] pixels = alphaRaster.getPixels(0, 0,
- alphaRaster.getSampleModel().getWidth(),
- alphaRaster.getSampleModel().getHeight(),
+ alphaRaster.getWidth(),
+ alphaRaster.getHeight(),
(int[]) null);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
int bpc;
@@ -155,7 +155,7 @@ public final class LosslessFactory
{
bpc = 1;
MemoryCacheImageOutputStream mcios = new MemoryCacheImageOutputStream(bos);
- int width = alphaRaster.getSampleModel().getWidth();
+ int width = alphaRaster.getWidth();
int p = 0;
for (int pixel : pixels)
{