At 19:31 2000-11-05 -0800, Todd C. Klaus wrote:

>for( int x = 0; x < img.getWidth(); x++ )
>{
>   for( int y = 0; y < img.getHeight(); y++ )
>   {
>     int color = img.getRGB(x,y);
>     color = shadePixel(color);
>     img.setRGB(x,y,color);
>   }
>}
>
>This works fine, but I'm wondering if this is the most efficient way to do
>this.

I would try to replace any method calls in a heavy inner loop such as the
one above with the code that those methods actually perform. This removes
any method calling overhead, and has proven to be a nice performance
improvement - atleast for my programs (e.g. my simplistic 3D engine).

If your shadePixel method does some heavy work it could overshadow the
method calling overhead though, in which case my suggestion won't give much
improvement.


+---------------------------------------------------------+
|   Kenneth  /          http://kenjon.cjb.net/           /
|  Jonsson  /  PC, Amiga, C64 and KORG N364 enthusiast  /
+------------------------------------------------------+

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to