diff --git a/PdfView/src/main/java/com/sun/pdfview/PDFImage.java b/PdfView/src/main/java/com/sun/pdfview/PDFImage.java index 007796b..b7ce9af 100644 --- a/PdfView/src/main/java/com/sun/pdfview/PDFImage.java +++ b/PdfView/src/main/java/com/sun/pdfview/PDFImage.java @@ -20,22 +20,20 @@ */ package com.sun.pdfview; -import java.io.File; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.HashMap; -import java.util.Map; +import android.graphics.Bitmap; +import android.graphics.Bitmap.Config; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.util.Log; import com.sun.pdfview.colorspace.PDFColorSpace; import com.sun.pdfview.function.FunctionType0; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Bitmap.Config; -import android.util.Log; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Map; @@ -83,7 +81,7 @@ public class PDFImage { /** the actual image data */ private PDFObject imageObj; - /** + /** * Create an instance of a PDFImage */ protected PDFImage(PDFObject imageObj) { @@ -127,9 +125,9 @@ public class PDFImage { // create the indexed color space for the mask // [PATCHED by michal.busta@gmail.com] - default value od Decode according to PDF spec. is [0, 1] - // so the color arry should be: + // so the color arry should be: int[] colors = {Color.BLACK, Color.WHITE}; - + PDFObject imageMaskDecode = obj.getDictRef("Decode"); if (imageMaskDecode != null) { PDFObject[] array = imageMaskDecode.getArray(); @@ -260,34 +258,31 @@ public class PDFImage { if (colorSpace == null) { throw new UnsupportedOperationException("image without colorspace"); } else if (colorSpace.getType() == PDFColorSpace.COLORSPACE_RGB) { - int maxH = getHeight(); - int maxW = getWidth(); - if (imgBytes.length == 2*maxW*maxH) { - // decoded JPEG as RGB565 - bi = Bitmap.createBitmap(maxW, maxH, Config.RGB_565); - bi.copyPixelsFromBuffer(ByteBuffer.wrap(imgBytes)); - } - else { - // create RGB image - bi = Bitmap.createBitmap(getWidth(), getHeight(), Config.ARGB_8888); - int[] line = new int[maxW]; - int n=0; - for (int h = 0; h