你如何在java中裁剪图像?

时间:2013-11-22 23:20:57

标签: java image crop

我需要在每侧裁剪150像素的图像而不改变图像的高度。这就是我到目前为止所做的:

import images.APImage;
import images.Pixel;

public class Practice
{
public static void main(String[] args)
{
    APImage orig = new APImage("Beans.jpg");

    int width = orig.getImageWidth();
    int height = orig.getImageHeight();

    APImage duplic = new APImage(//width - something?, height);

    for (int x = 0; x < width; x++)
    {
        for (int y = 0; y < height; y++)
        {
            Pixel pixelorig = orig.getPixel(x, y);
            Pixel pixelduplic = duplic.getPixel(//x - something?, height);
            pixelduplic.setRed(pixelorig.getRed());
            pixelduplic.setGreen(pixelorig.getGreen());
            pixelduplic.setBlue(pixelorig.getBlue());
        }
    }
    orig.draw();
    duplic.draw();
}
}

任何帮助将不胜感激!谢谢!

0 个答案:

没有答案
相关问题