2010-04-21 10 views
1

je veux rogner une partie de l'image, pour que je suis en utilisant le code suivant:BlackBerry - Rogner

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 sont une position où la culture se fera sous la forme rectangulaire. mais cela ne fonctionne pas peut-on m'aider s'il vous plaît. n'importe quel code d'exemple travaillera pour moi. son urgence. merci à l'avance

Répondre

3

vous pouvez le faire en utilisant les graphiques:

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