Fetching an Image

Hi, long time no see.
I’ve been really busy with my software 3D engine and it is turning out to be a nice system :wink:

I have one question about Images though… Is there any other way to fetch the pixels from an Image than with a PixelGrabber? First, it’s slow and secondly if a game has a high framerate and getPixels() is called like 60 times/second the program will eventually crash as it cannot fetch the pixels fast enough. The implementation doesn’t allow the pixels to be cached as a new image can be supplied at any time asynchronously, so this is the only way. Right now I’ve solved it by forcing the user to fetch the pixels by himself and give the pixel array as an argument to my method, but it feels somewhat of a hack. Any ideas?

This is all for now,
laters dudes =)

How about reading the pixels data from a file to an array (maybe using your own format) and using java.awt.image.MemoryImageSource to create a java.awt.Image? You can have immedeate access to the pixel array aswell as to the image.

[quote]How about reading the pixels data from a file to an array (maybe using your own format) and using java.awt.image.MemoryImageSource to create a java.awt.Image? You can have immedeate access to the pixel array aswell as to the image.
[/quote]
Hi.
That’s what I am doing now, but I want to have a method, drawImage(Image, width, height etc…) in my own rasteriser. I try to keep a high abstraction level so the user won’t have to fetch the image pixels himself and calling the current drawImage(int[] pixels, width, height etc…). Hope you understand what I mean.
Laters.

Then the answer is no.

I suggest you create a wrapper for the int [] way of doing it, and then simply provide a drawImage(YourImageClass,x,y,etc)

If you use a BufferedImage then you should be able to get at the pixel data through the Raster object.

[quote]If you use a BufferedImage then you should be able to get at the pixel data through the Raster object.
[/quote]
I think hes sticking to 1.1.
Atleast, thats the assumption I made when I said ‘no’.

Correct, Java1.1 here =)
Thanks for the help though, now I can leave this behind me and focus on other things.