]> gcc.gnu.org Git - gcc.git/commitdiff
XToolkit.java (getColorModel): Implemented.
authorScott Gilbertson <scottg@mantatest.com>
Wed, 15 Jan 2003 23:18:58 +0000 (23:18 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Wed, 15 Jan 2003 23:18:58 +0000 (23:18 +0000)
2003-01-15  Scott Gilbertson  <scottg@mantatest.com>

* gnu/awt/xlib/XToolkit.java (getColorModel): Implemented.
* gnu/awt/xlib/XGraphicsConfiguration.java (getPixel): Work with
16-bit display mode.

From-SVN: r61362

libjava/ChangeLog
libjava/gnu/awt/xlib/XGraphicsConfiguration.java
libjava/gnu/awt/xlib/XToolkit.java

index 96297166325ee7aba1421339de2357561c43d920..9f1d5304c80cd19c84b1bd6fa0b96c67d9612919 100644 (file)
@@ -1,3 +1,9 @@
+2003-01-15  Scott Gilbertson  <scottg@mantatest.com>
+
+       * gnu/awt/xlib/XToolkit.java (getColorModel): Implemented.
+       * gnu/awt/xlib/XGraphicsConfiguration.java (getPixel): Work with
+       16-bit display mode.
+
 2003-01-15  Scott Gilbertson  <scottg@mantatest.com>
 
        * java/awt/CardLayout.java (show): Rewrote.
index 9ae12d6f8b99838ce44ab42ca01582c42ed5bd34..7d7d5159fe0ccde8d2aff8542dc8429048b0434a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000  Free Software Foundation
+/* Copyright (C) 2000, 2003  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -389,15 +389,32 @@ public class XGraphicsConfiguration extends GraphicsConfiguration
 
   int getPixel(Color color)
   {
+    /* FIXME: consider an integer technique whenever
+     * the ColorModel is 8 bits per color.
+     * The problem with using integers is that it doesn't work unless
+     * the colors are 8 bits each (as in the array), since ColorModel.getDataElement(int[],int)
+     * expects non-normalized values.  For example, in a 16-bit display mode, you
+     * would typically have 5 bits each for red and blue, and 6 bits for green.
     int[] components =
-        {
-         color.getRed(),
-         color.getGreen(),
-         color.getBlue(),
-         0xff
-       };
-       
-    ColorModel cm = getColorModel();
-    return cm.getDataElement(components, 0);
+    {
+      color.getRed (),
+      color.getGreen (),
+      color.getBlue (),
+      0xff
+    };
+     */
+    
+    float[] normalizedComponents =
+    {
+      ((float)color.getRed ()) / 255F,
+      ((float)color.getGreen ()) / 255F,
+      ((float)color.getBlue ()) / 255F,
+      1
+    };
+    int[] unnormalizedComponents = { 0, 0, 0, 0xff };
+    ColorModel cm = getColorModel ();
+    cm.getUnnormalizedComponents(normalizedComponents, 0,
+                                unnormalizedComponents, 0);
+    return cm.getDataElement (unnormalizedComponents, 0);
   }
 }
index 0c199b2b7f73744fd4327e5f8ead4cb0c607b2e3..c71b39d0f80035515119b07cf17c1fe73910348c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002  Free Software Foundation
+/* Copyright (C) 2000, 2002, 2003  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -173,7 +173,7 @@ public class XToolkit extends Toolkit
   
   public java.awt.image.ColorModel getColorModel()
   {
-    throw new UnsupportedOperationException("not implemented yet");
+    return getDefaultXGraphicsConfiguration().getColorModel();
   }
 
   public String[] getFontList()
This page took 0.075543 seconds and 5 git commands to generate.