mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-25 14:21:00 +08:00
IndexColorModel.java: Reformated.
2003-09-29 Michael Koch <konqueror@gmx.de> * java/awt/image/IndexColorModel.java: Reformated. From-SVN: r71898
This commit is contained in:
parent
7da1da8352
commit
3887819542
@ -1,3 +1,7 @@
|
|||||||
|
2003-09-29 Michael Koch <konqueror@gmx.de>
|
||||||
|
|
||||||
|
* java/awt/image/IndexColorModel.java: Reformated.
|
||||||
|
|
||||||
2003-09-29 Michael Koch <konqueror@gmx.de>
|
2003-09-29 Michael Koch <konqueror@gmx.de>
|
||||||
|
|
||||||
* java/net/InetAddress.java,
|
* java/net/InetAddress.java,
|
||||||
|
@ -43,70 +43,70 @@ package java.awt.image;
|
|||||||
*/
|
*/
|
||||||
public class IndexColorModel extends ColorModel
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Each array much contain <code>size</code> elements. For each
|
* Each array much contain <code>size</code> elements. For each
|
||||||
* array, the i-th color is described by reds[i], greens[i],
|
* array, the i-th color is described by reds[i], greens[i],
|
||||||
* blues[i], alphas[i], unless alphas is not specified, then all the
|
* blues[i], alphas[i], unless alphas is not specified, then all the
|
||||||
* colors are opaque except for the transparent color.
|
* colors are opaque except for the transparent color.
|
||||||
*
|
*
|
||||||
* @param bits the number of bits needed to represent <code>size</code> colors
|
* @param bits the number of bits needed to represent <code>size</code> colors
|
||||||
* @param size the number of colors in the color map
|
* @param size the number of colors in the color map
|
||||||
* @param reds the red component of all colors
|
* @param reds the red component of all colors
|
||||||
* @param greens the green component of all colors
|
* @param greens the green component of all colors
|
||||||
* @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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Each array much contain <code>size</code> elements. For each
|
* Each array much contain <code>size</code> elements. For each
|
||||||
* array, the i-th color is described by reds[i], greens[i],
|
* array, the i-th color is described by reds[i], greens[i],
|
||||||
* blues[i], alphas[i], unless alphas is not specified, then all the
|
* blues[i], alphas[i], unless alphas is not specified, then all the
|
||||||
* colors are opaque except for the transparent color.
|
* colors are opaque except for the transparent color.
|
||||||
*
|
*
|
||||||
* @param bits the number of bits needed to represent <code>size</code> colors
|
* @param bits the number of bits needed to represent <code>size</code> colors
|
||||||
* @param size the number of colors in the color map
|
* @param size the number of colors in the color map
|
||||||
* @param reds the red component of all colors
|
* @param reds the red component of all colors
|
||||||
* @param greens the green component of all colors
|
* @param greens the green component of all colors
|
||||||
* @param blues the blue component of all colors
|
* @param blues the blue component of all colors
|
||||||
* @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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Each array much contain <code>size</code> elements. For each
|
* Each array much contain <code>size</code> elements. For each
|
||||||
* array, the i-th color is described by reds[i], greens[i],
|
* array, the i-th color is described by reds[i], greens[i],
|
||||||
* blues[i], alphas[i], unless alphas is not specified, then all the
|
* blues[i], alphas[i], unless alphas is not specified, then all the
|
||||||
* colors are opaque except for the transparent color.
|
* colors are opaque except for the transparent color.
|
||||||
*
|
*
|
||||||
* @param bits the number of bits needed to represent <code>size</code> colors
|
* @param bits the number of bits needed to represent <code>size</code> colors
|
||||||
* @param size the number of colors in the color map
|
* @param size the number of colors in the color map
|
||||||
* @param reds the red component of all colors
|
* @param reds the red component of all colors
|
||||||
* @param greens the green component of all colors
|
* @param greens the green component of all colors
|
||||||
* @param blues the blue component of all colors
|
* @param blues the blue component of all colors
|
||||||
* @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++)
|
for (int i = 0; i < size; i++)
|
||||||
@ -115,8 +115,8 @@ public class IndexColorModel extends ColorModel
|
|||||||
| ((reds[i] & 0xff) << 16)
|
| ((reds[i] & 0xff) << 16)
|
||||||
| ((greens[i] & 0xff) << 8)
|
| ((greens[i] & 0xff) << 8)
|
||||||
| (blues[i] & 0xff));
|
| (blues[i] & 0xff));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i = 0; i < size; i++)
|
for (int i = 0; i < size; i++)
|
||||||
@ -125,165 +125,165 @@ public class IndexColorModel extends ColorModel
|
|||||||
| ((reds[i] & 0xff) << 16)
|
| ((reds[i] & 0xff) << 16)
|
||||||
| ((greens[i] & 0xff) << 8)
|
| ((greens[i] & 0xff) << 8)
|
||||||
| (blues[i] & 0xff));
|
| (blues[i] & 0xff));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Each array much contain <code>size</code> elements. For each
|
* Each array much contain <code>size</code> elements. For each
|
||||||
* array, the i-th color is described by reds[i], greens[i],
|
* array, the i-th color is described by reds[i], greens[i],
|
||||||
* blues[i], alphas[i], unless alphas is not specified, then all the
|
* blues[i], alphas[i], unless alphas is not specified, then all the
|
||||||
* colors are opaque except for the transparent color.
|
* colors are opaque except for the transparent color.
|
||||||
*
|
*
|
||||||
* @param bits the number of bits needed to represent <code>size</code> colors
|
* @param bits the number of bits needed to represent <code>size</code> colors
|
||||||
* @param size the number of colors in the color map
|
* @param size the number of colors in the color map
|
||||||
* @param cmap packed color components
|
* @param cmap packed color components
|
||||||
* @param start the offset of the first color component in <code>cmap</code>
|
* @param start the offset of the first color component in <code>cmap</code>
|
||||||
* @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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Each array much contain <code>size</code> elements. For each
|
* Each array much contain <code>size</code> elements. For each
|
||||||
* array, the i-th color is described by reds[i], greens[i],
|
* array, the i-th color is described by reds[i], greens[i],
|
||||||
* blues[i], alphas[i], unless alphas is not specified, then all the
|
* blues[i], alphas[i], unless alphas is not specified, then all the
|
||||||
* colors are opaque except for the transparent color.
|
* colors are opaque except for the transparent color.
|
||||||
*
|
*
|
||||||
* @param bits the number of bits needed to represent <code>size</code> colors
|
* @param bits the number of bits needed to represent <code>size</code> colors
|
||||||
* @param size the number of colors in the color map
|
* @param size the number of colors in the color map
|
||||||
* @param cmap packed color components
|
* @param cmap packed color components
|
||||||
* @param start the offset of the first color component in <code>cmap</code>
|
* @param start the offset of the first color component in <code>cmap</code>
|
||||||
* @param hasAlpha <code>cmap</code> has alpha values
|
* @param hasAlpha <code>cmap</code> has alpha values
|
||||||
* @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);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getComponents( byte[] c, int ci )
|
private void getComponents (byte[] c, int ci)
|
||||||
{
|
{
|
||||||
int i, max = ( map_size < c.length ) ? map_size : c.length;
|
int i, max = (map_size < c.length) ? map_size : c.length;
|
||||||
for( i = 0; i < max; i++ )
|
for (i = 0; i < max; i++)
|
||||||
c[i] = (byte)(( generateMask( ci ) & rgb[i]) >> ( ci * pixel_bits) );
|
c[i] = (byte) ((generateMask (ci) & rgb[i]) >> (ci * pixel_bits));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the red component of the given pixel.
|
* Get the red component of the given pixel.
|
||||||
*/
|
*/
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
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.
|
||||||
*
|
*
|
||||||
* @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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//pixel_bits is number of bits to be in generated mask
|
//pixel_bits is number of bits to be in generated mask
|
||||||
private int generateMask( int offset )
|
private int generateMask (int offset)
|
||||||
{
|
{
|
||||||
return ( ( ( 2 << pixel_bits ) - 1 ) << ( pixel_bits * offset ) );
|
return (((2 << pixel_bits ) - 1) << (pixel_bits * offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user