Partying on the bitmap...

OK, I’ve googled a bit for this and haven’t found any leads. Any help would be appreciated…

How do I directly party on the bitmap in Java (i.e. draw arbitrary, dynamic stuff there)?

I’m trying to stay Java 1.1 compatible. I’m double-buffering, using an off-screen Image. Mostly, I want to blit other images into the main off-screen image, but the set of functions provided is rather limited, and so I’d like to do at least some stuff more dynamically (i.e. color-remapping as I blit, arbitrary rotation, etc…). I understand that this is likely to be somewhat slower than the provided drawImage functions - I can handle that. But of course I don’t want to have to drop all the way down to using 1 x 1 fillRects or the like.

In C, you can generally get a ptr to the dest bitmap (effectively as an array of bytes or DWORDs), then walk that array and do what you like - anything roughly comparable in Java?

I looked at BufferedImage, but that appears to require something higher than Java 1.1 (it’s an invalid type when I compile for 1.1 - I didn’t test it in 1.4, though).

I’ve seen the reference code here:
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/image/MemoryImageSource.html
But this basically requires you to create a new image every time. So, for instance, if I had a slowly spinning ship sprite, then I’d have to create a new version of that sprite every frame. It’s doable, but not an ideal solution - what I’d like is to have my ship, in it’s normal non-rotated form, and dynamically blit it every frame at whatever the current rotation is.

Any thoughts and/or websites with reference code?

Thanks,
Phil

You can use MemoryImageSource. You don’t have to create a new one every frame. There is a way to update the pixels.

[quote]I’ve seen the reference code here:
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/image/MemoryImageSource.html
But this basically requires you to create a new image every time. So, for instance, if I had a slowly spinning ship sprite, then I’d have to create a new version of that sprite every frame. It’s doable, but not an ideal solution - what I’d like is to have my ship, in it’s normal non-rotated form, and dynamically blit it every frame at whatever the current rotation is.
[/quote]
You could create your own version of this. Just create a class that implements the ImageProducer interface, then you control how the image is generated.

But this is painfully slow! I would dual-implement one with PxelGrabber/ImageSource (for pre-1.2 platfroms) and completly rely on BufferedImage starting with 1.2 and later…

lg Clemens

[quote]But this is painfully slow! I would dual-implement one with PxelGrabber/ImageSource (for pre-1.2 platfroms) and completly rely on BufferedImage starting with 1.2 and later…
[/quote]
BufferedImage is faster but I don’t think the differance is huge. The slow part is uploading the data to the card. Have you done any tests?

yep, since 1.4 PixelGrabber’s performance is REALLY terrible.
It needs several (~7 with X11; 1,5min with OGL!!) seconds to completly grab an 1024x768 image…

There’s already a bug-report complaining about that…

lg Clemens