Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / November 2006

Tip: Looking for answers? Try searching our database.

Resample image - drawImage exception

Thread view: 
karthikeyan.jambulingam@gmail.com - 15 Nov 2006 06:25 GMT
Hi,

Am resampling the images to be displayed in my web page for different
height and width . This is the code i use for it whenever the height
and width changes:

ServletOutputStream sout = response.getOutputStream();
ImageIO.setUseCache(false);
BufferedImage bufImg = ImageIO.read(new File(src));
Image scaledImage = bufImg.getScaledInstance( width, height,
Image.SCALE_SMOOTH);
BufferedImage scaledBufImage = new BufferedImage(width, height ,
BufferedImage.TYPE_INT_RGB);
Graphics grphcs = scaledBufImage.createGraphics();
grphcs.drawImage(scaledImage, 0, 0, null);
grphcs.dispose()';
ImageIO.write(scaledBufImage , "jpg" , sout);

bufImg.flush();
scaleImage.flush();
scaledBufImage.flush();
sout.flush();
sout.close();

This code works fine . But take up to 100%CPU after some time , when
thread dump was taken a lot of threads remained in locked condition.
This was the dump for the locked thread:

    at sun.awt.color.CMM.cmmColorConvert(Native Method)
    at sun.awt.color.ICC_Transform.colorConvert(ICC_Transform.java:859)
    at java.awt.color.ICC_ColorSpace.toRGB(ICC_ColorSpace.java:160)
    at
java.awt.image.ComponentColorModel.getRGB(ComponentColorModel.java:1127)
    at java.awt.image.BufferedImage.getRGB(BufferedImage.java:870)
    at
sun.awt.image.OffScreenImageSource.sendPixels(OffScreenImageSource.java:157)
    at
sun.awt.image.OffScreenImageSource.produce(OffScreenImageSource.java:169)
    at
sun.awt.image.OffScreenImageSource.addConsumer(OffScreenImageSource.java:48)
    - locked <0x4f4e9a30> (a sun.awt.image.OffScreenImageSource)
    at
sun.awt.image.OffScreenImageSource.startProduction(OffScreenImageSource.java:62)
    at
java.awt.image.FilteredImageSource.startProduction(FilteredImageSource.java:166)
    at
sun.awt.image.ImageRepresentation.startProduction(ImageRepresentation.java:647)
    at
sun.awt.image.ImageRepresentation.drawToBufImage(ImageRepresentation.java:722)
    at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:855)
    at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:168)
    at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2833)
    at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2818)

Am using java 1.5 in a linux box . Is there any issues with drawImage
method , if so is there any alternative ways to resample images.
Searched thru the web , but was not able to find useful messages.

Thanks for your help.

Regards
JK
karthikeyan.jambulingam@gmail.com - 15 Nov 2006 16:49 GMT
Hi,

Have posted the same in Programmer group . so lets continue with this
question in that group.
Thanks .

Regards
JK

> Hi,
>
[quoted text clipped - 58 lines]
> Regards
> JK


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.