< prev index next >
src/java.desktop/share/classes/java/awt/image/ComponentColorModel.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -800,11 +800,11 @@
switch (transferType) {
// Note: we do no clamping of the pixel data here - we
// assume that the data is scaled properly
case DataBuffer.TYPE_SHORT: {
- short sdata[] = (short[]) inData;
+ short[] sdata = (short[]) inData;
float scalefactor = (float) ((1 << precision) - 1);
if (needAlpha) {
short s = sdata[numColorComponents];
if (s != (short) 0) {
return (int) ((((float) sdata[idx]) /
@@ -815,11 +815,11 @@
} else {
return (int) ((sdata[idx] / 32767.0f) * scalefactor + 0.5f);
}
}
case DataBuffer.TYPE_FLOAT: {
- float fdata[] = (float[]) inData;
+ float[] fdata = (float[]) inData;
float scalefactor = (float) ((1 << precision) - 1);
if (needAlpha) {
float f = fdata[numColorComponents];
if (f != 0.0f) {
return (int) (((fdata[idx] / f) * scalefactor) + 0.5f);
@@ -829,11 +829,11 @@
} else {
return (int) (fdata[idx] * scalefactor + 0.5f);
}
}
case DataBuffer.TYPE_DOUBLE: {
- double ddata[] = (double[]) inData;
+ double[] ddata = (double[]) inData;
double scalefactor = (double) ((1 << precision) - 1);
if (needAlpha) {
double d = ddata[numColorComponents];
if (d != 0.0) {
return (int) (((ddata[idx] / d) * scalefactor) + 0.5);
@@ -843,26 +843,26 @@
} else {
return (int) (ddata[idx] * scalefactor + 0.5);
}
}
case DataBuffer.TYPE_BYTE:
- byte bdata[] = (byte[])inData;
+ byte[] bdata = (byte[])inData;
comp = bdata[idx] & mask;
precision = 8;
if (needAlpha) {
alp = bdata[numColorComponents] & mask;
}
break;
case DataBuffer.TYPE_USHORT:
- short usdata[] = (short[])inData;
+ short[] usdata = (short[])inData;
comp = usdata[idx] & mask;
if (needAlpha) {
alp = usdata[numColorComponents] & mask;
}
break;
case DataBuffer.TYPE_INT:
- int idata[] = (int[])inData;
+ int[] idata = (int[])inData;
comp = idata[idx];
if (needAlpha) {
alp = idata[numColorComponents];
}
break;
@@ -1052,31 +1052,31 @@
int aIdx = numColorComponents;
int mask = (1 << nBits[aIdx]) - 1;
switch (transferType) {
case DataBuffer.TYPE_SHORT:
- short sdata[] = (short[])inData;
+ short[] sdata = (short[])inData;
alpha = (int) ((sdata[aIdx] / 32767.0f) * 255.0f + 0.5f);
return alpha;
case DataBuffer.TYPE_FLOAT:
- float fdata[] = (float[])inData;
+ float[] fdata = (float[])inData;
alpha = (int) (fdata[aIdx] * 255.0f + 0.5f);
return alpha;
case DataBuffer.TYPE_DOUBLE:
- double ddata[] = (double[])inData;
+ double[] ddata = (double[])inData;
alpha = (int) (ddata[aIdx] * 255.0 + 0.5);
return alpha;
case DataBuffer.TYPE_BYTE:
- byte bdata[] = (byte[])inData;
+ byte[] bdata = (byte[])inData;
alpha = bdata[aIdx] & mask;
break;
case DataBuffer.TYPE_USHORT:
- short usdata[] = (short[])inData;
+ short[] usdata = (short[])inData;
alpha = usdata[aIdx] & mask;
break;
case DataBuffer.TYPE_INT:
- int idata[] = (int[])inData;
+ int[] idata = (int[])inData;
alpha = idata[aIdx];
break;
default:
throw new
UnsupportedOperationException("This method has not "+
@@ -1199,11 +1199,11 @@
// Handle SHORT, FLOAT, & DOUBLE here
switch(transferType) {
case DataBuffer.TYPE_SHORT:
{
- short sdata[];
+ short[] sdata;
if (pixel == null) {
sdata = new short[numComponents];
} else {
sdata = (short[])pixel;
}
@@ -1262,11 +1262,11 @@
}
}
sdata[0] = (short) (gray * factor + 0.5f);
} else {
factor = 1.0f / 255.0f;
- float norm[] = new float[3];
+ float[] norm = new float[3];
norm[0] = red * factor;
norm[1] = grn * factor;
norm[2] = blu * factor;
norm = colorSpace.fromRGB(norm);
if (nonStdScale) {
@@ -1298,11 +1298,11 @@
}
return sdata;
}
case DataBuffer.TYPE_FLOAT:
{
- float fdata[];
+ float[] fdata;
if (pixel == null) {
fdata = new float[numComponents];
} else {
fdata = (float[])pixel;
}
@@ -1355,11 +1355,11 @@
if (isAlphaPremultiplied) {
fdata[0] *= fdata[1];
}
}
} else {
- float norm[] = new float[3];
+ float[] norm = new float[3];
factor = 1.0f / 255.0f;
norm[0] = red * factor;
norm[1] = grn * factor;
norm[2] = blu * factor;
norm = colorSpace.fromRGB(norm);
@@ -1379,11 +1379,11 @@
}
return fdata;
}
case DataBuffer.TYPE_DOUBLE:
{
- double ddata[];
+ double[] ddata;
if (pixel == null) {
ddata = new double[numComponents];
} else {
ddata = (double[])pixel;
}
@@ -1437,11 +1437,11 @@
ddata[0] *= ddata[1];
}
}
} else {
float factor = 1.0f / 255.0f;
- float norm[] = new float[3];
+ float[] norm = new float[3];
norm[0] = red * factor;
norm[1] = grn * factor;
norm[2] = blu * factor;
norm = colorSpace.fromRGB(norm);
if (supportsAlpha) {
@@ -1464,11 +1464,11 @@
}
// Handle BYTE, USHORT, & INT here
//REMIND: maybe more efficient not to use int array for
//DataBuffer.TYPE_USHORT and DataBuffer.TYPE_INT
- int intpixel[];
+ int[] intpixel;
if (transferType == DataBuffer.TYPE_INT &&
pixel != null) {
intpixel = (int[])pixel;
} else {
intpixel = new int[numComponents];
@@ -1613,11 +1613,11 @@
}
}
switch (transferType) {
case DataBuffer.TYPE_BYTE: {
- byte bdata[];
+ byte[] bdata;
if (pixel == null) {
bdata = new byte[numComponents];
} else {
bdata = (byte[])pixel;
}
@@ -1625,11 +1625,11 @@
bdata[i] = (byte)(0xff&intpixel[i]);
}
return bdata;
}
case DataBuffer.TYPE_USHORT:{
- short sdata[];
+ short[] sdata;
if (pixel == null) {
sdata = new short[numComponents];
} else {
sdata = (short[])pixel;
}
@@ -1739,11 +1739,11 @@
* not null and is not large enough to hold all the color and alpha
* components (starting at offset), or if {@code pixel} is not large
* enough to hold a pixel value for this ColorModel.
*/
public int[] getComponents(Object pixel, int[] components, int offset) {
- int intpixel[];
+ int[] intpixel;
if (needScaleInit) {
initScale();
}
if (noUnnorm) {
throw new
@@ -2055,11 +2055,11 @@
}
Object pixel = getDataElements(normComponents, normOffset, null);
switch (transferType) {
case DataBuffer.TYPE_BYTE:
{
- byte bpixel[] = (byte[]) pixel;
+ byte[] bpixel = (byte[]) pixel;
return bpixel[0] & 0xff;
}
case DataBuffer.TYPE_USHORT:
{
short[] uspixel = (short[]) pixel;
@@ -2466,12 +2466,12 @@
int rY = raster.getMinY();
int rX;
if (isAlphaPremultiplied) {
switch (transferType) {
case DataBuffer.TYPE_BYTE: {
- byte pixel[] = null;
- byte zpixel[] = null;
+ byte[] pixel = null;
+ byte[] zpixel = null;
float alphaScale = 1.0f / ((float) ((1<<nBits[aIdx]) - 1));
for (int y = 0; y < h; y++, rY++) {
rX = rminX;
for (int x = 0; x < w; x++, rX++) {
pixel = (byte[])raster.getDataElements(rX, rY,
@@ -2493,12 +2493,12 @@
}
}
}
break;
case DataBuffer.TYPE_USHORT: {
- short pixel[] = null;
- short zpixel[] = null;
+ short[] pixel = null;
+ short[] zpixel = null;
float alphaScale = 1.0f / ((float) ((1<<nBits[aIdx]) - 1));
for (int y = 0; y < h; y++, rY++) {
rX = rminX;
for (int x = 0; x < w; x++, rX++) {
pixel = (short[])raster.getDataElements(rX, rY,
@@ -2521,12 +2521,12 @@
}
}
}
break;
case DataBuffer.TYPE_INT: {
- int pixel[] = null;
- int zpixel[] = null;
+ int[] pixel = null;
+ int[] zpixel = null;
float alphaScale = 1.0f / ((float) ((1<<nBits[aIdx]) - 1));
for (int y = 0; y < h; y++, rY++) {
rX = rminX;
for (int x = 0; x < w; x++, rX++) {
pixel = (int[])raster.getDataElements(rX, rY,
@@ -2548,12 +2548,12 @@
}
}
}
break;
case DataBuffer.TYPE_SHORT: {
- short pixel[] = null;
- short zpixel[] = null;
+ short[] pixel = null;
+ short[] zpixel = null;
float alphaScale = 1.0f / 32767.0f;
for (int y = 0; y < h; y++, rY++) {
rX = rminX;
for (int x = 0; x < w; x++, rX++) {
pixel = (short[]) raster.getDataElements(rX, rY,
@@ -2575,12 +2575,12 @@
}
}
}
break;
case DataBuffer.TYPE_FLOAT: {
- float pixel[] = null;
- float zpixel[] = null;
+ float[] pixel = null;
+ float[] zpixel = null;
for (int y = 0; y < h; y++, rY++) {
rX = rminX;
for (int x = 0; x < w; x++, rX++) {
pixel = (float[]) raster.getDataElements(rX, rY,
pixel);
@@ -2600,12 +2600,12 @@
}
}
}
break;
case DataBuffer.TYPE_DOUBLE: {
- double pixel[] = null;
- double zpixel[] = null;
+ double[] pixel = null;
+ double[] zpixel = null;
for (int y = 0; y < h; y++, rY++) {
rX = rminX;
for (int x = 0; x < w; x++, rX++) {
pixel = (double[]) raster.getDataElements(rX, rY,
pixel);
@@ -2633,11 +2633,11 @@
}
else {
// We are premultiplied and want to divide it out
switch (transferType) {
case DataBuffer.TYPE_BYTE: {
- byte pixel[] = null;
+ byte[] pixel = null;
float alphaScale = 1.0f / ((float) ((1<<nBits[aIdx]) - 1));
for (int y = 0; y < h; y++, rY++) {
rX = rminX;
for (int x = 0; x < w; x++, rX++) {
pixel = (byte[])raster.getDataElements(rX, rY,
@@ -2654,11 +2654,11 @@
}
}
}
break;
case DataBuffer.TYPE_USHORT: {
- short pixel[] = null;
+ short[] pixel = null;
float alphaScale = 1.0f / ((float) ((1<<nBits[aIdx]) - 1));
for (int y = 0; y < h; y++, rY++) {
rX = rminX;
for (int x = 0; x < w; x++, rX++) {
pixel = (short[])raster.getDataElements(rX, rY,
@@ -2675,11 +2675,11 @@
}
}
}
break;
case DataBuffer.TYPE_INT: {
- int pixel[] = null;
+ int[] pixel = null;
float alphaScale = 1.0f / ((float) ((1<<nBits[aIdx]) - 1));
for (int y = 0; y < h; y++, rY++) {
rX = rminX;
for (int x = 0; x < w; x++, rX++) {
pixel = (int[])raster.getDataElements(rX, rY,
@@ -2696,11 +2696,11 @@
}
}
}
break;
case DataBuffer.TYPE_SHORT: {
- short pixel[] = null;
+ short[] pixel = null;
float alphaScale = 1.0f / 32767.0f;
for (int y = 0; y < h; y++, rY++) {
rX = rminX;
for (int x = 0; x < w; x++, rX++) {
pixel = (short[])raster.getDataElements(rX, rY,
@@ -2717,11 +2717,11 @@
}
}
}
break;
case DataBuffer.TYPE_FLOAT: {
- float pixel[] = null;
+ float[] pixel = null;
for (int y = 0; y < h; y++, rY++) {
rX = rminX;
for (int x = 0; x < w; x++, rX++) {
pixel = (float[])raster.getDataElements(rX, rY,
pixel);
@@ -2736,11 +2736,11 @@
}
}
}
break;
case DataBuffer.TYPE_DOUBLE: {
- double pixel[] = null;
+ double[] pixel = null;
for (int y = 0; y < h; y++, rY++) {
rX = rminX;
for (int x = 0; x < w; x++, rX++) {
pixel = (double[])raster.getDataElements(rX, rY,
pixel);
< prev index next >