Skip to main content
Interwork Corporation
IDR Solutions Product Support Portal
PDF開発用語集 モードの切替 ダーク/ライト/自動 モードの切替 ダーク/ライト/自動 モードの切替 ダーク/ライト/自動

画像の拡大縮小

機能概要

スケール操作は、double型で指定された拡大縮小率により画像をリサイズします。デフォルトで使用されるスケーリングオプションはAffineTransformOp.TYPE_BILINEARです。

JavaでBufferedImageを拡大縮小する

ImageProcessingOperations operations = new ImageProcessingOperations();

// ここでは、拡大縮小、ぼかしなど、複数の操作を連鎖させることができます
operations.scale(1.2); //この場合、AffineTransformOp.TYPE_BILINEARが使用されます
//operations.scale(scalingFactor, AffineTransformOp.TYPE_BICUBIC); //AffineTransformOp.VALUE
        
// BufferedImageに操作を適用する
BufferedImage modifiedImage = operations.apply(BufferedImage originalImage);

スケール操作のJavadocを表示

追加のコード例

以下のコード例を使用して、画像フォーマット間の処理と変換を行います:

Fileを使用する場合

File inputFile = new File("path/to/file");
File outputFile = new File("path/to/output-scaled-file");
JDeli.convert(inputFile, outputFile, operations);

InputStreamとOutputSteamを使用する場合

final InputStream inputStream = new FileInputStream(inputFile);
final OutputStream outputStream = new FileOutputStream(outputFile);
final String outputFormat = "format"; // 出力ファイルのフォーマット (例: png, jpeg,...)
JDeli.convert(inputStream, outputStream, outputFormat, operations);

byte[]を使用する場合

byte[] inputData = Files.readAllBytes(Paths.get("/path/to/file"));
final String outputFormat = "format"; // 出力ファイルのフォーマット (例: png, jpeg,...)
byte[] outputData = JDeli.convert(inputData, outputFormat, operations);