开发者

BlackBerry - Cropping image

开发者 https://www.devze.com 2022-12-28 03:31 出处:网络
I want to crop a part of Image, for that I am using following code: int x=20; int y=50; int [] rgbdata=new int[(0+width-x+height-y)* (image.getWidth(开发者_运维问答))];

I want to crop a part of Image, for that I am using following code:

    int x=20;
    int y=50;
    int [] rgbdata=new int[(0+width-x+height-y)* (image.getWidth(开发者_运维问答))];
    image.getARGB(rgbdata, 0, image.getWidth(), x, y, width, height);
    cropedImage=new Bitmap(image.getWidth(),image.getWidth());
    cropedImage.setARGB(rgbdata, 0,image.getWidth(), 80,80, width, height);

x an y are the position from where the cropping will be done in the rectangular form. but it is not working.


you can do this using graphics:

public Bitmap cropImage(Bitmap image, int x, int y, int width, int height) {
    Bitmap result = new Bitmap(width, height);
    Graphics g = new Graphics(result);
    g.drawBitmap(0, 0, width, height, image, x, y);
    return result;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消