< prev index next >

src/java.desktop/share/classes/java/awt/image/DirectColorModel.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -309,12 +309,12 @@
      * Given an int pixel in this ColorModel's ColorSpace, converts
      * it to the default sRGB ColorSpace and returns the R, G, and B
      * components as float values between 0.0 and 1.0.
      */
     private float[] getDefaultRGBComponents(int pixel) {
-        int components[] = getComponents(pixel, null, 0);
-        float norm[] = getNormalizedComponents(components, 0, null, 0);
+        int[] components = getComponents(pixel, null, 0);
+        float[] norm = getNormalizedComponents(components, 0, null, 0);
         // Note that getNormalizedComponents returns non-premultiplied values
         return colorSpace.toRGB(norm);
     }
 
 

@@ -369,11 +369,11 @@
         if (is_sRGB) {
             return getsRGBComponentFromsRGB(pixel, 0);
         } else if (is_LinearRGB) {
             return getsRGBComponentFromLinearRGB(pixel, 0);
         }
-        float rgb[] = getDefaultRGBComponents(pixel);
+        float[] rgb = getDefaultRGBComponents(pixel);
         return (int) (rgb[0] * 255.0f + 0.5f);
     }
 
     /**
      * Returns the green color component for the specified pixel, scaled

@@ -392,11 +392,11 @@
         if (is_sRGB) {
             return getsRGBComponentFromsRGB(pixel, 1);
         } else if (is_LinearRGB) {
             return getsRGBComponentFromLinearRGB(pixel, 1);
         }
-        float rgb[] = getDefaultRGBComponents(pixel);
+        float[] rgb = getDefaultRGBComponents(pixel);
         return (int) (rgb[1] * 255.0f + 0.5f);
     }
 
     /**
      * Returns the blue color component for the specified pixel, scaled

@@ -415,11 +415,11 @@
         if (is_sRGB) {
             return getsRGBComponentFromsRGB(pixel, 2);
         } else if (is_LinearRGB) {
             return getsRGBComponentFromLinearRGB(pixel, 2);
         }
-        float rgb[] = getDefaultRGBComponents(pixel);
+        float[] rgb = getDefaultRGBComponents(pixel);
         return (int) (rgb[2] * 255.0f + 0.5f);
     }
 
     /**
      * Returns the alpha component for the specified pixel, scaled

@@ -455,11 +455,11 @@
             return (getAlpha(pixel) << 24)
                 | (getRed(pixel) << 16)
                 | (getGreen(pixel) << 8)
                 | (getBlue(pixel) << 0);
         }
-        float rgb[] = getDefaultRGBComponents(pixel);
+        float[] rgb = getDefaultRGBComponents(pixel);
         return (getAlpha(pixel) << 24)
             | (((int) (rgb[0] * 255.0f + 0.5f)) << 16)
             | (((int) (rgb[1] * 255.0f + 0.5f)) << 8)
             | (((int) (rgb[2] * 255.0f + 0.5f)) << 0);
     }

@@ -497,19 +497,19 @@
      */
     public int getRed(Object inData) {
         int pixel=0;
         switch (transferType) {
             case DataBuffer.TYPE_BYTE:
-               byte bdata[] = (byte[])inData;
+               byte[] bdata = (byte[])inData;
                pixel = bdata[0] & 0xff;
             break;
             case DataBuffer.TYPE_USHORT:
-               short sdata[] = (short[])inData;
+               short[] sdata = (short[])inData;
                pixel = sdata[0] & 0xffff;
             break;
             case DataBuffer.TYPE_INT:
-               int idata[] = (int[])inData;
+               int[] idata = (int[])inData;
                pixel = idata[0];
             break;
             default:
                throw new UnsupportedOperationException("This method has not been "+
                    "implemented for transferType " + transferType);

@@ -550,19 +550,19 @@
      */
     public int getGreen(Object inData) {
         int pixel=0;
         switch (transferType) {
             case DataBuffer.TYPE_BYTE:
-               byte bdata[] = (byte[])inData;
+               byte[] bdata = (byte[])inData;
                pixel = bdata[0] & 0xff;
             break;
             case DataBuffer.TYPE_USHORT:
-               short sdata[] = (short[])inData;
+               short[] sdata = (short[])inData;
                pixel = sdata[0] & 0xffff;
             break;
             case DataBuffer.TYPE_INT:
-               int idata[] = (int[])inData;
+               int[] idata = (int[])inData;
                pixel = idata[0];
             break;
             default:
                throw new UnsupportedOperationException("This method has not been "+
                    "implemented for transferType " + transferType);

@@ -603,19 +603,19 @@
      */
     public int getBlue(Object inData) {
         int pixel=0;
         switch (transferType) {
             case DataBuffer.TYPE_BYTE:
-               byte bdata[] = (byte[])inData;
+               byte[] bdata = (byte[])inData;
                pixel = bdata[0] & 0xff;
             break;
             case DataBuffer.TYPE_USHORT:
-               short sdata[] = (short[])inData;
+               short[] sdata = (short[])inData;
                pixel = sdata[0] & 0xffff;
             break;
             case DataBuffer.TYPE_INT:
-               int idata[] = (int[])inData;
+               int[] idata = (int[])inData;
                pixel = idata[0];
             break;
             default:
                throw new UnsupportedOperationException("This method has not been "+
                    "implemented for transferType " + transferType);

@@ -653,19 +653,19 @@
      */
     public int getAlpha(Object inData) {
         int pixel=0;
         switch (transferType) {
             case DataBuffer.TYPE_BYTE:
-               byte bdata[] = (byte[])inData;
+               byte[] bdata = (byte[])inData;
                pixel = bdata[0] & 0xff;
             break;
             case DataBuffer.TYPE_USHORT:
-               short sdata[] = (short[])inData;
+               short[] sdata = (short[])inData;
                pixel = sdata[0] & 0xffff;
             break;
             case DataBuffer.TYPE_INT:
-               int idata[] = (int[])inData;
+               int[] idata = (int[])inData;
                pixel = idata[0];
             break;
             default:
                throw new UnsupportedOperationException("This method has not been "+
                    "implemented for transferType " + transferType);

@@ -701,19 +701,19 @@
      */
     public int getRGB(Object inData) {
         int pixel=0;
         switch (transferType) {
             case DataBuffer.TYPE_BYTE:
-               byte bdata[] = (byte[])inData;
+               byte[] bdata = (byte[])inData;
                pixel = bdata[0] & 0xff;
             break;
             case DataBuffer.TYPE_USHORT:
-               short sdata[] = (short[])inData;
+               short[] sdata = (short[])inData;
                pixel = sdata[0] & 0xffff;
             break;
             case DataBuffer.TYPE_INT:
-               int idata[] = (int[])inData;
+               int[] idata = (int[])inData;
                pixel = idata[0];
             break;
             default:
                throw new UnsupportedOperationException("This method has not been "+
                    "implemented for transferType " + transferType);

@@ -756,11 +756,11 @@
      * @see SampleModel#setDataElements
      */
     public Object getDataElements(int rgb, Object pixel) {
         //REMIND: maybe more efficient not to use int array for
         //DataBuffer.TYPE_USHORT and DataBuffer.TYPE_INT
-        int intpixel[] = null;
+        int[] intpixel = null;
         if (transferType == DataBuffer.TYPE_INT &&
             pixel != null) {
             intpixel = (int[])pixel;
             intpixel[0] = 0;
         } else {

@@ -874,21 +874,21 @@
                        (grn << maskOffsets[1]) |
                        (blu << maskOffsets[2]);
 
         switch (transferType) {
             case DataBuffer.TYPE_BYTE: {
-               byte bdata[];
+               byte[] bdata;
                if (pixel == null) {
                    bdata = new byte[1];
                } else {
                    bdata = (byte[])pixel;
                }
                bdata[0] = (byte)(0xff&intpixel[0]);
                return bdata;
             }
             case DataBuffer.TYPE_USHORT:{
-               short sdata[];
+               short[] sdata;
                if (pixel == null) {
                    sdata = new short[1];
                } else {
                    sdata = (short[])pixel;
                }

@@ -977,19 +977,19 @@
     public final int[] getComponents(Object pixel, int[] components,
                                      int offset) {
         int intpixel=0;
         switch (transferType) {
             case DataBuffer.TYPE_BYTE:
-               byte bdata[] = (byte[])pixel;
+               byte[] bdata = (byte[])pixel;
                intpixel = bdata[0] & 0xff;
             break;
             case DataBuffer.TYPE_USHORT:
-               short sdata[] = (short[])pixel;
+               short[] sdata = (short[])pixel;
                intpixel = sdata[0] & 0xffff;
             break;
             case DataBuffer.TYPE_INT:
-               int idata[] = (int[])pixel;
+               int[] idata = (int[])pixel;
                intpixel = idata[0];
             break;
             default:
                throw new UnsupportedOperationException("This method has not been "+
                    "implemented for transferType " + transferType);

@@ -1116,33 +1116,33 @@
             pixel |= ((components[offset+i]<<maskOffsets[i])&maskArray[i]);
         }
         switch (transferType) {
             case DataBuffer.TYPE_BYTE:
                if (obj instanceof byte[]) {
-                   byte bdata[] = (byte[])obj;
+                   byte[] bdata = (byte[])obj;
                    bdata[0] = (byte)(pixel&0xff);
                    return bdata;
                } else {
-                   byte bdata[] = {(byte)(pixel&0xff)};
+                   byte[] bdata = {(byte)(pixel&0xff)};
                    return bdata;
                }
             case DataBuffer.TYPE_USHORT:
                if (obj instanceof short[]) {
-                   short sdata[] = (short[])obj;
+                   short[] sdata = (short[])obj;
                    sdata[0] = (short)(pixel&0xffff);
                    return sdata;
                } else {
-                   short sdata[] = {(short)(pixel&0xffff)};
+                   short[] sdata = {(short)(pixel&0xffff)};
                    return sdata;
                }
             case DataBuffer.TYPE_INT:
                if (obj instanceof int[]) {
-                   int idata[] = (int[])obj;
+                   int[] idata = (int[])obj;
                    idata[0] = pixel;
                    return idata;
                } else {
-                   int idata[] = {pixel};
+                   int[] idata = {pixel};
                    return idata;
                }
             default:
                throw new ClassCastException("This method has not been "+
                    "implemented for transferType " + transferType);

@@ -1188,12 +1188,12 @@
         float alphaScale = 1.0f / ((float) ((1 << nBits[aIdx]) - 1));
 
         int rminX = raster.getMinX();
         int rY = raster.getMinY();
         int rX;
-        int pixel[] = null;
-        int zpixel[] = null;
+        int[] pixel = null;
+        int[] zpixel = null;
 
         if (isAlphaPremultiplied) {
             // Must mean that we are currently not premultiplied so
             // multiply by alpha
             switch (transferType) {
< prev index next >