OSDN Git Service

2003-06-19 Michael Koch <konqueror@gmx.de>
authormkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 19 Jun 2003 09:33:40 +0000 (09:33 +0000)
committermkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 19 Jun 2003 09:33:40 +0000 (09:33 +0000)
* java/awt/image/IndexColorModel.java:
New version from classpath.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@68185 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/java/awt/image/IndexColorModel.java

index fc1b286..eccedbc 100644 (file)
@@ -1,3 +1,8 @@
+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>
 
        * java/net/Inet6Address.java (isAnyLocalAddress): Don't use "=="
index 3e56f85..066c868 100644 (file)
@@ -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;
     }