Hi all,

I have written the following method that iterates through all of the pixels of a 
BufferedImage,
setting the color of each one based on the output of a procedural texture algorithm.  
When I run
it on a 1280x1024 image on my 1.2GHz AMD machine, it takes about 5 seconds to render.  
At first I
thought it was my algorithm taking most of the time, but even when I changed it to 
just set a
constant color (as shown below; the procedural algorithm call is commented out), the 
time is about
the same.  I would expect just setting a constant color to be pretty fast.  Is there 
something I'm
doing in this code that is causing some behind the scenes conversions to happen or is 
this
slowness expected?  All I want to do is set the RGB values for each pixel, so any 
suggestions on
another way to do this are welcome.

Thanks,
Todd Klaus

private void drawImage() {

        image = new BufferedImage( getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB 
);
        Graphics2D g2 = (Graphics2D)image.getGraphics();

        if( texture != null ){
                for( int x = 0; x < image.getWidth(); x++ ){
                        for( int y = 0; y < image.getHeight(); y++ ){
                                float s = ((float)x)/((float)image.getWidth())*sRange;
                                float t = ((float)y)/((float)image.getHeight())*tRange;
                                //image.setRGB( x, y, texture.color(s,t).getRGB());
                                image.setRGB( x, y, Color.red.getRGB());
                        }
                }
        }
}

__________________________________________________
Do You Yahoo!?
Find a job, post your resume.
http://careers.yahoo.com

===========================================================================
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