aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/awt/image
diff options
context:
space:
mode:
authorMichael Koch <konqueror@gmx.de>2003-06-19 09:33:40 +0000
committerMichael Koch <mkoch@gcc.gnu.org>2003-06-19 09:33:40 +0000
commit16e4b777c8391192e3cd53ba549ccc023b07409a (patch)
tree163729db2d8c841d5f6b5921e761de3dccea8302 /libjava/java/awt/image
parent85009435975dee67ed981ecb0955e7d6499dbe6a (diff)
downloadgcc-16e4b777c8391192e3cd53ba549ccc023b07409a.zip
gcc-16e4b777c8391192e3cd53ba549ccc023b07409a.tar.gz
gcc-16e4b777c8391192e3cd53ba549ccc023b07409a.tar.bz2
IndexColorModel.java: New version from classpath.
2003-06-19 Michael Koch <konqueror@gmx.de> * java/awt/image/IndexColorModel.java: New version from classpath. From-SVN: r68185
Diffstat (limited to 'libjava/java/awt/image')
-rw-r--r--libjava/java/awt/image/IndexColorModel.java88
1 files changed, 53 insertions, 35 deletions
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 <code>cmap</code> 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;
}
/**
* <br>
*/
- public final void getReds(byte[] r) {
+ public final void getReds (byte[] r)
+ {
getComponents( r, 2 );
}
/**
* <br>
*/
- public final void getGreens(byte[] g) {
+ public final void getGreens (byte[] g)
+ {
getComponents( g, 1 );
}
/**
* <br>
*/
- public final void getBlues(byte[] b) {
+ public final void getBlues (byte[] b)
+ {
getComponents( b, 0 );
}
/**
* <br>
*/
- 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.
- * <br>
*/
- 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.
- * <br>
*/
- 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.
- * <br>
*/
- 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.
- * <br>
*/
- 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.
- * <br>
*
* @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;
}