przycięcie BufferedImage

0

File f = new File("nowy.png");
File f2 = new File("wynik.png");
BufferedImage czastka = ImageIO.read(f);

Graphics2D D = czastka.createGraphics();
D.setClip(0,0,256,256);
// TODO

ImageIO.write(czastka, "png", f2);

Chciałbym wyciąć z obrazka "nowy.png" jakiś określony obszar i zapisać ten obszar w "wynik.png".

Niestety nie mam pojęcia jak się do tego zabrać, czy da się może jakoś otrzymać nowy BufferedImage z wycietym obszarem?
Dziękuję z góry za odpowiedź.

0

juz sobie poradzilem... ciagle pod nosem mialem a nie zobaczylem :) Można sobie poradzić prostym drawImage ;)

public abstract boolean drawImage(Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
ImageObserver observer)

Parameters:
img - the specified image to be drawn
dx1 - the x coordinate of the first corner of the destination rectangle.
dy1 - the y coordinate of the first corner of the destination rectangle.
dx2 - the x coordinate of the second corner of the destination rectangle.
dy2 - the y coordinate of the second corner of the destination rectangle.
sx1 - the x coordinate of the first corner of the source rectangle.
sy1 - the y coordinate of the first corner of the source rectangle.
sx2 - the x coordinate of the second corner of the source rectangle.
sy2 - the y coordinate of the second corner of the source rectangle.
observer - object to be notified as more of the image is scaled and converted.

1 użytkowników online, w tym zalogowanych: 0, gości: 1