From 16e4b777c8391192e3cd53ba549ccc023b07409a Mon Sep 17 00:00:00 2001 From: Michael Koch Date: Thu, 19 Jun 2003 09:33:40 +0000 Subject: [PATCH] IndexColorModel.java: New version from classpath. 2003-06-19 Michael Koch * java/awt/image/IndexColorModel.java: New version from classpath. From-SVN: r68185 --- libjava/ChangeLog | 5 ++ libjava/java/awt/image/IndexColorModel.java | 88 +++++++++++++++++------------ 2 files changed, 58 insertions(+), 35 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index fc1b286..eccedbc 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2003-06-19 Michael Koch + + * java/awt/image/IndexColorModel.java: + New version from classpath. + 2003-06-18 Tom Tromey * java/net/Inet6Address.java (isAnyLocalAddress): Don't use "==" diff --git a/libjava/java/awt/image/IndexColorModel.java b/libjava/java/awt/image/IndexColorModel.java index 3e56f85..066c868 100644 --- a/libjava/java/awt/image/IndexColorModel.java +++ b/libjava/java/awt/image/IndexColorModel.java @@ -39,7 +39,6 @@ exception statement from your version. */ package java.awt.image; /** - * * @author C. Brian Jones (cbj@gnu.org) */ public class IndexColorModel extends ColorModel @@ -47,7 +46,6 @@ public class IndexColorModel extends ColorModel private int map_size; private boolean opaque; private int trans = -1; - private int[] rgb; /** @@ -63,7 +61,8 @@ public class IndexColorModel extends ColorModel * @param blues the blue component of all colors */ public IndexColorModel(int bits, int size, byte[] reds, byte[] greens, - byte[] blues) { + byte[] blues) + { this(bits, size, reds, greens, blues, (byte[])null); } @@ -81,7 +80,8 @@ public class IndexColorModel extends ColorModel * @param trans the index of the transparent color */ public IndexColorModel(int bits, int size, byte[] reds, byte[] greens, - byte[] blues, int trans) { + byte[] blues, int trans) + { this(bits, size, reds, greens, blues, (byte[])null); this.trans = trans; } @@ -100,26 +100,31 @@ public class IndexColorModel extends ColorModel * @param alphas the alpha component of all colors */ public IndexColorModel(int bits, int size, byte[] reds, byte[] greens, - byte[] blues, byte[] alphas) { + byte[] blues, byte[] alphas) + { super(bits); map_size = size; opaque = (alphas == null); rgb = new int[size]; - if (alphas == null) { - for (int i = 0; i < size; i++) { - rgb[i] = 0xff000000 | - ((reds[i] & 0xff) << 16) | - ((greens[i] & 0xff) << 8) | - (blues[i] & 0xff); + if (alphas == null) + { + for (int i = 0; i < size; i++) + { + rgb[i] = (0xff000000 + | ((reds[i] & 0xff) << 16) + | ((greens[i] & 0xff) << 8) + | (blues[i] & 0xff)); } } - else { - for (int i = 0; i < size; i++) { - rgb[i] = ((alphas[i] & 0xff) << 24 | - ((reds[i] & 0xff) << 16) | - ((greens[i] & 0xff) << 8) | - (blues[i] & 0xff)); + else + { + for (int i = 0; i < size; i++) + { + rgb[i] = ((alphas[i] & 0xff) << 24 + | ((reds[i] & 0xff) << 16) + | ((greens[i] & 0xff) << 8) + | (blues[i] & 0xff)); } } } @@ -137,7 +142,8 @@ public class IndexColorModel extends ColorModel * @param hasAlpha cmap has alpha values */ public IndexColorModel(int bits, int size, byte[] cmap, int start, - boolean hasAlpha) { + boolean hasAlpha) + { this(bits, size, cmap, start, hasAlpha, -1); } @@ -155,49 +161,56 @@ public class IndexColorModel extends ColorModel * @param trans the index of the transparent color */ public IndexColorModel(int bits, int size, byte[] cmap, int start, - boolean hasAlpha, int trans) { + boolean hasAlpha, int trans) + { super(bits); map_size = size; opaque = !hasAlpha; this.trans = trans; } - public final int getMapSize() { + public final int getMapSize () + { return map_size; } /** * Get the index of the transparent color in this color model */ - public final int getTransparentPixel() { + public final int getTransparentPixel () + { return trans; } /** *
*/ - public final void getReds(byte[] r) { + public final void getReds (byte[] r) + { getComponents( r, 2 ); } /** *
*/ - public final void getGreens(byte[] g) { + public final void getGreens (byte[] g) + { getComponents( g, 1 ); } /** *
*/ - public final void getBlues(byte[] b) { + public final void getBlues (byte[] b) + { getComponents( b, 0 ); } /** *
*/ - public final void getAlphas(byte[] a) { + public final void getAlphas (byte[] a) + { getComponents( a, 3 ); } @@ -210,54 +223,59 @@ public class IndexColorModel extends ColorModel /** * Get the red component of the given pixel. - *
*/ - public final int getRed(int pixel) { + public final int getRed (int pixel) + { if( pixel < map_size ) return (int)(( generateMask( 2 ) & rgb[pixel]) >> (2 * pixel_bits ) ); + return 0; } /** * Get the green component of the given pixel. - *
*/ - public final int getGreen(int pixel) { + public final int getGreen (int pixel) + { if( pixel < map_size ) return (int)(( generateMask( 1 ) & rgb[pixel]) >> (1 * pixel_bits ) ); + return 0; } /** * Get the blue component of the given pixel. - *
*/ - public final int getBlue(int pixel) { + public final int getBlue (int pixel) + { if( pixel < map_size ) return (int)( generateMask( 0 ) & rgb[pixel]); + return 0; } /** * Get the alpha component of the given pixel. - *
*/ - public final int getAlpha(int pixel) { + public final int getAlpha (int pixel) + { if( pixel < map_size ) return (int)(( generateMask( 3 ) & rgb[pixel]) >> (3 * pixel_bits ) ); + return 0; } /** * Get the RGB color value of the given pixel using the default * RGB color model. - *
* * @param pixel a pixel value */ - public final int getRGB(int pixel) { + public final int getRGB (int pixel) + { if( pixel < map_size ) return rgb[pixel]; + return 0; } -- 2.7.4