ImageEditor.st
changeset 1122 66e895f34b9b
parent 1121 9ceac76e1c8d
child 1123 7979a71001d0
equal deleted inserted replaced
1121:9ceac76e1c8d 1122:66e895f34b9b
  2598 !ImageEditor methodsFor:'user actions - loading'!
  2598 !ImageEditor methodsFor:'user actions - loading'!
  2599 
  2599 
  2600 doLoadFromClass
  2600 doLoadFromClass
  2601     "opens a dialog for loading an image from class and a (resource-) selector"
  2601     "opens a dialog for loading an image from class and a (resource-) selector"
  2602 
  2602 
       
  2603     |img|
       
  2604 
  2603     (imageEditView loadFromClass) notNil ifTrue:[
  2605     (imageEditView loadFromClass) notNil ifTrue:[
  2604         self image notNil ifTrue: [
  2606         (img := self image) notNil ifTrue: [
  2605             self listOfColors contents: self image usedColors asSet asOrderedCollection.
  2607             self listOfColors contents: img usedColors asSet asOrderedCollection.
  2606             self findColorMapMode.
  2608             self findColorMapMode.
  2607             self updateLabelsAndHistory
  2609             self updateLabelsAndHistory
  2608         ] ifFalse: [
  2610         ] ifFalse: [
  2609             self updateForNoImage
  2611             self updateForNoImage
  2610         ]
  2612         ]
  2612 !
  2614 !
  2613 
  2615 
  2614 doLoadFromFile
  2616 doLoadFromFile
  2615     "opens a dialog for loading an image from a file"
  2617     "opens a dialog for loading an image from a file"
  2616 
  2618 
       
  2619     |img|
       
  2620 
  2617     self loadFromFile:
  2621     self loadFromFile:
  2618         (FileSelectionBrowser
  2622         (FileSelectionBrowser
  2619             request: 'Load Image From'
  2623             request: 'Load Image From'
  2620             fileName: (self image notNil ifTrue: [self image fileName] ifFalse: [nil])
  2624             fileName: ((img := self image) notNil ifTrue: [img fileName] ifFalse: [nil])
  2621             withFileFilters: FileSelectionBrowser loadImageFileNameFilters)
  2625             withFileFilters: FileSelectionBrowser loadImageFileNameFilters)
  2622 !
  2626 !
  2623 
  2627 
  2624 doNewImage
  2628 doNewImage
  2625     "opens a dialog with choices of size and color map for creating a new image"
  2629     "opens a dialog with choices of size and color map for creating a new image"
  2670             |image d8image img|
  2674             |image d8image img|
  2671 
  2675 
  2672             image := Image fromUser.
  2676             image := Image fromUser.
  2673             image isNil ifFalse:[
  2677             image isNil ifFalse:[
  2674                 image depth > 8 ifTrue:[
  2678                 image depth > 8 ifTrue:[
  2675                     Object errorSignal handle:[:ex |
  2679                     Object errorSignal handle:[:ex | |sig|
  2676                         ex signal == Object haltSignal ifTrue:[ex reject].
  2680                         (sig := ex signal) == Object haltSignal ifTrue:[ex reject].
  2677                         ex signal == Signal noHandlerSignal ifTrue:[ex reject].
  2681                         sig == Signal noHandlerSignal ifTrue:[ex reject].
  2678 
  2682 
  2679                         self warn:'Could not convert to depth8 image (too many colors)'.
  2683                         self warn:'Could not convert to depth8 image (too many colors)'.
  2680                         d8image := nil.
  2684                         d8image := nil.
  2681                     ] do:[
  2685                     ] do:[
  2682                         d8image := Depth8Image new.
  2686                         d8image := Depth8Image new.