[#JAI_CORE-78] Problem with using filestore to save a cropped tiled

advertisement
[JAI_CORE-78] Problem with using filestore to save a cropped tiled image as
Jpeg Created: 21/Nov/06 Updated: 21/Dec/07
Status:
Project:
Component/s:
Affects
Version/s:
Fix Version/s:
Open
jai-core
implementation
1.1.3-beta
Type:
Reporter:
Resolution:
Labels:
Remaining
Estimate:
Time Spent:
Original
Estimate:
Environment:
Bug
rummyr
Unresolved
None
Not Specified
milestone 1
Major
jai-core-issues
1
Not Specified
Not Specified
Operating System: Windows XP
Platform: PC
Attachments:
Issuezilla Id:
Priority:
Assignee:
Votes:
ImageUtils.java
ScaleNCropBug.java
78
Description
java.lang.IllegalArgumentException: Raster ByteInterleavedRaster: width = 100
height = 100 #numDataElements 3 dataOff[0] = 0 is incompatible with ColorModel
DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0
Is thrown when attempting to save a cropped tiled image as jpeg where the crop
area covers more than one tile.
original post:
OK, I've been at this one for hours and still haven't bottomed it out. I'm
cropping parts of a tiled image out and saving them to jpeg using "filestore".
Initially I was alwas getting the exception:
java.lang.IllegalArgumentException: Raster ByteInterleavedRaster: width = 100
height = 100 #numDataElements 3 dataOff[0] = 0 is incompatible with ColorModel
DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0
on every save.
So I tried using a colorconvert operation before the crop, now only the left
edge parts save and the rest still give the exception above.
I think the failure only happens when the crop crosses a tile boundary, though I
am not sure of this.
Here's the smallest example program I could devise to demonstrate the problem.
/** This class tests a problem encountered when writing tiled images to

a jpeg using "filestore"
*/
public class JpegAndTiledImageWritingTest {
public static void main(String[] args)
throws IOException
{
File filename = File.createTempFile("delme", ".jpg"); // somewhere to shove the
data to.
filename.deleteOnExit();
System.out.println("please delete " + filename.getAbsolutePath() + " from your
temp directory");
RenderedImage current;
BufferedImage srcBufferedImage = new BufferedImage(2048, 2048,
BufferedImage.TYPE_INT_RGB);
// Create a tiled image from the buffered image
java.awt.image.SampleModel sampleModel =
srcBufferedImage.getSampleModel().createCompatibleSampleModel(128, 128);
TiledImage src = new TiledImage(srcBufferedImage.getMinX(),
srcBufferedImage.getMinY(),
srcBufferedImage.getWidth(),
srcBufferedImage.getHeight(),
srcBufferedImage.getTileGridXOffset(),
srcBufferedImage.getTileGridYOffset(), sampleModel,
srcBufferedImage.getColorModel());
src.set(srcBufferedImage);
current = src;
if (true) { // change to false to have ALL parts fail to save.
ColorModel rgb = new BufferedImage(1, 1,
BufferedImage.TYPE_INT_RGB).getColorModel();
ParameterBlockJAI ccPB = new ParameterBlockJAI("ColorConvert");
ccPB.addSource(src);
ccPB.setParameter("colorModel", rgb);
RenderedImage colorConverted = JAI.create("ColorConvert", ccPB);
System.out.println("converted colorModel:" + colorConverted.getColorModel());
current = colorConverted;
}
for (int x = 0; x < 2; x++) {
System.out.println("saving" + x);
boolean success = true;
ParameterBlockJAI cropPB = new ParameterBlockJAI("crop");
cropPB.addSource(current);
cropPB.setParameter("x", (float) x * 100);
cropPB.setParameter("y", (float) 0);
cropPB.setParameter("width", 100f);
cropPB.setParameter("height", 100f);
RenderedImage cropped = JAI.create("crop", cropPB);
// current = cropped;
ParameterBlockJAI pb = new ParameterBlockJAI("filestore");
pb.addSource(cropped);
pb.setParameter("filename", filename.toString());
pb.setParameter("format", "JPEG");
try {
JAI.create("filestore", pb);
}
catch (Exception e) {
e.printStackTrace();
success = false;
}
System.out.println("saved " + x + (success ? " successfully" : " failed"));
}
}
}
Comments
Comment by bpb [ 04/Sep/07 ]
Created an attachment (id=80)
Another case apparently reproducing the same problem.
Comment by bpb [ 04/Sep/07 ]
See also thread http://forums.java.net/jive/thread.jspa?threadID=30399&tstart=0.
Comment by iwo [ 21/Dec/07 ]
Created an attachment (id=86)
Using JAI 1.1.3 on linux without native acceleration
Generated at Tue Feb 09 11:58:46 UTC 2016 using JIRA 6.2.3#6260sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.
Download