bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug awt/27239] Images shown with wrong color on powerpc (big endian)


From: sven at physto dot se
Subject: [Bug awt/27239] Images shown with wrong color on powerpc (big endian)
Date: 5 May 2006 01:39:32 -0000


------- Comment #9 from sven at physto dot se  2006-05-05 01:39 -------
(From update of attachment 11379)
>Index: gnu/java/awt/peer/gtk/GtkImage.java
>===================================================================
>RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/GtkImage.java,v
>retrieving revision 1.27
>diff -U3 -r1.27 GtkImage.java
>--- gnu/java/awt/peer/gtk/GtkImage.java        20 Mar 2006 14:42:37 -0000      
>1.27
>+++ gnu/java/awt/peer/gtk/GtkImage.java        5 May 2006 01:26:28 -0000
>@@ -53,6 +53,7 @@
> import java.util.Vector;
> import java.io.ByteArrayOutputStream;
> import java.io.BufferedInputStream;
>+import java.nio.ByteOrder;
> import java.net.URL;
> import gnu.classpath.Pointer;
> 
>@@ -113,13 +114,27 @@
>   ImageProducer source;
> 
>   /*
>-   * The 32-bit AABBGGRR format the GDK uses.
>+   * The 32-bit format the GDK uses.
>    */
>-  static ColorModel nativeModel = new DirectColorModel(32, 
>-                                                     0x000000FF,
>-                                                     0x0000FF00,
>-                                                     0x00FF0000,
>-                                                     0xFF000000);
>+  static ColorModel nativeModel;
>+  
>+  static 
>+  {
>+    // Little endian - AABBGGRR
>+    if( ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN )
>+      nativeModel = new DirectColorModel(32, 
>+                                       0x000000FF,
>+                                       0x0000FF00,
>+                                       0x00FF0000,
>+                                       0xFF000000);
>+    else
>+      // Big endian - RRGGBBAA
>+      nativeModel = new DirectColorModel(32, 
>+                                       0xFF000000,
>+                                       0x00FF0000,
>+                                       0x0000FF00,
>+                                       0x000000FF);
>+  }
> 
>   /**
>    * Returns a copy of the pixel data as a java array.
>Index: gnu/java/awt/peer/gtk/GtkImageConsumer.java
>===================================================================
>RCS file: 
>/sources/classpath/classpath/gnu/java/awt/peer/gtk/GtkImageConsumer.java,v
>retrieving revision 1.4
>diff -U3 -r1.4 GtkImageConsumer.java
>--- gnu/java/awt/peer/gtk/GtkImageConsumer.java        26 Jul 2005 01:53:25 
>-0000      1.4
>+++ gnu/java/awt/peer/gtk/GtkImageConsumer.java        5 May 2006 01:26:28 
>-0000
>@@ -126,12 +126,12 @@
>           {
>             // get in AARRGGBB and convert to AABBGGRR
>             int pix = cm.getRGB(pixels[offset + (i * scansize) + x + j]);
>-            byte b = (byte)(pix & 0xFF);
>-            byte r = (byte)(((pix & 0x00FF0000) >> 16) & 0xFF);
>-            pix &= 0xFF00FF00;
>-            pix |= ((b & 0xFF) << 16);
>-            pix |= (r & 0xFF);
>-            pixelCache[(y + i) * this.width + x + j] = pix;
>+            pixelCache[(y + i) * this.width + x + j] = 
>+              GtkImage.nativeModel.getDataElement(new int[]
>+                  { (((pix & 0x00FF0000) >> 16) & 0xFF),
>+                    (((pix & 0x0000FF00) >> 8) & 0xFF),
>+                    (pix & 0xFF),
>+                    (((pix & 0xFF000000) >> 24) & 0xFF)}, 0);
>           }
>       }
>   }


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27239





reply via email to

[Prev in Thread] Current Thread [Next in Thread]