From 1b677f9837595d29a82c8be03ed4a4a1e3f6d482 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 19:03:57 +0000 Subject: + implemented fallback for placeholder creation git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@108 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../java/at/asit/pdfover/gui/ImageConverter.java | 23 +++++++++++++++++++++- .../states/mobilebku/PostSLRequestThread.java | 1 - 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'pdf-over-gui/src/main') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/ImageConverter.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/ImageConverter.java index 28fb55a6..83beceff 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/ImageConverter.java +++ b/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/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/PostSLRequestThread.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/PostSLRequestThread.java index 260f49d6..34430abb 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/PostSLRequestThread.java +++ b/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