Pixel plotting on image object
Hi
Is there any way I can directly by code put single pixels in a image object (of any screen-drawable type like bufferedimage or such)? This should be able to perform really fast so I would try to avoid questionable "workarounds".
I was thinking about performing operations on the underlying datastructure (the pixel data being updated by drawLine, drawOval and such need to be store somewhere right?) but I wasnt able to find out from the API reference if this kind of direct access was possible.
[517 byte] By [
invictus2a] at [2007-11-26 12:48:04]

# 1
have you seen BufferedImage.setRGB()?
If you need to update few pixels this is probably easiest way.
Alternatively you may try to work with Raster or DataBuffer.
This likely be faster for bulk processing but there are some important caveats,
e.g.
http://java.sun.com/javase/6/webnotes/trouble/TSG-Desktop/html/java2d.html#gcrwq
# 3
There is no silver bullet.
Which way is most efficient depnds on number of factors
- not just number of pixels being udated but also image
characteristics (size, is it cached, etc.) and even system
(e.g. consider remote display case).
setRGB has bigger overhead per pixel access comparing
to Raster/DataBuffer . However, setup and sideeffect costs
(e.g. image will be invalidated in the video memory and has to be copied
there again) for Raster/DataBuffer may be bigger than total per pixel
access overhead.
# 4
Although I already granted you the well deserved duke dollars assigned to this post, is there any chance you could point me in the right direction (like tutorial or spesific api reference section) for the second alternative?Thanks for the help btw :)
# 5
Well, i do not know good tutorial but basic things should be fairly straigtforward.
Read
http://java.sun.com/developer/technicalArticles/GUI/java2d/java2dpart2.html
and API docs on Raster/WritableRaster.
Pages here may have some related examples:
http://kickjava.com/1925.htm