Sign in to follow this  
Straudos

[java] Something Faster than BufferedImage?

Recommended Posts

Straudos    100
Hello. I'm working on a isometric chessboard-like strategy game but have run into a bit of a problem. I use VolatileImages for the board, but at some points throughout the game I need to put a blueish or redish tint on some of the squares to show where the person can move or attack. Right now, I have pre-made red and blue squares with a certain alpha level that I display on top of the board. Since VolatileImage doesn't support transparency, I've been using BufferedImage for these pictures. However, I've found that they significantly lower frames per second and dramatically increase CPU% usage. Is there any way to display a semi-transparent image than using BufferedImage? Thanks for any help you can give.

Share this post


Link to post
Share on other sites
nmi    978
Why not convert that BufferedImage into a volatile one, then use the VolatileImage for drawing. If another tile is selected, then create a new VolatileImage for that one.

Share this post


Link to post
Share on other sites
CaptainJester    523
It is not that BufferedImage is slow, but if you try to blit from one image type to another image type, you will lose a A LOT of speed. ie. If your BuffereImage is RGBA and your VolatileImage is RGB, then that could be your speed loss.

To ensure that the images are compatable, make sure you create them both from the same source.

Component.createImage(...)
Component.createVolatileImage(...)

To ensure that both images have an alpha channel, you would have to go to fullscreen mode at 32bpp. Otherwise alpha blending will be slow anyway.

VolatileImage will support an alpha channel as long as the display it was created from is set to support it.

Share this post


Link to post
Share on other sites
Marianne    163
i once converted one of my games written in java to use volatile images and noticed no speed difference (though it may vary) the best way is still to do the smallest possible amount of drawing - (and use the OpenGL pipeline in 1.5 if possible!)

Share this post


Link to post
Share on other sites
scgrn    168
I've always found java's graphics API to be too cumbersome and confusing. I do graphics by using MemoryImageSource for a back buffer, loading an image and using PixelGrabber to grab it's data, and rolling my own sprite engine. Maybe I'm just a control freak.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
You could just use pre shaded tiles with simple bitmask transparency. Say there are dark and bright tiles and yellow and blue highlighting colors... then you need only 4 of those pre shaded tiles (you can generate em on startup).

Its all smoke and mirrors. Dont forget that ;)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this