aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2007-02-27 21:35:17 +0000
committerKenneth Russel <[email protected]>2007-02-27 21:35:17 +0000
commitf024046a2eadf8cc695ac74181893baa8913245c (patch)
treef0bfb71d43d8dbba918c926462127fe15f25329c /src
parent78d92b6443c9817d3b4c35738948109e1aee769e (diff)
On advice from Chris Campbell, forced TYPE_INT_ARGB and
TYPE_4BYTE_ABGR images down custom code path in order to obey general invariant that image data sent down to OpenGL has premultiplied alpha. Fixed bug in handling of TYPE_INT_ARGB images in custom image conversion. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1155 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src')
-rwxr-xr-xsrc/classes/com/sun/opengl/util/texture/TextureData.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/classes/com/sun/opengl/util/texture/TextureData.java b/src/classes/com/sun/opengl/util/texture/TextureData.java
index 67e5d347e..7a00cd71a 100755
--- a/src/classes/com/sun/opengl/util/texture/TextureData.java
+++ b/src/classes/com/sun/opengl/util/texture/TextureData.java
@@ -427,7 +427,6 @@ public class TextureData {
rowLength = scanlineStride;
alignment = 4;
break;
- case BufferedImage.TYPE_INT_ARGB:
case BufferedImage.TYPE_INT_ARGB_PRE:
pixelFormat = GL.GL_BGRA;
pixelType = GL.GL_UNSIGNED_INT_8_8_8_8_REV;
@@ -455,7 +454,6 @@ public class TextureData {
}
}
break;
- case BufferedImage.TYPE_4BYTE_ABGR:
case BufferedImage.TYPE_4BYTE_ABGR_PRE:
{
// we can pass the image data directly to OpenGL only if
@@ -507,6 +505,11 @@ public class TextureData {
rowLength = scanlineStride;
alignment = 2;
break;
+ // Note: TYPE_INT_ARGB and TYPE_4BYTE_ABGR images go down the
+ // custom code path to satisfy the invariant that images with an
+ // alpha channel always go down with premultiplied alpha.
+ case BufferedImage.TYPE_INT_ARGB:
+ case BufferedImage.TYPE_4BYTE_ABGR:
case BufferedImage.TYPE_BYTE_BINARY:
case BufferedImage.TYPE_BYTE_INDEXED:
case BufferedImage.TYPE_CUSTOM:
@@ -538,11 +541,13 @@ public class TextureData {
pixelFormat = hasAlpha ? GL.GL_RGBA : GL.GL_RGB;
alignment = 1; // FIXME: do we need better?
rowLength = width; // FIXME: correct in all cases?
+ // Don't use GL_UNSIGNED_INT for TYPE_INT_ARGB images
+ boolean isIntRGBA = (image.getType() == BufferedImage.TYPE_INT_ARGB);
// Allow previously-selected pixelType (if any) to override that
// we can infer from the DataBuffer
DataBuffer data = image.getRaster().getDataBuffer();
- if (data instanceof DataBufferByte) {
+ if (data instanceof DataBufferByte || isIntRGBA) {
if (pixelType == 0) pixelType = GL.GL_UNSIGNED_BYTE;
} else if (data instanceof DataBufferDouble) {
throw new RuntimeException("DataBufferDouble rasters not supported by OpenGL");
@@ -568,6 +573,10 @@ public class TextureData {
boolean hasAlpha = image.getColorModel().hasAlpha();
ColorModel cm = null;
int dataBufferType = image.getRaster().getDataBuffer().getDataType();
+ // Don't use integer components for TYPE_INT_ARGB images
+ if (image.getType() == BufferedImage.TYPE_INT_ARGB) {
+ dataBufferType = DataBuffer.TYPE_BYTE;
+ }
if (dataBufferType == DataBuffer.TYPE_BYTE) {
cm = hasAlpha ? rgbaColorModel : rgbColorModel;
} else {