ImageEditor.st
changeset 1383 179597c2abed
parent 1381 30fedb56e7db
child 1392 f6f7a70c5d41
equal deleted inserted replaced
1382:bf0c6d52d103 1383:179597c2abed
  2593 !
  2593 !
  2594 
  2594 
  2595 doCropManual
  2595 doCropManual
  2596     "let user specify borders and cut them off"
  2596     "let user specify borders and cut them off"
  2597 
  2597 
  2598     |bindings left top right bottom|
  2598     |bindings left top right bottom img|
  2599 
  2599 
  2600     bindings := IdentityDictionary new.
  2600     bindings := IdentityDictionary new.
  2601     bindings at:#left put:(left := 0 asValue).
  2601     bindings at:#left put:(left := 0 asValue).
  2602     bindings at:#right put:(right := 0 asValue).
  2602     bindings at:#right put:(right := 0 asValue).
  2603     bindings at:#top put:(top := 0 asValue).
  2603     bindings at:#top put:(top := 0 asValue).
  2606     ifTrue:[
  2606     ifTrue:[
  2607         left := left value.
  2607         left := left value.
  2608         right := right value.
  2608         right := right value.
  2609         top := top value.
  2609         top := top value.
  2610         bottom := bottom value.
  2610         bottom := bottom value.
       
  2611         img := imageEditView image.
  2611         imageEditView
  2612         imageEditView
  2612             makeSubImageX:left y:top 
  2613             makeSubImageX:left y:top 
  2613             width:(imageEditView image width - left - right)
  2614             width:(img width - left - right)
  2614             height:(imageEditView image height - top - bottom).
  2615             height:(img height - top - bottom).
  2615         self updateInfoLabel
  2616         self updateInfoLabel
  2616     ].
  2617     ].
  2617 
  2618 
  2618     "Created: / 7.9.1998 / 18:16:07 / cg"
  2619     "Created: / 7.9.1998 / 18:16:07 / cg"
  2619     "Modified: / 7.9.1998 / 18:20:42 / cg"
  2620     "Modified: / 7.9.1998 / 18:20:42 / cg"
  2805 !
  2806 !
  2806 
  2807 
  2807 doNewImage
  2808 doNewImage
  2808     "opens a dialog with choices of size and color map for creating a new image"
  2809     "opens a dialog with choices of size and color map for creating a new image"
  2809 
  2810 
  2810     |aspects|
  2811     |aspects width height cMap imageClass image szString|
       
  2812 
  2811 
  2813 
  2812     aspects  := IdentityDictionary new
  2814     aspects  := IdentityDictionary new
  2813         at:#listOfSizes         put: self class listOfDefaultSizes asValue;
  2815         at:#listOfSizes         put: self class listOfDefaultSizes asValue;
  2814         at:#listOfColorMaps     put: self class listOfColorMaps keys asSortedCollection asValue;
  2816         at:#listOfColorMaps     put: self class listOfColorMaps keys asSortedCollection asValue;
  2815         at:#selectionOfSize     put: self class listOfDefaultSizes first copy asValue;
  2817         at:#selectionOfSize     put: self class listOfDefaultSizes first copy asValue;
  2816         at:#selectionOfColorMap put: self class listOfColorMaps keys asSortedCollection first asValue;
  2818         at:#selectionOfColorMap put: self class listOfColorMaps keys asSortedCollection first asValue;
  2817         yourself.
  2819         yourself.
  2818 
  2820 
  2819     (self openDialogInterface:#dialogSpecForNewImage withBindings:aspects)
  2821     (self openDialogInterface:#dialogSpecForNewImage withBindings:aspects)
  2820     ifTrue:
  2822     ifTrue:[
  2821     [
  2823         szString := (aspects at:#selectionOfSize) value.
  2822         |width height cMap imageClass image|
  2824         width  := 128 min: (Integer readFromString: (szString upTo: $x) onError:[24]).
  2823 
  2825         height := 128 min: (Integer readFromString: (szString copy reverse upTo: $x) reverse onError:[24]).
  2824         width  := 128 min: (Integer readFromString: ((aspects at:#selectionOfSize) value upTo: $x) onError:[24]).
       
  2825         height := 128 min: (Integer readFromString: ((aspects at:#selectionOfSize) value copy reverse upTo: $x) reverse onError:[24]).
       
  2826 
  2826 
  2827         cMap       := (self class listOfColorMaps at: (colorMapMode value: (aspects at:#selectionOfColorMap) value) value).
  2827         cMap       := (self class listOfColorMaps at: (colorMapMode value: (aspects at:#selectionOfColorMap) value) value).
  2828         imageClass := Image implementorForDepth: ((cMap size log: 2) asInteger).
  2828         imageClass := Image implementorForDepth: ((cMap size log: 2) asInteger).
  2829         image      := imageClass width: width height: height fromArray: (ByteArray new: width*height).
  2829         image      := imageClass width: width height: height fromArray: (ByteArray new: width*height).
  2830 
  2830 
  2883     "Modified: / 10.9.1998 / 16:01:23 / cg"
  2883     "Modified: / 10.9.1998 / 16:01:23 / cg"
  2884 !
  2884 !
  2885 
  2885 
  2886 nextImageInSequence
  2886 nextImageInSequence
  2887     "display the next image in the image sequence"
  2887     "display the next image in the image sequence"
  2888     |img seq frame|
  2888     |img seq frame listOfColors|
  2889 
  2889 
  2890     imageEditView releaseUndos.
  2890     imageEditView releaseUndos.
  2891 
  2891 
  2892     seq := self image imageSequence.
  2892     seq := self image imageSequence.
  2893     imageSeqNr isNil ifTrue:[
  2893     imageSeqNr isNil ifTrue:[
  2900     ].
  2900     ].
  2901     frame := seq at:imageSeqNr.
  2901     frame := seq at:imageSeqNr.
  2902     imageEditView image:(frame image).
  2902     imageEditView image:(frame image).
  2903 
  2903 
  2904     (img := self image) notNil ifTrue:[          
  2904     (img := self image) notNil ifTrue:[          
       
  2905         listOfColors := self listOfColors.
  2905         img colorMap notNil ifTrue:[
  2906         img colorMap notNil ifTrue:[
  2906             self listOfColors contents:(img usedColors asSet asOrderedCollection).
  2907             listOfColors contents:(img usedColors asSet asOrderedCollection).
  2907         ] ifFalse:[
  2908         ] ifFalse:[
  2908             self listOfColors removeAll.
  2909             listOfColors removeAll.
  2909         ].
  2910         ].
  2910         self findColorMapMode.     
  2911         self findColorMapMode.     
  2911         self updateLabelsAndHistory.
  2912         self updateLabelsAndHistory.
  2912         img := img onDevice:device.
  2913         img := img onDevice:device.
  2913         imageEditView image:img.
  2914         imageEditView image:img.