黑莓手机 - 裁剪图像 [英] BlackBerry - Cropping image

查看:111
本文介绍了黑莓手机 - 裁剪图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要裁切图像的一部分,对于我使用以下code:

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上的y是从哪里裁剪将在矩形形状来完成的位置。
但它不工作的任何一个可以帮助我,请。任何样品code会为我工作。
这很紧急。
在此先感谢

x an y are the position from where the cropping will be done in the rectangular form. but it is not working can any one help me out please. any sample code will work for me. its urgent. thanks in advance

推荐答案

您可以用图形做到这一点:

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

这篇关于黑莓手机 - 裁剪图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆