-
Bug
-
Resolution: Not an Issue
-
P3
-
7u45, 8-pool, 9
-
x86_64
-
windows_7
FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
1.Question:
I fill RGB byte array with some value, and then create an IndexColorModel.
When I run IndexColorModel.isCompatibleRaster(Raster), it return false.
Here is code:
===================
import java.awt.image.DataBuffer;
import java.awt.image.IndexColorModel;
import java.awt.image.Raster;
import java.io.IOException;
public class TestIscom {
public static void main(String[] args) throws IOException {
final int length = 100 * 100;
byte r[] = new byte[length];
byte g[] = new byte[length];
byte b[] = new byte[length];
for(int i = 0; i!= length;++i){
r[i] = (byte)6;
g[i] = (byte)6;
b[i] = (byte)6;
}
IndexColorModel icm = new IndexColorModel(8, length, r, g, b);
Raster raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, 100, 100, 1, null);
if(!icm.isCompatibleRaster(raster))
{
System.out.println("Raster : error!");
}
System.out.println("Raster : OK!");
}
}
=====================
Result: Raster : error!
2.
I tried to find out the reason.
The source code I've seen is:
public boolean isCompatibleRaster(Raster raster) {
int size = raster.getSampleModel().getSampleSize(0);
return ((raster.getTransferType() == transferType) &&
(raster.getNumBands() == 1) && ((1 << size) >= map_size));
}
"map_size" is the size of dataBuffer, (1<<size) is a result of typesize.
To check the map_size with a typesize, that really confuse me.
In my opinion, the last line "((1 << size) >= map_size));" should be "((1 << size) < maxBits));"
REGRESSION. Last worked in version 7u45
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run source code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Raster : OK!
ACTUAL -
Raster : error!
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.image.DataBuffer;
import java.awt.image.IndexColorModel;
import java.awt.image.Raster;
import java.io.IOException;
public class TestIscom {
public static void main(String[] args) throws IOException {
final int length = 100 * 100;
byte r[] = new byte[length];
byte g[] = new byte[length];
byte b[] = new byte[length];
for(int i = 0; i!= length;++i){
r[i] = (byte)6;
g[i] = (byte)6;
b[i] = (byte)6;
}
IndexColorModel icm = new IndexColorModel(8, length, r, g, b);
Raster raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, 100, 100, 1, null);
if(!icm.isCompatibleRaster(raster))
{
System.out.println("Raster : error!");
}
System.out.println("Raster : OK!");
}
}
---------- END SOURCE ----------
A DESCRIPTION OF THE PROBLEM :
1.Question:
I fill RGB byte array with some value, and then create an IndexColorModel.
When I run IndexColorModel.isCompatibleRaster(Raster), it return false.
Here is code:
===================
import java.awt.image.DataBuffer;
import java.awt.image.IndexColorModel;
import java.awt.image.Raster;
import java.io.IOException;
public class TestIscom {
public static void main(String[] args) throws IOException {
final int length = 100 * 100;
byte r[] = new byte[length];
byte g[] = new byte[length];
byte b[] = new byte[length];
for(int i = 0; i!= length;++i){
r[i] = (byte)6;
g[i] = (byte)6;
b[i] = (byte)6;
}
IndexColorModel icm = new IndexColorModel(8, length, r, g, b);
Raster raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, 100, 100, 1, null);
if(!icm.isCompatibleRaster(raster))
{
System.out.println("Raster : error!");
}
System.out.println("Raster : OK!");
}
}
=====================
Result: Raster : error!
2.
I tried to find out the reason.
The source code I've seen is:
public boolean isCompatibleRaster(Raster raster) {
int size = raster.getSampleModel().getSampleSize(0);
return ((raster.getTransferType() == transferType) &&
(raster.getNumBands() == 1) && ((1 << size) >= map_size));
}
"map_size" is the size of dataBuffer, (1<<size) is a result of typesize.
To check the map_size with a typesize, that really confuse me.
In my opinion, the last line "((1 << size) >= map_size));" should be "((1 << size) < maxBits));"
REGRESSION. Last worked in version 7u45
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run source code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Raster : OK!
ACTUAL -
Raster : error!
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.image.DataBuffer;
import java.awt.image.IndexColorModel;
import java.awt.image.Raster;
import java.io.IOException;
public class TestIscom {
public static void main(String[] args) throws IOException {
final int length = 100 * 100;
byte r[] = new byte[length];
byte g[] = new byte[length];
byte b[] = new byte[length];
for(int i = 0; i!= length;++i){
r[i] = (byte)6;
g[i] = (byte)6;
b[i] = (byte)6;
}
IndexColorModel icm = new IndexColorModel(8, length, r, g, b);
Raster raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, 100, 100, 1, null);
if(!icm.isCompatibleRaster(raster))
{
System.out.println("Raster : error!");
}
System.out.println("Raster : OK!");
}
}
---------- END SOURCE ----------