Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  BufferedImage for fast display?  (Read 1986 times)
0 Members and 1 Guest are viewing this topic.
Offline gojira

Senior Newbie

Java games rock!

« Posted 2005-02-05 01:56:34 »

Hi all!  I'm looking at starting a simple game, with a few sprites.  I want to make a few sprites using BufferedImage, then blit the sprites quickly to the screen.

Query: How can I match the display (bit depth, RGB, BGR, etc. ) for the fastest blit?

I want to set this up before hand, not in the paint() method.  Trying to create all the sprites in the paint() method would basically be kludgy, at best, and totaly unworkable at worst.

I want to set up the sprites in main(), or some method called by main, with images that match the screen bit depth.

Any ideas?  Thanks for the help!
Offline Smarto

Senior Newbie


« Reply #1 - Posted 2005-02-06 21:23:23 »

Hi there gojira!

I don't quite understand your question, but I will try to help.

It seems like what you are trying to do is implement a form of double buffering, where instead of your graphics being drawn directly to the screen, it is drawn in your computer's memory and then simply "flipped" over or copied to your screen.

If you want to set up your sprites before drawing them, I suppose you could load them in your program's initialization phase, either the constructor if you are making an Application, or init() in an Applet.

Some other solutions to this:

1) If you are looking for a full-fledged animation loop, complete with double buffering, you might want to check out Chapter 1 of this book-in-progress:
This chapter also covers totally ignoring paint() altogether so you can perform your own graphics drawing whenever and wherever.

2) There are a few sections on passive vs. active rendering here at the Java Tutorial:

Sorry if this isn't what you were looking for!

Anger is the equivalent of grasping a hot coal in the palm of your hand
- Unkown
Offline gojira

Senior Newbie

Java games rock!

« Reply #2 - Posted 2005-02-07 01:41:01 »

Hey Smarto, thanks for those links.  They look pretty good, I'll have to check them out.  

Basically I want to do a form of double buffering.  I want to use a background image and then add seperate sprite images the background to form the final image.  I plan to use these as seperate images, not quite double buffering, and use dirty rectangles to only update the areas that I want.

But that doesn't matter.  Right now, I only want one thing.  How can I get the bit depth and color mode of the display so I can match it with my images I create?

I changed my original post to better say what I ment (you are right, I wasn't too clear the first time).  

Anyhoo, hopefully someone can answer.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Malohkan

Senior Devvie

while (true) System.out.println("WOO!!!!");

« Reply #3 - Posted 2005-02-07 02:46:59 »

Scroll down a bit to where I talk about how to get managed BufferedImages.  With that strategy, you can ask for a BufferedImage with Translucency.WHATEVER constants which will be compatible with the current display.

Admin and Game Developer at
Play Rimscape!    |    Play Conquer!
Offline gojira

Senior Newbie

Java games rock!

« Reply #4 - Posted 2005-02-07 15:18:41 »

 GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment()

BufferedImage image = gc.createCompatibleImage(width, height,

Woo!  That looks like what I wanted! Thanks Mal, I'll check this out. Smiley
Pages: [1]
  ignore  |  Print  

EgonOlsen (60 views)
2018-06-10 19:43:48

EgonOlsen (42 views)
2018-06-10 19:43:44

EgonOlsen (61 views)
2018-06-10 19:43:20

DesertCoockie (241 views)
2018-05-13 18:23:11

nelsongames (142 views)
2018-04-24 18:15:36

nelsongames (141 views)
2018-04-24 18:14:32

ivj94 (883 views)
2018-03-24 14:47:39

ivj94 (144 views)
2018-03-24 14:46:31

ivj94 (795 views)
2018-03-24 14:43:53

Solater (159 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!