uhhh....

Maybe you meant:

BufferedImage snap = new BufferedImage(subw, subh, TYPE_INT_RGB);
>>>     Graphics2D g2d = snap.createGraphics();


Jim Graham wrote:
Yes, if you want alpha you should pass in TYPE_INT_ARGB.

Note that the default compositing mode of the freshly retrieved graphics object is SRC_OVER. The code sample still works fine since the newly constructed image is all 0's (transparent pixels) so copying your source image "over" the fully transparent image works just fine.

But, if you try to reuse the image and copy a different section of the source image into it at a later stage then you might want to do the image copy using "g2d.setComposite(AlphaComposite.SRC)"...

        ...jim

[EMAIL PROTECTED] wrote:

    // assuming:
    Image src;
    int subx, suby, subw, subh;
    // then execute:
    BufferedImage snap =
        new BufferedImage(subw, subh, TYPE_INT_RGB);
    Graphics2D g2d = snap.createImage();
    g2d.drawImage(src, -subx, -suby, null);
    g2d.dispose();
    // snap is now a snapshot of subx,y,w,h of src


OK; thanks.

If you didn't want a snapshot, I can outline other
ways, but I'm guessing that this is probably what you wanted...?


Yep. What allowed you to know that TYPE_INT_RGB was the correct parameter to pass in the BufferedImage constructor? If it helps, I know that the source image often has an alpha value set. Would I use TYPE_INT_RGBA in this case?

Thanks again for helping this newbie out.

Best,
Laird
[Message sent by forum member 'ljnelson' (ljnelson)]

http://forums.java.net/jive/thread.jspa?messageID=295232

=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to