Mantis - Squeak
Viewing Issue Advanced Details
5692 Morphic minor always 01-02-07 02:52 09-09-08 15:34
haleden  
 
normal  
closed 3.9  
fixed  
none    
none 3.10  
0005692: AnimatedImageMorph
final-7067

some animated gifs draw strangely (artifacts from previous steps remain on display).

using the previous image to draw in erase mode in the step method seems to help.

step
    | f d |
    images isEmpty
        ifTrue: [^ self].
    nextTime > Time millisecondClockValue
        ifTrue: [^self].
    f _ images at: imageIndex.
    f displayOn: self image at: 0@0 rule: Form erase.
    imageIndex _ imageIndex \\ images size + 1.
    f _ images at: imageIndex.
    f displayOn: self image at: 0@0 rule: Form paint.
    self invalidRect: (self position + f offset extent: f extent) .
    d _ (delays at: imageIndex) ifNil: [0].
    nextTime := Time millisecondClockValue + d

here is a gif that shows the behavior described and works with the described change
 Dragon-18-june.gif [^] (32,099 bytes) 01-02-07 02:52
 AnimatedImageMorph-step.st [^] (481 bytes) 01-02-07 04:37

Notes
(0008784)
haleden   
01-02-07 02:58   
guess needed to check bondary condition

step
    | f d |
    images isEmpty
        ifTrue: [^ self].
    nextTime > Time millisecondClockValue
        ifTrue: [^self].
    imageIndex > 0 ifTrue: [
        f _ images at: imageIndex.
        f displayOn: self image at: 0@0 rule: Form erase.
    ].
    imageIndex _ imageIndex \\ images size + 1.
    f _ images at: imageIndex.
    f displayOn: self image at: 0@0 rule: Form paint.
    self invalidRect: (self position + f offset extent: f extent) .
    d _ (delays at: imageIndex) ifNil: [0].
    nextTime := Time millisecondClockValue + d
(0008785)
wiz   
01-02-07 04:35   
Hmmm.

This sounds like a need to do a self changed before and after
the image change so the invalid rectangle is set to include both the before and after bounds. The usual error is to just do on self changed after the update. If the before bounds is not encompassed by the after the left over pixels can persist.

so looking at your code
a simple
self changed.
self image: images at: imageIndex.
self changed.

should work .

And it does... Try uploaded #step fix.


Yours in service, -- Jerome Peace

P.S. nice dragon.

P.P.S.
I do not know if this fix solves all possible problems. Can you think of some good sUnit tests to give animated gifs a work out? That would be helpful.

P.P.P.S. problem was being caused by the drawing on Translucent pixels.
My fix worked because we eliminated that by shifting the drawing to the imageMorph draw on function where it probably belongs anyway.

I found this out when I set your dragon to be the background pattern.
Whenever the annimation drew over the "transparent" portion of the background the pixels stuck.

(0008786)
haleden   
01-02-07 06:01   
ahh, yes, that is much better.

the gif is one i downloaded to play with in squeak (from bestanimations.com) while showing squeak to my son, and i just thought that something was wrong, so i tried something to make it work--your solution is much better.

i don't know enough about the animated gifs to be able come up with a general case--i was just acting as a user in this case. an sunit might be tricky--could there be a comparison of the current image with the current animation step?

hal
(0010944)
wiz   
07-28-07 22:43   
I don't know when this got included but the patch is in 7130 so this can be resolved.
(0010948)
ScottWallace   
07-29-07 06:40   
Jerome, the first "self changed" in your fix is superfluous, since in the very next line, "self image: ..." is sent, and the first thing that #image: does is send "self changed".
(0011460)
matthewf   
11-24-07 17:06   
Reminder sent to: edgardec

Has this issue been fixed? It is listed on http://wiki.squeak.org/squeak/5961 [^] as ready
(0011463)
edgardec   
11-24-07 19:53   
Was fixed , loooong time ago.
And I send a cute running cheetah to Jerome for test this
(0012607)
KenCausey   
09-09-08 15:33   
Harvested in update 7088 and released in 3.10. I believe Scott's point is valid but a new issue should be opened to address it.