• Post Reply Bookmark Topic Watch Topic
  • New Topic

image scaling error  RSS feed

 
Kay Tracid
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • 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!!!
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!