allow display and extract from image sequences (gif anims)
authorClaus Gittinger <cg@exept.de>
Mon, 03 Jul 2000 17:33:19 +0200
changeset 1380 9787c42843c2
parent 1379 1a2e94a447e1
child 1381 30fedb56e7db
allow display and extract from image sequences (gif anims)
ImageEditor.st
--- a/ImageEditor.st	Fri Jun 16 13:28:21 2000 +0200
+++ b/ImageEditor.st	Mon Jul 03 17:33:19 2000 +0200
@@ -14,7 +14,7 @@
 
 ToolApplicationModel subclass:#ImageEditor
 	instanceVariableNames:'imageEditView colorMapMode editMode mouseKeyColorMode
-		selectedColorIndex postOpenAction'
+		selectedColorIndex postOpenAction imageSeqNr'
 	classVariableNames:'LastDirectory'
 	poolDictionaries:''
 	category:'Interface-UIPainter'
@@ -908,6 +908,12 @@
                   #activeHelpKey: #fileGrabImage
                 )
                #(#MenuItem
+                  #label: 'Next In Sequence'
+                  #translateLabel: true
+                  #value: #nextImageInSequence
+                  #enabled: #imageHasNextImage
+                )
+               #(#MenuItem
                   #label: '-'
                 )
                #(#MenuItem
@@ -1492,6 +1498,15 @@
     "Created: / 30.9.1998 / 23:53:55 / cg"
 !
 
+imageHasNextImage
+    "returns whether an image is loaded as value holder"
+
+    ^ [self image notNil
+       and:[self image imageSequence notNil]]
+
+    "Created: / 31.7.1998 / 02:04:18 / cg"
+!
+
 imageInfoHolder
     |holder|
     (holder := builder bindingAt:#imageInfoHolder) isNil ifTrue:[
@@ -2738,6 +2753,7 @@
     |img|
 
     (imageEditView loadFromClass) notNil ifTrue:[
+        imageSeqNr := nil.
         (img := self image) notNil ifTrue: [
             self listOfColors contents: img usedColors asSet asOrderedCollection.
             self findColorMapMode.
@@ -2753,6 +2769,7 @@
 
     |img file dir filters|
 
+    imageSeqNr := nil.
     img := self image.
     img notNil ifTrue: [
         file := img fileName
@@ -2827,6 +2844,7 @@
         addTimedBlock:[
             |image d8image img|
 
+            imageSeqNr := nil.
             image := Image fromUser.
             image isNil ifFalse:[
                 image depth > 8 ifTrue:[
@@ -2855,6 +2873,40 @@
 
     "Created: / 29.7.1998 / 21:24:42 / cg"
     "Modified: / 10.9.1998 / 16:01:23 / cg"
+!
+
+nextImageInSequence
+    "display the next image in the image sequence"
+    |img seq frame|
+
+    imageEditView releaseUndos.
+
+    seq := self image imageSequence.
+    imageSeqNr isNil ifTrue:[
+        imageSeqNr := 1.
+    ].
+    imageSeqNr := imageSeqNr + 1.
+    imageSeqNr > seq size ifTrue:[
+        self information:'Back to first image in sequence'.
+        imageSeqNr := 1.
+    ].
+    frame := seq at:imageSeqNr.
+    imageEditView image:(frame image).
+
+    (img := self image) notNil ifTrue:[          
+        img colorMap notNil ifTrue:[
+            self listOfColors contents:(img usedColors asSet asOrderedCollection).
+        ] ifFalse:[
+            self listOfColors removeAll.
+        ].
+        self findColorMapMode.     
+        self updateLabelsAndHistory.
+        img := img onDevice:device.
+        imageEditView image:img.
+    ] ifFalse:[
+        self updateForNoImage
+    ].
+
 ! !
 
 !ImageEditor methodsFor:'user actions - saving'!