diff options
author | Scott Gilbertson <scottg@mantatest.com> | 2003-01-15 23:18:58 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2003-01-15 23:18:58 +0000 |
commit | 7a968a57826efd0a56fc3dd172134f57c76a33c8 (patch) | |
tree | f39a4fca2c01f1adf7e3990b5a79360436b447e1 /libjava/gnu/awt | |
parent | f077f1693bd11aee4daeb9bc9720f1f96161de46 (diff) | |
download | gcc-7a968a57826efd0a56fc3dd172134f57c76a33c8.zip gcc-7a968a57826efd0a56fc3dd172134f57c76a33c8.tar.gz gcc-7a968a57826efd0a56fc3dd172134f57c76a33c8.tar.bz2 |
XToolkit.java (getColorModel): Implemented.
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
Diffstat (limited to 'libjava/gnu/awt')
-rw-r--r-- | libjava/gnu/awt/xlib/XGraphicsConfiguration.java | 37 | ||||
-rw-r--r-- | libjava/gnu/awt/xlib/XToolkit.java | 4 |
2 files changed, 29 insertions, 12 deletions
diff --git a/libjava/gnu/awt/xlib/XGraphicsConfiguration.java b/libjava/gnu/awt/xlib/XGraphicsConfiguration.java index 9ae12d6..7d7d515 100644 --- a/libjava/gnu/awt/xlib/XGraphicsConfiguration.java +++ b/libjava/gnu/awt/xlib/XGraphicsConfiguration.java @@ -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); } } diff --git a/libjava/gnu/awt/xlib/XToolkit.java b/libjava/gnu/awt/xlib/XToolkit.java index 0c199b2..c71b39d 100644 --- a/libjava/gnu/awt/xlib/XToolkit.java +++ b/libjava/gnu/awt/xlib/XToolkit.java @@ -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() |