From 74af39df685584f6e9d298648f5e52e51cc99e31 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 31 Oct 2012 16:36:35 +0000 Subject: + implemented fallback for placeholder creation git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12694 3a0b52a2-8410-0410-bc02-ff6273a87459 --- .../java/at/asit/pdfover/gui/ImageConverter.java | 23 +++++++++++++++++++++- .../states/mobilebku/PostSLRequestThread.java | 1 - 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'trunk/pdf-over-gui') diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/ImageConverter.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/ImageConverter.java index 28fb55a6..83beceff 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/ImageConverter.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/ImageConverter.java @@ -18,6 +18,7 @@ package at.asit.pdfover.gui; // Imports import java.awt.image.BufferedImage; import java.awt.image.ColorModel; +import java.awt.image.ComponentColorModel; import java.awt.image.DirectColorModel; import java.awt.image.IndexColorModel; import java.awt.image.WritableRaster; @@ -147,8 +148,28 @@ public class ImageConverter { } } return data; + } else if (bufferedImage.getColorModel() instanceof ComponentColorModel) { + ComponentColorModel colorModel = (ComponentColorModel)bufferedImage.getColorModel(); + + //ASSUMES: 3 BYTE BGR IMAGE TYPE + + PaletteData palette = new PaletteData(0x0000FF, 0x00FF00,0xFF0000); + ImageData data = new ImageData(bufferedImage.getWidth(), bufferedImage.getHeight(), colorModel.getPixelSize(), palette); + + //This is valid because we are using a 3-byte Data model with no transparent pixels + data.transparentPixel = -1; + + WritableRaster raster = bufferedImage.getRaster(); + int[] pixelArray = new int[3]; + for (int y = 0; y < data.height; y++) { + for (int x = 0; x < data.width; x++) { + raster.getPixel(x, y, pixelArray); + int pixel = palette.getPixel(new RGB(pixelArray[0], pixelArray[1], pixelArray[2])); + data.setPixel(x, y, pixel); + } + } + return data; } return null; } - } diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/PostSLRequestThread.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/PostSLRequestThread.java index 260f49d6..34430abb 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/PostSLRequestThread.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/PostSLRequestThread.java @@ -62,7 +62,6 @@ public class PostSLRequestThread implements Runnable { @Override public long getLength() { - // TODO Auto-generated method stub return this.source.getLength(); } -- cgit v1.2.3