@@ -0,0 +1,1792 @@
+/**%0D%0A * Copyright (C) 2012 Brookhaven National Laboratory%0D%0A * All rights reserved. Use is subject to license terms.%0D%0A */%0D%0Apackage org.epics.graphene.profile;%0D%0A%0D%0Aimport java.awt.Color;%0D%0Aimport java.awt.Graphics2D;%0D%0Aimport java.awt.image.BufferedImage;%0D%0Aimport java.io.File;%0D%0Aimport java.io.IOException;%0D%0Aimport java.util.Random;%0D%0Aimport javax.imageio.ImageIO;%0D%0A%0D%0A/**%0D%0A *%0D%0A * @author carcassi%0D%0A */%0D%0Apublic class SetPixelVsDrawRect %7B%0D%0A    public static void main(String%5B%5D args) throws IOException %7B%0D%0A        // Checking the difference in performance in using Image.setRGB%0D%0A        // and Graphics2D.fillRect. It's about twice and fast.%0D%0A        int width = 600;%0D%0A        int height = 600;%0D%0A        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);%0D%0A        %0D%0A        Random rand  = new Random(0);%0D%0A        int%5B%5D values = new int%5B100000%5D;%0D%0A        for (int i = 0; i %3C values.length; i++) %7B%0D%0A            values%5Bi%5D = rand.nextInt(height);%0D%0A        %7D%0D%0A        %0D%0A        Graphics2D g = image.createGraphics();%0D%0A        int nAttempts = 1000;%0D%0A        StopWatch watch = new StopWatch(nAttempts);%0D%0A        for (int i = 0; i %3C nAttempts; i++) %7B%0D%0A            watch.start();%0D%0A            for (int j = 0; j %3C values.length; j++) %7B%0D%0A                int x = values%5Bj++%5D;%0D%0A                int y = values%5Bj%5D;%0D%0A                int rgb = values%5Bj%5D;%0D%0A//                Color color = new Color(rgb);%0D%0A//                g.setColor(color);%0D%0A//                g.drawLine(x, y, x, y);%0D%0A//                g.fillRect(x, y, 1, 1);%0D%0A                image.setRGB(x, y, rgb);%0D%0A            %7D%0D%0A            watch.stop();%0D%0A        %7D%0D%0A        %0D%0A        ImageIO.write(image, %22png%22, new File(%22test.png%22));%0D%0A        System.out.println(watch.getAverageMs() + %22 ms%22);%0D%0A        %0D%0A        %0D%0A    %7D%0D%0A%7D%0D%0A

check performance between setRGB and drawRect