Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: is it only a performace problem?



Thanks for the testcase. I do see the behavior you are describing. My
testing indicates that this particular performance problem has been
fixed in Java141Update1DP102.

M McDougall

On Wednesday, August 27, 2003, at 06:00 AM, Edoardo Panfili wrote:

> This is the code, I use BufferedOutputStream(os,1024*200)
> but nothing changes, if I cut out the code betweeen "==="
> all works better.
>
> thank you
> edoardo
>
> ------------------------------Java2DChain.java-----------------
> public class Java2DChain {
> private static long start_time;
> private static void start(String s){
> System.out.print(s);
> start_time=System.currentTimeMillis();
> }
> private static void stop(String s){
> long stop_time=System.currentTimeMillis();
> System.out.println(s+" ["+(stop_time-start_time)+" msec]");
> }
>
> public static void main(String args[]) throws
> FileNotFoundException, IOException{
>
> long startGlobal=System.currentTimeMillis();
>
> start("Retrieving the original image... ");
> BufferedImage bi=ImageIO.read(new FileInputStream("white.jpg"));
> stop("OK.");
>
> // ======== cutting out this part works better ======
> start("Drawing something... ");
> Graphics2D gr2d=(Graphics2D) bi.createGraphics();
> gr2d.setColor(Color.RED);
> gr2d.drawLine(1,1,10,10);
> stop("OK");
> // ==================================================
>
> start("Get first available jpeg writer... ");
> ImageWriter writer =
> (ImageWriter)(ImageIO.getImageWritersByFormatName("jpg").next());
> stop("OK");
>
> start("Setting up writer parameters... ");
> ImageWriteParam iwparam = new
> JPEGImageWriteParam(Locale.getDefault());
> iwparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT) ;
> iwparam.setCompressionQuality(1.0f);
> stop("OK.");
>
> start("Building the output stream... ");
> FileOutputStream os=new FileOutputStream("out.jpg");
> BufferedOutputStream bos = new BufferedOutputStream(os,1024*200);
> ImageOutputStream ios = ImageIO.createImageOutputStream(bos);
> stop("OK.");
>
> start("Building IIOImage...");
> IIOImage aggregato=new IIOImage(bi, null, null);
> stop("OK.");
>
> start("Writing the file... ");
> writer.setOutput(ios);
> //writer.addIIOWriteProgressListener(new
> AscoltatoreWriteProgress());
> writer.write(null, aggregato,iwparam);
> ios.close();
> bos.close();
> os.close();
> stop("OK.");
>
> System.out.println("Global
> time:"+(System.currentTimeMillis()-startGlobal));
> }
> }
> _______________________________________________
> java-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/java-dev
> Be sure to read the FAQ http://developer.apple.com/java/faq/ before
> posting
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: is it only a performace problem? (From: Edoardo Panfili <email@hidden>)



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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.