Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: drawImage speed (solved)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: drawImage speed (solved)



On 2 Nov 2005, at 19:13, Michael McDougall wrote:

We're very  interested in taking a closer look at this case.  It would be great if you could provide a testcase that we could run from the command line, rather than  pseudo-code, so we can be sure that we are actually investigating the same issue that you are seeing.

In particular, "swap image1 and image2" is vague.  If you are doing direct pixel manipulation (like setpixel) that this is known to be a very non-optimal (aka abysmal) case.

Hi,

Thanks for the speedy reply, and thanks also to Jeremy Wood who sent me a test program which nudged me on the right track. After a long time transforming my code and the test code into the same form and still getting totally different results, I had a D'Oh! moment. I said in the original post that my image was TYPE_INT_ARGB. However, this turned out not to be the case. In my test program I was using ImageIO.read to read a PNG image and it turned out to be of TYPE_CUSTOM. Normally, I make sure that I''ve got TYPE_INT_ARGB images, but the conversion got missed out by accident. Converting to TYPE_INT_ARGB did the trick. The TYPE_CUSTOM case is still way slower than Windows though, (but I don't care).

Jerry

For reference, here's cut down code which illustrates the problem:

        BufferedImage dst = createCompatibleDestImage( src, null );
        BufferedImage tmp = createCompatibleDestImage( src, null );
        for ( int i = 0; i < steps; i++ ) {
            Graphics2D g = tmp.createGraphics();
            long t1 = System.currentTimeMillis();
            g.drawImage( tsrc, null, null );
            t1 = System.currentTimeMillis()-t1;

            long t2 = System.currentTimeMillis();
            g.drawImage( dst, null, null );
            t2 = System.currentTimeMillis()-t2;
            g.dispose();
            System.out.println(t1+" "+t2);

            BufferedImage ti = dst;
            dst = tmp;
            tmp = ti;
            tsrc = dst;
        }

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >drawImage speed (From: Jerry <email@hidden>)
 >Re: drawImage speed (From: Jeremy Wood <email@hidden>)
 >Re: drawImage speed (From: Jerry <email@hidden>)
 >Re: drawImage speed (From: Michael McDougall <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.