Clean-up, no functional change.

This commit is contained in:
Harald Kuhr 2011-10-13 09:55:02 +02:00
parent 1ba271af9d
commit 4b77d1c22a

View File

@ -535,27 +535,27 @@ public final class ImageUtil {
* *
* @param pOriginal the orignal image * @param pOriginal the orignal image
* @param pModel the original color model * @param pModel the original color model
* @param mWidth the requested width of the raster * @param width the requested width of the raster
* @param mHeight the requested height of the raster * @param height the requested height of the raster
* *
* @return a new WritableRaster * @return a new WritableRaster
*/ */
static WritableRaster createCompatibleWritableRaster(BufferedImage pOriginal, ColorModel pModel, int mWidth, int mHeight) { static WritableRaster createCompatibleWritableRaster(BufferedImage pOriginal, ColorModel pModel, int width, int height) {
if (pModel == null || equals(pOriginal.getColorModel(), pModel)) { if (pModel == null || equals(pOriginal.getColorModel(), pModel)) {
int[] bOffs; int[] bOffs;
switch (pOriginal.getType()) { switch (pOriginal.getType()) {
case BufferedImage.TYPE_3BYTE_BGR: case BufferedImage.TYPE_3BYTE_BGR:
bOffs = new int[]{2, 1, 0}; // NOTE: These are reversed from what the cm.createCompatibleWritableRaster would return bOffs = new int[]{2, 1, 0}; // NOTE: These are reversed from what the cm.createCompatibleWritableRaster would return
return Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, return Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,
mWidth, mHeight, width, height,
mWidth * 3, 3, width * 3, 3,
bOffs, null); bOffs, null);
case BufferedImage.TYPE_4BYTE_ABGR: case BufferedImage.TYPE_4BYTE_ABGR:
case BufferedImage.TYPE_4BYTE_ABGR_PRE: case BufferedImage.TYPE_4BYTE_ABGR_PRE:
bOffs = new int[] {3, 2, 1, 0}; // NOTE: These are reversed from what the cm.createCompatibleWritableRaster would return bOffs = new int[] {3, 2, 1, 0}; // NOTE: These are reversed from what the cm.createCompatibleWritableRaster would return
return Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, return Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,
mWidth, mHeight, width, height,
mWidth * 4, 4, width * 4, 4,
bOffs, null); bOffs, null);
case BufferedImage.TYPE_CUSTOM: case BufferedImage.TYPE_CUSTOM:
// Peek into the sample model to see if we have a sample model that will be incompatible with the default case // Peek into the sample model to see if we have a sample model that will be incompatible with the default case
@ -563,16 +563,17 @@ public final class ImageUtil {
if (sm instanceof ComponentSampleModel) { if (sm instanceof ComponentSampleModel) {
bOffs = ((ComponentSampleModel) sm).getBandOffsets(); bOffs = ((ComponentSampleModel) sm).getBandOffsets();
return Raster.createInterleavedRaster(sm.getDataType(), return Raster.createInterleavedRaster(sm.getDataType(),
mWidth, mHeight, width, height,
mWidth * bOffs.length, bOffs.length, width * bOffs.length, bOffs.length,
bOffs, null); bOffs, null);
} }
// Else fall through // Else fall through
default: default:
return pOriginal.getColorModel().createCompatibleWritableRaster(mWidth, mHeight); return pOriginal.getColorModel().createCompatibleWritableRaster(width, height);
} }
} }
return pModel.createCompatibleWritableRaster(mWidth, mHeight);
return pModel.createCompatibleWritableRaster(width, height);
} }
/** /**