R
Raj
Hi ,
I am trying to write a function which rescales a bufferedimage using
JAI biliner interpolation
But it seems the rescaled image looses the data and now only a part of
the rescaled image is visible.I read the JAI documentation and read
somewhere that its because of not giving the proper renderinghint to
extend the border.
So i created the renderinghint and added it to the the JAI.create
method,still the result is same.
What am i doing wrong???I am new to this and am totally flabbergasted

Help me!!!
Copying the code below
Thanx a lot
Raj
public static BufferedImage _rescale(BufferedImage image, float
xScale,
float yScale)
{
if((xScale == 1.0f)&& (yScale == 1.0f)){return image;}
// Interpolation interp = Interpolation.getInstance(
// Interpolation.INTERP_BICUBIC);
Interpolation interp =
Interpolation.getInstance(Interpolation.INTERP_BILINEAR);
ParameterBlock params = new ParameterBlock();
params.addSource(image);
params.add(xScale);
params.add(yScale);
/** Add x translate */
params.add(0.0F);
/** Add y translate */
params.add(0.0F);
/** Adds interpolation method */
params.add(interp);
RenderingHints rh = new RenderingHints(JAI.KEY_BORDER_EXTENDER,
BorderExtender.createInstance(BorderExtender.BORDER_COPY));
RenderedOp outputImage = JAI.create("scale", params,rh);
//RenderedOp outputImage = JAI.create("scale", params);
Raster raster = outputImage.getData();
//BufferedImage result=new BufferedImage();
BufferedImage result = new BufferedImage(raster.getWidth(),
raster.getHeight(),
IMAGE_TYPE);
System.out.println(raster.getWidth()+"---"+
raster.getHeight());
result.setData(raster);
return result;
}
I am trying to write a function which rescales a bufferedimage using
JAI biliner interpolation
But it seems the rescaled image looses the data and now only a part of
the rescaled image is visible.I read the JAI documentation and read
somewhere that its because of not giving the proper renderinghint to
extend the border.
So i created the renderinghint and added it to the the JAI.create
method,still the result is same.
What am i doing wrong???I am new to this and am totally flabbergasted
Help me!!!
Copying the code below
Thanx a lot
Raj
public static BufferedImage _rescale(BufferedImage image, float
xScale,
float yScale)
{
if((xScale == 1.0f)&& (yScale == 1.0f)){return image;}
// Interpolation interp = Interpolation.getInstance(
// Interpolation.INTERP_BICUBIC);
Interpolation interp =
Interpolation.getInstance(Interpolation.INTERP_BILINEAR);
ParameterBlock params = new ParameterBlock();
params.addSource(image);
params.add(xScale);
params.add(yScale);
/** Add x translate */
params.add(0.0F);
/** Add y translate */
params.add(0.0F);
/** Adds interpolation method */
params.add(interp);
RenderingHints rh = new RenderingHints(JAI.KEY_BORDER_EXTENDER,
BorderExtender.createInstance(BorderExtender.BORDER_COPY));
RenderedOp outputImage = JAI.create("scale", params,rh);
//RenderedOp outputImage = JAI.create("scale", params);
Raster raster = outputImage.getData();
//BufferedImage result=new BufferedImage();
BufferedImage result = new BufferedImage(raster.getWidth(),
raster.getHeight(),
IMAGE_TYPE);
System.out.println(raster.getWidth()+"---"+
raster.getHeight());
result.setData(raster);
return result;
}