Commit 16e4b777 by Michael Koch Committed by Michael Koch

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
parent 85009435
2003-06-19 Michael Koch <konqueror@gmx.de>
* java/awt/image/IndexColorModel.java:
New version from classpath.
2003-06-18 Tom Tromey <tromey@redhat.com> 2003-06-18 Tom Tromey <tromey@redhat.com>
* java/net/Inet6Address.java (isAnyLocalAddress): Don't use "==" * java/net/Inet6Address.java (isAnyLocalAddress): Don't use "=="
......
...@@ -39,7 +39,6 @@ exception statement from your version. */ ...@@ -39,7 +39,6 @@ exception statement from your version. */
package java.awt.image; package java.awt.image;
/** /**
*
* @author C. Brian Jones (cbj@gnu.org) * @author C. Brian Jones (cbj@gnu.org)
*/ */
public class IndexColorModel extends ColorModel public class IndexColorModel extends ColorModel
...@@ -47,7 +46,6 @@ public class IndexColorModel extends ColorModel ...@@ -47,7 +46,6 @@ public class IndexColorModel extends ColorModel
private int map_size; private int map_size;
private boolean opaque; private boolean opaque;
private int trans = -1; private int trans = -1;
private int[] rgb; private int[] rgb;
/** /**
...@@ -63,7 +61,8 @@ public class IndexColorModel extends ColorModel ...@@ -63,7 +61,8 @@ public class IndexColorModel extends ColorModel
* @param blues the blue component of all colors * @param blues the blue component of all colors
*/ */
public IndexColorModel(int bits, int size, byte[] reds, byte[] greens, public IndexColorModel(int bits, int size, byte[] reds, byte[] greens,
byte[] blues) { byte[] blues)
{
this(bits, size, reds, greens, blues, (byte[])null); this(bits, size, reds, greens, blues, (byte[])null);
} }
...@@ -81,7 +80,8 @@ public class IndexColorModel extends ColorModel ...@@ -81,7 +80,8 @@ public class IndexColorModel extends ColorModel
* @param trans the index of the transparent color * @param trans the index of the transparent color
*/ */
public IndexColorModel(int bits, int size, byte[] reds, byte[] greens, 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(bits, size, reds, greens, blues, (byte[])null);
this.trans = trans; this.trans = trans;
} }
...@@ -100,26 +100,31 @@ public class IndexColorModel extends ColorModel ...@@ -100,26 +100,31 @@ public class IndexColorModel extends ColorModel
* @param alphas the alpha component of all colors * @param alphas the alpha component of all colors
*/ */
public IndexColorModel(int bits, int size, byte[] reds, byte[] greens, public IndexColorModel(int bits, int size, byte[] reds, byte[] greens,
byte[] blues, byte[] alphas) { byte[] blues, byte[] alphas)
{
super(bits); super(bits);
map_size = size; map_size = size;
opaque = (alphas == null); opaque = (alphas == null);
rgb = new int[size]; rgb = new int[size];
if (alphas == null) { if (alphas == null)
for (int i = 0; i < size; i++) { {
rgb[i] = 0xff000000 | for (int i = 0; i < size; i++)
((reds[i] & 0xff) << 16) | {
((greens[i] & 0xff) << 8) | rgb[i] = (0xff000000
(blues[i] & 0xff); | ((reds[i] & 0xff) << 16)
| ((greens[i] & 0xff) << 8)
| (blues[i] & 0xff));
} }
} }
else { else
for (int i = 0; i < size; i++) { {
rgb[i] = ((alphas[i] & 0xff) << 24 | for (int i = 0; i < size; i++)
((reds[i] & 0xff) << 16) | {
((greens[i] & 0xff) << 8) | rgb[i] = ((alphas[i] & 0xff) << 24
(blues[i] & 0xff)); | ((reds[i] & 0xff) << 16)
| ((greens[i] & 0xff) << 8)
| (blues[i] & 0xff));
} }
} }
} }
...@@ -137,7 +142,8 @@ public class IndexColorModel extends ColorModel ...@@ -137,7 +142,8 @@ public class IndexColorModel extends ColorModel
* @param hasAlpha <code>cmap</code> has alpha values * @param hasAlpha <code>cmap</code> has alpha values
*/ */
public IndexColorModel(int bits, int size, byte[] cmap, int start, public IndexColorModel(int bits, int size, byte[] cmap, int start,
boolean hasAlpha) { boolean hasAlpha)
{
this(bits, size, cmap, start, hasAlpha, -1); this(bits, size, cmap, start, hasAlpha, -1);
} }
...@@ -155,49 +161,56 @@ public class IndexColorModel extends ColorModel ...@@ -155,49 +161,56 @@ public class IndexColorModel extends ColorModel
* @param trans the index of the transparent color * @param trans the index of the transparent color
*/ */
public IndexColorModel(int bits, int size, byte[] cmap, int start, public IndexColorModel(int bits, int size, byte[] cmap, int start,
boolean hasAlpha, int trans) { boolean hasAlpha, int trans)
{
super(bits); super(bits);
map_size = size; map_size = size;
opaque = !hasAlpha; opaque = !hasAlpha;
this.trans = trans; this.trans = trans;
} }
public final int getMapSize() { public final int getMapSize ()
{
return map_size; return map_size;
} }
/** /**
* Get the index of the transparent color in this color model * Get the index of the transparent color in this color model
*/ */
public final int getTransparentPixel() { public final int getTransparentPixel ()
{
return trans; return trans;
} }
/** /**
* <br> * <br>
*/ */
public final void getReds(byte[] r) { public final void getReds (byte[] r)
{
getComponents( r, 2 ); getComponents( r, 2 );
} }
/** /**
* <br> * <br>
*/ */
public final void getGreens(byte[] g) { public final void getGreens (byte[] g)
{
getComponents( g, 1 ); getComponents( g, 1 );
} }
/** /**
* <br> * <br>
*/ */
public final void getBlues(byte[] b) { public final void getBlues (byte[] b)
{
getComponents( b, 0 ); getComponents( b, 0 );
} }
/** /**
* <br> * <br>
*/ */
public final void getAlphas(byte[] a) { public final void getAlphas (byte[] a)
{
getComponents( a, 3 ); getComponents( a, 3 );
} }
...@@ -210,54 +223,59 @@ public class IndexColorModel extends ColorModel ...@@ -210,54 +223,59 @@ public class IndexColorModel extends ColorModel
/** /**
* Get the red component of the given pixel. * 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 ) if( pixel < map_size )
return (int)(( generateMask( 2 ) & rgb[pixel]) >> (2 * pixel_bits ) ); return (int)(( generateMask( 2 ) & rgb[pixel]) >> (2 * pixel_bits ) );
return 0; return 0;
} }
/** /**
* Get the green component of the given pixel. * 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 ) if( pixel < map_size )
return (int)(( generateMask( 1 ) & rgb[pixel]) >> (1 * pixel_bits ) ); return (int)(( generateMask( 1 ) & rgb[pixel]) >> (1 * pixel_bits ) );
return 0; return 0;
} }
/** /**
* Get the blue component of the given pixel. * 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 ) if( pixel < map_size )
return (int)( generateMask( 0 ) & rgb[pixel]); return (int)( generateMask( 0 ) & rgb[pixel]);
return 0; return 0;
} }
/** /**
* Get the alpha component of the given pixel. * 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 ) if( pixel < map_size )
return (int)(( generateMask( 3 ) & rgb[pixel]) >> (3 * pixel_bits ) ); return (int)(( generateMask( 3 ) & rgb[pixel]) >> (3 * pixel_bits ) );
return 0; return 0;
} }
/** /**
* Get the RGB color value of the given pixel using the default * Get the RGB color value of the given pixel using the default
* RGB color model. * RGB color model.
* <br>
* *
* @param pixel a pixel value * @param pixel a pixel value
*/ */
public final int getRGB(int pixel) { public final int getRGB (int pixel)
{
if( pixel < map_size ) if( pixel < map_size )
return rgb[pixel]; return rgb[pixel];
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment