Skip to main content

Losing xMin and yMin from scale operation when getting as BufferedImage

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
newmanw10
Offline
Joined: 2009-08-17

// scale the image
ParameterBlockJAI scalePb= new ParameterBlockJAI("scale");
scalePb.addSource(image);
scalePb.setParameter("xScale", 10 / image.getWidth());
scalePb.setParameter("yScale", 10 / image.getHeight()); 
scalePb.setParameter("xTrans", xTrans); //xTrans 100
scalePb.setParameter("yTrans", yTrans); // yTrans 100
RenderedOp scaledImage = JAI.create("scale", scalePb);

scaledImage.geMinX() // == 100
scaledImage.geMinY() // == 100

BufferedImage bi = scaledImage.getAsBufferedImage();

bi.getMinX() // == 0, what happened?
bi.getMinY() // == 0 what happend?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
simboss1
Offline
Joined: 2005-08-08

going from memory bufferedimages are always 0 based when it comes to mix/miny

aside, getAsBufferedImage trigger a full copy of the inpur rendered
image as it is a planar image subclass.

Regards,
Simone Giannecchini