Win a copy of OCP Oracle Certified Professional Java SE 11 Developer Practice Tests this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

image scaling error

 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a program where I scale pictures. I wrote a methode for this action. I call this method two times, but one of the pictures has always strange stribes. If I call a Thread.sleep() between the two method calls, the pictures look fine. If I call the method only once, the one picture is fine, too. Can you help me please? Must I use Threads? I don't want it...but if theres is no other way i do it...

(I load the Image (parameter) before with a MediaTracker)
Thanks!!!
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just weird!

Scaling has random glitches when called multiple times... It partly depends on the algorithm you use, too... Image.SCALE_SMOOTH messes up about 8 in 10 times, whereas Image.SCALE_FAST messes up only about 2 in 10 times... If you put a Thread.sleep( 1 ) between calls everything works out fine, though... (However, Thread.sleep( 0 ) and Thread.yield() do not help at all..) Looks like there may be some threading problems in there somewhere...

I would submit this as a bug in the bug database at java.sun.com and see what Sun says to do, or how (or when) they will fix it...

In the meantime I would just add a Thread.sleep( 1 ) between calls... I don't think 1 millisecond per image is a long time to wait anyway...

-Nate
 
Kay Tracid
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!!!
Now I'm writing the method as a thread, i hope this will work fine, but it seems so.
 
Forget this weirdo. You guys wanna see something really neat? I just have to take off my shoe .... (hint: it's a tiny ad)
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic