freelanceprogrammers.org Forum Index » Java

Double-buffering/image creation


View user's profile Post To page top
msulli1355 Posted: Tue Apr 20, 2004 8:46 pm


Joined: 17 Apr 2004

Posts: 28
Double-buffering/image creation
If I were to create an image with code such as:

Image image = createImage(500, 500)

how would I write to it?
Reply with quote
Send private message
View user's profile Post To page top
testthis222001 Posted: Wed Apr 21, 2004 2:08 am


Joined: 14 Apr 2004

Posts: 6
Double-buffering/image creation
--- In beginnersclub@yahoogroups.com, Michael Sullivan
<michael@e...> wrote:
> If I were to create an image with code such as:
>
> Image image = createImage(500, 500)
>
> how would I write to it?

From my expereince using images you usually use a JLabel (as
JLabel`s are used to hold images) and if the image that you want is
in a file use strings to create a file path to the image and then
you use the setIcon() method (setIcon - something like that) to post
the image (via file path) in to the JLabel. I have an example I
could post if you want (just ask and I will post it).

Hope this helps
John
Reply with quote
Send private message
View user's profile Post To page top
msulli1355 Posted: Wed Apr 21, 2004 4:01 am


Joined: 17 Apr 2004

Posts: 28
Double-buffering/image creation
I`m using a Canvas to do my animation on, and adding the Canvas to a
JPanel in a JFrame...

-Michael Sullivan-



On Tue, 2004-04-20 at 16:08, testthis222001 wrote:
> --- In beginnersclub@yahoogroups.com, Michael Sullivan
> <michael@e...> wrote:
> > If I were to create an image with code such as:
> >
> > Image image = createImage(500, 500)
> >
> > how would I write to it?
>
> >From my expereince using images you usually use a JLabel (as
> JLabel`s are used to hold images) and if the image that you want is
> in a file use strings to create a file path to the image and then
> you use the setIcon() method (setIcon - something like that) to post
> the image (via file path) in to the JLabel. I have an example I
> could post if you want (just ask and I will post it).
>
> Hope this helps
> John
>
>
>
> ______________________________________________________________________
> Yahoo! Groups Links
> * To visit your group on the web, go to:
> http://groups.yahoo.com/group/beginnersclub/
>
> * To unsubscribe from this group, send an email to:
> beginnersclub-unsubscribe@yahoogroups.com
>
> * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service.
>
Reply with quote
Send private message
View user's profile Post To page top
nitrusrit Posted: Wed Apr 21, 2004 8:26 am


Joined: 10 Apr 2004

Posts: 19
Double-buffering/image creation
Create a BufferedImage instead. I`ve done this double-buffering stuff before
and it`s actually not bad. The BufferedImage will give you pixel-by-pixel
access to the buffer. Also, you can call getGraphics on it. What I would
generally do is get the Graphics object from my buffered image and put my
images, lines, whatever else in it, then when I finished drawing I would copy
the whole thing over to an image in an applet or jframe.

Hope that helps.

Dustin

Michael Sullivan <michael@...> wrote:
If I were to create an image with code such as:

Image image = createImage(500, 500)

how would I write to it?



---------------------------------
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢

[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
msulli1355 Posted: Wed Apr 21, 2004 8:38 am


Joined: 17 Apr 2004

Posts: 28
Double-buffering/image creation
Can you use Graphics.drawImage on a BufferedImage?

On Tue, 2004-04-20 at 22:26, Dustin Metzgar wrote:
> Create a BufferedImage instead. I`ve done this double-buffering stuff before
and it`s actually not bad. The BufferedImage will give you pixel-by-pixel
access to the buffer. Also, you can call getGraphics on it. What I would
generally do is get the Graphics object from my buffered image and put my
images, lines, whatever else in it, then when I finished drawing I would copy
the whole thing over to an image in an applet or jframe.
>
> Hope that helps.
>
> Dustin
>
> Michael Sullivan <michael@...> wrote:
> If I were to create an image with code such as:
>
> Image image = createImage(500, 500)
>
> how would I write to it?
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Photos: High-quality 4x6 digital prints for 25
>
> [Non-text portions of this message have been removed]
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
Reply with quote
Send private message
View user's profile Post To page top
testthis222001 Posted: Wed Apr 21, 2004 11:59 am


Joined: 14 Apr 2004

Posts: 6
Double-buffering/image creation
Yes you can. Check out the link below for a post on the Sun Forums
that should answer your questions.
This is the example they use
graphics.drawImage((BufferedImage)list.get(i), null, i *
dividerLine, 0);

To see the code in it`s full context click on this link.

http://forum.java.sun.com/thread.jsp?
forum=20&thread=514292&tstart=0&trange=15

because the link is to long. You will have to copy and paste both
bits into the address bar. The tread is called Combining Buffered
Images. Check out all 3 posts, but the last one seems to be the
most relevent.

Hope this helps.
Regards John


--- In beginnersclub@yahoogroups.com, Michael Sullivan
<michael@e...> wrote:
> Can you use Graphics.drawImage on a BufferedImage?
>
> On Tue, 2004-04-20 at 22:26, Dustin Metzgar wrote:
> > Create a BufferedImage instead. I`ve done this double-buffering
stuff before and it`s actually not bad. The BufferedImage will give
you pixel-by-pixel access to the buffer. Also, you can call
getGraphics on it. What I would generally do is get the Graphics
object from my buffered image and put my images, lines, whatever
else in it, then when I finished drawing I would copy the whole
thing over to an image in an applet or jframe.
> >
> > Hope that helps.
> >
> > Dustin
> >
> > Michael Sullivan <michael@e...> wrote:
> > If I were to create an image with code such as:
> >
> > Image image = createImage(500, 500)
> >
> > how would I write to it?
> >
> >
> >
> > ---------------------------------
> > Do you Yahoo!?
> > Yahoo! Photos: High-quality 4x6 digital prints for 25
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
Reply with quote
Send private message
View user's profile Post To page top
nitrusrit Posted: Wed Apr 21, 2004 4:56 pm


Joined: 10 Apr 2004

Posts: 19
Double-buffering/image creation
Yes you can. If you get Graphics from a BufferedImage you can use any (I think)
of the Graphics functions. I used it to paint images with image filters so I`m
sure it works.

Dustin

Michael Sullivan <michael@...> wrote:
Can you use Graphics.drawImage on a BufferedImage?

On Tue, 2004-04-20 at 22:26, Dustin Metzgar wrote:
> Create a BufferedImage instead. I`ve done this double-buffering stuff before
and it`s actually not bad. The BufferedImage will give you pixel-by-pixel
access to the buffer. Also, you can call getGraphics on it. What I would
generally do is get the Graphics object from my buffered image and put my
images, lines, whatever else in it, then when I finished drawing I would copy
the whole thing over to an image in an applet or jframe.
>
> Hope that helps.
>
> Dustin
>
> Michael Sullivan <michael@...> wrote:
> If I were to create an image with code such as:
>
> Image image = createImage(500, 500)
>
> how would I write to it?
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Photos: High-quality 4x6 digital prints for 25
>
> [Non-text portions of this message have been removed]
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>



---------------------------------
Yahoo! Groups Links

To visit your group on the web, go to:
http://groups.yahoo.com/group/beginnersclub/

To unsubscribe from this group, send an email to:
beginnersclub-unsubscribe@yahoogroups.com

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



---------------------------------
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢

[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
dale_erwin Posted: Wed Apr 21, 2004 9:18 pm


Joined: 11 Apr 2004

Posts: 11
Double-buffering/image creation
testthis222001 wrote:
> --- In beginnersclub@yahoogroups.com, Michael Sullivan
> <michael@e...> wrote:
>
>>If I were to create an image with code such as:
>>
>>Image image = createImage(500, 500)
>>
>>how would I write to it?
>
>
>>From my expereince using images you usually use a JLabel (as
> JLabel`s are used to hold images) and if the image that you want is
> in a file use strings to create a file path to the image and then
> you use the setIcon() method (setIcon - something like that) to post
> the image (via file path) in to the JLabel. I have an example I
> could post if you want (just ask and I will post it).
>
> Hope this helps
> John

Out of curiosity, in which class does the createImage method
reside?
--
Dale Erwin
Salamanca 116
Pueblo Libre
Lima 21 PERU
Tel. +51(1)461-3084
Cel. +51(1)9743-6439
DALE ERWIN`S OPERA FILES - http://www.geocities.com/dale_erwin
Reply with quote
Send private message
View user's profile Post To page top
nitrusrit Posted: Thu Apr 22, 2004 9:26 pm


Joined: 10 Apr 2004

Posts: 19
Double-buffering/image creation
The Applet class I think.

Dale Erwin <daleerwin@...> wrote:testthis222001 wrote:
> --- In beginnersclub@yahoogroups.com, Michael Sullivan
> <michael@e...> wrote:
>
>>If I were to create an image with code such as:
>>
>>Image image = createImage(500, 500)
>>
>>how would I write to it?
>
>
>>From my expereince using images you usually use a JLabel (as
> JLabel`s are used to hold images) and if the image that you want is
> in a file use strings to create a file path to the image and then
> you use the setIcon() method (setIcon - something like that) to post
> the image (via file path) in to the JLabel. I have an example I
> could post if you want (just ask and I will post it).
>
> Hope this helps
> John

Out of curiosity, in which class does the createImage method
reside?
--
Dale Erwin
Salamanca 116
Pueblo Libre
Lima 21 PERU
Tel. +51(1)461-3084
Cel. +51(1)9743-6439
DALE ERWIN`S OPERA FILES - http://www.geocities.com/dale_erwin



---------------------------------
Yahoo! Groups Links

To visit your group on the web, go to:
http://groups.yahoo.com/group/beginnersclub/

To unsubscribe from this group, send an email to:
beginnersclub-unsubscribe@yahoogroups.com

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.




---------------------------------
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢

[Non-text portions of this message have been removed]
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help