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

画像を引き伸ばして塗りつぶす

引き伸ばして塗りつぶす

何をするものか?

引き伸ばして塗りつぶす操作は、定義されたピクセル矩形を満たすように画像を引き伸ばします。アスペクト比は保持されないため、画像は引き伸ばされ、指定された幅と高さになります。

JavaでBufferedImageを引き伸ばす

ImageProcessingOperations operations = new ImageProcessingOperations();

// ここでスケール、ぼかしなどの複数の操作をチェーンできます
operations.stretchToFill(100, 100); // 画像を100x100ピクセルのボックスに収まるように引き伸ばす
        
// BufferedImageに操作を適用
BufferedImage modifiedImage = operations.apply(BufferedImage originalImage);

引き伸ばして塗りつぶす操作のJavadocを表示

追加のコード例

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

Fileを使用

File inputFile = new File("path/to/file");
File outputFile = new File("path/to/output-stretched-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);