Posted By:
Ronnie_Kilsbo
Posted On:
Monday, November 11, 2002 10:44 AM
Ok. I have an image that I want to crop. It is 210 pixels wide and 143 pixels high (checked with getWidth() and getHeight() methods (PlanarImage()). This is my code for performing the crop: int maxX = 191; int maxY = 143; // First float makes the crop in the center of the image. float xStart = ((float)workimage.getWidth() / 2.0F) - ((float)maxX / 2.0F); float yStart = 0.0F; float xLength = (float)maxX; float yLength = (float)maxY; ParameterBlock pb = new ParameterBlock(); pb.addSource(workimage); pb.add(xStart); pb.add(yStart); pb.add(xLength); pb.add(yLength); pb.add(
More>>
Ok. I have an image that I want to crop. It is 210 pixels wide and 143 pixels high (checked with
getWidth()
and
getHeight()
methods (PlanarImage()).
This is my code for performing the crop:
int maxX = 191;
int maxY = 143;
// First float makes the crop in the center of the image.
float xStart = ((float)workimage.getWidth() / 2.0F) - ((float)maxX / 2.0F);
float yStart = 0.0F;
float xLength = (float)maxX;
float yLength = (float)maxY;
ParameterBlock pb = new ParameterBlock();
pb.addSource(workimage);
pb.add(xStart);
pb.add(yStart);
pb.add(xLength);
pb.add(yLength);
pb.add(new InterpolationNearest());
workimage = JAI.
create
("crop", pb, null);
However, when I check the size of my new image with the methods
getWidth()
and
getHeight()
it is not 191x143 pixels, it is 192x143 ... but I set the ParameterBlock() so it should have ended up with the width of 191 pixels.
What do I seem to have done wrong here?
<<Less