Skip to content

Instantly share code, notes, and snippets.

@ulinkwo
Created March 19, 2010 01:35
Show Gist options
  • Save ulinkwo/337134 to your computer and use it in GitHub Desktop.
Save ulinkwo/337134 to your computer and use it in GitHub Desktop.
//搭配 scale operator
Interpolation interp = Interpolation.getInstance(Interpolation.INTERP_BILINEAR);
//利用 ParameterBlock 物件儲存必要的 input Source 與 參數
ParameterBlock params = new ParameterBlock();
params.addSource(ri);//为RenderedImage对象或图像文件
params.add(scale); // x scale factor
params.add(scale); // y scale factor
params.add(0.0F); // x translate
params.add(0.0F); // y translate
params.add(interp); // interpolation method
//建立一個 operator 來 scale 影像
RenderedOp scaledImage = JAI.create("scale", params);
JPEGEncodeParam param = new JPEGEncodeParam();
param.setQuality(1.2F);
RenderedOp op = JAI.create("filestore", scaledImage, "file.jpg"-, "JPEG", param);
op.dispose();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment