diff options
-rw-r--r-- | ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageLoader.java | 48 | ||||
-rw-r--r-- | ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageUtil.java | 17 |
2 files changed, 40 insertions, 25 deletions
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageLoader.java b/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageLoader.java index 5ecbeb3..d025592 100644 --- a/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageLoader.java +++ b/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageLoader.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -80,14 +80,14 @@ public class AWTImageLoader implements ImageLoader { final boolean grayscale = image.getColorModel().getNumComponents() == 1; BufferedImage tex; - if (flipImage - || ((image).getType() != BufferedImage.TYPE_BYTE_GRAY && (hasAlpha ? (image).getType() != BufferedImage.TYPE_4BYTE_ABGR + if (flipImage || ((image).getType() != BufferedImage.TYPE_BYTE_GRAY + && (hasAlpha ? (image).getType() != BufferedImage.TYPE_4BYTE_ABGR : (image).getType() != BufferedImage.TYPE_3BYTE_BGR))) { // Obtain the image data. try { tex = new BufferedImage(image.getWidth(null), image.getHeight(null), - grayscale ? BufferedImage.TYPE_BYTE_GRAY : hasAlpha ? BufferedImage.TYPE_4BYTE_ABGR - : BufferedImage.TYPE_3BYTE_BGR); + grayscale ? BufferedImage.TYPE_BYTE_GRAY + : hasAlpha ? BufferedImage.TYPE_4BYTE_ABGR : BufferedImage.TYPE_3BYTE_BGR); } catch (final IllegalArgumentException e) { logger.warning("Problem creating buffered Image: " + e.getMessage()); return TextureState.getDefaultTextureImage(); @@ -108,14 +108,14 @@ public class AWTImageLoader implements ImageLoader { // Get a pointer to the image memory final byte data[] = asByteArray(tex); - final ByteBuffer scratch = createOnHeap ? BufferUtils.createByteBufferOnHeap(data.length) : BufferUtils - .createByteBuffer(data.length); + final ByteBuffer scratch = createOnHeap ? BufferUtils.createByteBufferOnHeap(data.length) + : BufferUtils.createByteBuffer(data.length); scratch.clear(); scratch.put(data); scratch.flip(); final Image ardorImage = new Image(); - ardorImage.setDataFormat(grayscale ? ImageDataFormat.Luminance : hasAlpha ? ImageDataFormat.RGBA - : ImageDataFormat.RGB); + ardorImage.setDataFormat( + grayscale ? ImageDataFormat.Luminance : hasAlpha ? ImageDataFormat.RGBA : ImageDataFormat.RGB); ardorImage.setDataType(PixelDataType.UnsignedByte); ardorImage.setWidth(tex.getWidth()); ardorImage.setHeight(tex.getHeight()); @@ -138,14 +138,14 @@ public class AWTImageLoader implements ImageLoader { // Get a pointer to the image memory final byte data[] = asByteArray(image, grayscale, hasAlpha); - final ByteBuffer scratch = createOnHeap ? BufferUtils.createByteBufferOnHeap(data.length) : BufferUtils - .createByteBuffer(data.length); + final ByteBuffer scratch = createOnHeap ? BufferUtils.createByteBufferOnHeap(data.length) + : BufferUtils.createByteBuffer(data.length); scratch.clear(); scratch.put(data); scratch.flip(); final Image ardorImage = new Image(); - ardorImage.setDataFormat(grayscale ? ImageDataFormat.Luminance : hasAlpha ? ImageDataFormat.RGBA - : ImageDataFormat.RGB); + ardorImage.setDataFormat( + grayscale ? ImageDataFormat.Luminance : hasAlpha ? ImageDataFormat.RGBA : ImageDataFormat.RGB); ardorImage.setDataType(PixelDataType.UnsignedByte); ardorImage.setWidth(image.getWidth()); ardorImage.setHeight(image.getHeight()); @@ -217,7 +217,27 @@ public class AWTImageLoader implements ImageLoader { } /** - * Extract rgb values from raster using the colormodel. + * Extract RGB values from the raster using the color model. + * + * @param raster + * the raster + * @param colorModel + * the color model + * @param startX + * the start abscissa + * @param startY + * the start ordinate + * @param w + * the width + * @param h + * the height + * @param rgbArray + * the array containing the RGB values + * @param offset + * the offset in the passed array + * @param scansize + * the scan size + * @return the RGB values from the raster using the color model */ private static int[] getRGB(final Raster raster, final ColorModel colorModel, final int startX, final int startY, final int w, final int h, int[] rgbArray, final int offset, final int scansize) { diff --git a/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageUtil.java b/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageUtil.java index d158478..6002da3 100644 --- a/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageUtil.java +++ b/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageUtil.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -27,7 +27,7 @@ public abstract class AWTImageUtil { /** * Convert the given Ardor3D Image to a List of BufferedImages. It is a List because Ardor3D Images may contain * multiple layers (for example, in the case of cube maps or 3D textures). - * + * * @param input * the Ardor3D Image to convert * @return the BufferedImage(s) created in the conversion @@ -41,11 +41,11 @@ public abstract class AWTImageUtil { * Convert the given Ardor3D Image to a List of BufferedImages. It is a List because Ardor3D Images may contain * multiple layers (for example, in the case of cube maps or 3D textures). The given AWT Color is used to modulate * or "tint" the returned image. - * - * TODO: Add support for more formats.<br/> + * + * TODO: Add support for more formats.<br> * XXX: Note that only images of data type ImageDataType.UnsignedByte and ImageDataFormat of RGB or RGBA are * currently supported. - * + * * @param input * the Ardor3D Image to convert * @param tint @@ -88,12 +88,7 @@ public abstract class AWTImageUtil { image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); } - int index, - r, - g, - b, - a, - argb; + int index, r, g, b, a, argb; // Go through each pixel for (int x = 0; x < width; x++) { |