BlackBerry - Cropping image

倖福魔咒の 提交于 2019-12-01 11:51:59

问题


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.


回答1:


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;
}


来源:https://stackoverflow.com/questions/2682250/blackberry-cropping-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!