🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #9551

Re: How do i capture the "canvas" of a JFrame (or, turn it into an Image)?

#9551
From: Johan Forsberg
Date: Tue, 14 Mar 2000 00:00
26 lines
1581 bytes
John Hines <jrhines@onramp.net> skrev i
diskussionsgruppsmeddelandet:8a128u$35q1@bornews.borland.com...
> I have some code I inherited where a complex image is written onto an
> off-screen JFrame-derived class.  I need to write the image (don't need
the
> JFrame) out to a file in standard format.  This would be easy if I had the
> picture as a bitmap or (preferably) as an Image.  How do I do this?
>
> Can somebody toss me a hint or point me to a book or some commercial code?

Presumably, you have a method somewhere along the lines of

public void paint(Graphics g)

which causes the complex image to be drawn to the graphics g.

Create a BufferedImage of appropriate size and color format, then

paint(bimg.createGraphics());

As for writing the image, check out the com.sun.image.codec.jpeg package
(included with Java 2). For other image formats, you may have to download
Java Advanced Imaging (JAI). Check out http://java.sun.com/products/

HTH
Technical Details
Message-ID: <8alqbc$r035@bornews.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <8a128u$35q1@bornews.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,44cc2ec39376ba71
X-Google-Attributes: gid111d45,public
From: "Johan Forsberg" <jfo@SPAM_SPAM_EGGS_SPAMstmf.se>
Subject: Re: How do i capture the "canvas" of a JFrame (or, turn it into an Image)?
Date: 2000/03/14
Message-ID: <8alqbc$r035@bornews.borland.com>
X-Deja-AN: 597410807
References: <8a128u$35q1@bornews.borland.com>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
Organization: Another Netscape Collabra Server User
X-MSMail-Priority: Normal
Newsgroups: borland.public.jbuilder.java.swing