Mustafa Ozan Vural Mobil teknoloji notlari

14Jan/110

Java ME Image Crop

Kullanım :

 try {

            Image original = Image.createImage("/targetImage.png");
            Image cropped = getImageRegion(original, 0, 0, 20, 20);

        } catch (IOException ex) {
            ex.printStackTrace();
        }

Fonksiyon :

public static Image getImageRegion(Image source, int x, int y, int width, int height) {
        Image result = Image.createImage(width, height);
        result.getGraphics().drawImage(source, -x, -y, Graphics.TOP | Graphics.LEFT);
        return result;
    }