This content has been marked as final. Show 9 replies
firstname.lastname@example.org wrote:I assume you are reading your image from somewhere, right? A file, a db, a socket?
why do i want to create an buffered image from a stream?
And, if you drawing your image, create a BufferedImage first, then use that Graphics2D to draw it, then you can still call getRGB after drawing.
note: getrgb drops AlphaAlso, to tell you the truth, I have no idea why you feel the need to pass the data around as a color array, anyway. Why are you not simply passing around the actual Image, or Graphics.
my image is already loaded on startup and passed to my panel (which can be implemented in swing or swt)
why array ? -> cause i use my filters as "plugins" for a panel (implemented in SWT and Swing)
and swt and swing use different Image constructs (i was not able to transfer one into the other - have to admit that i did not really tried it..)
i am passing the array to my plugin, return the array and simply draw the graphics ONCE on the panel (which is way faster than drawing thousand times image on image...)
You are better off working with the actual images. If they are subclasses of Image, you can use getGraphics directly, if they are not a subclass of Image, then, almost guaranteed they have a way of getting an Image based class from it, with which, you can, once again, call getGraphics.
And, since it is probably with Graphics with which it is to be modified, that seems the better way.
yeah i know its better to work with the image itself,
but converting between the formats swt awt is too slow.
i compared the image vs my array stuff (realtime high fps)
cpu % with image: 67%
cpu % with array: 57%
and to note (sleep 15ms between calculation) the fps dropped (could be balanced by removing the sleep, but still the array would be faster)
(i do not have a really fast computer here so therefore the high precentages are ok...)
Edited by: email@example.com on Mar 25, 2009 2:38 AM