ImageEditor.st
changeset 1053 31097504a15a
parent 1047 f2d55d342903
child 1054 ef98bc11d1fd
equal deleted inserted replaced
1052:2b65eda2938e 1053:31097504a15a
   100     "opens a Image Editor on anImage"
   100     "opens a Image Editor on anImage"
   101     "
   101     "
   102      self openOnImage: Icon startIcon
   102      self openOnImage: Icon startIcon
   103     "
   103     "
   104 
   104 
   105     ^self open loadFromImage: anImage
   105     |editor|
       
   106 
       
   107     editor := self new.
       
   108     editor allButOpen.
       
   109     editor loadFromImage: anImage.
       
   110     editor openWindow
       
   111 
       
   112     "Modified: / 11.3.1999 / 16:18:33 / cg"
   106 ! !
   113 ! !
   107 
   114 
   108 !ImageEditor class methodsFor:'accessing'!
   115 !ImageEditor class methodsFor:'accessing'!
   109 
   116 
   110 listOfColorMaps
   117 listOfColorMaps
   590      
   597      
   591        #(#FullSpec
   598        #(#FullSpec
   592           #window: 
   599           #window: 
   593            #(#WindowSpec
   600            #(#WindowSpec
   594               #name: 'Image Editor'
   601               #name: 'Image Editor'
   595               #layout: #(#LayoutFrame 176 0 156 0 675 0 501 0)
   602               #layout: #(#LayoutFrame 507 0 28 0 1004 0 371 0)
       
   603               #level: 0
   596               #label: 'Image Editor'
   604               #label: 'Image Editor'
   597               #min: #(#Point 400 320)
   605               #min: #(#Point 400 320)
   598               #max: #(#Point 1152 900)
   606               #max: #(#Point 1152 900)
   599               #bounds: #(#Rectangle 176 156 676 502)
   607               #bounds: #(#Rectangle 507 28 1005 372)
   600               #menu: #menu
   608               #menu: #menu
   601               #usePreferredExtent: false
   609               #usePreferredExtent: false
       
   610               #returnIsOKInDialog: true
       
   611               #escapeIsCancelInDialog: true
   602           )
   612           )
   603           #component: 
   613           #component: 
   604            #(#SpecCollection
   614            #(#SpecCollection
   605               #collection: 
   615               #collection: 
   606                #(
   616                #(
   645                                                          #(#DataSetSpec
   655                                                          #(#DataSetSpec
   646                                                             #name: 'colorDataSetView'
   656                                                             #name: 'colorDataSetView'
   647                                                             #layout: #(#LayoutFrame 0 0.0 26 0.0 0 1.0 0 1.0)
   657                                                             #layout: #(#LayoutFrame 0 0.0 26 0.0 0 1.0 0 1.0)
   648                                                             #activeHelpKey: #colorMapTable
   658                                                             #activeHelpKey: #colorMapTable
   649                                                             #model: #selectionOfColor
   659                                                             #model: #selectionOfColor
       
   660                                                             #menu: #colorMapMenu
   650                                                             #style: #(#FontDescription #helvetica #medium #roman 10)
   661                                                             #style: #(#FontDescription #helvetica #medium #roman 10)
   651                                                             #hasHorizontalScrollBar: true
   662                                                             #hasHorizontalScrollBar: true
   652                                                             #hasVerticalScrollBar: true
   663                                                             #hasVerticalScrollBar: true
   653                                                             #miniScrollerHorizontal: true
   664                                                             #miniScrollerHorizontal: true
   654                                                             #miniScrollerVertical: true
   665                                                             #miniScrollerVertical: true
   715                                   )
   726                                   )
   716                               )
   727                               )
   717                           )
   728                           )
   718                            #(#ViewSpec
   729                            #(#ViewSpec
   719                               #name: 'view2'
   730                               #name: 'view2'
       
   731                               #level: -1
   720                               #component: 
   732                               #component: 
   721                                #(#SpecCollection
   733                                #(#SpecCollection
   722                                   #collection: 
   734                                   #collection: 
   723                                    #(
   735                                    #(
   724                                      #(#ArbitraryComponentSpec
   736                                      #(#ArbitraryComponentSpec
   730                                         #hasBorder: false
   742                                         #hasBorder: false
   731                                     )
   743                                     )
   732                                      #(#LabelSpec
   744                                      #(#LabelSpec
   733                                         #name: 'coordLabel'
   745                                         #name: 'coordLabel'
   734                                         #layout: #(#LayoutFrame 2 0.0 -22 1 -83 1.0 0 1.0)
   746                                         #layout: #(#LayoutFrame 2 0.0 -22 1 -83 1.0 0 1.0)
       
   747                                         #level: -1
   735                                         #labelChannel: #imageInfoHolder
   748                                         #labelChannel: #imageInfoHolder
   736                                         #level: -1
   749                                         #resizeForLabel: false
   737                                         #adjust: #left
   750                                         #adjust: #left
   738                                         #resizeForLabel: false
       
   739                                     )
   751                                     )
   740                                      #(#ArrowButtonSpec
   752                                      #(#ArrowButtonSpec
   741                                         #name: 'magnifyDownButton'
   753                                         #name: 'magnifyDownButton'
   742                                         #layout: #(#LayoutFrame -80 1 -22 1 -58 1 0 1)
   754                                         #layout: #(#LayoutFrame -80 1 -22 1 -58 1 0 1)
   743                                         #activeHelpKey: #magnifyImageDown
   755                                         #activeHelpKey: #magnifyImageDown
   768                                         #minValue: 1
   780                                         #minValue: 1
   769                                         #maxValue: 99
   781                                         #maxValue: 99
   770                                     )
   782                                     )
   771                                   )
   783                                   )
   772                               )
   784                               )
   773                               #level: -1
       
   774                           )
   785                           )
   775                         )
   786                         )
   776                     )
   787                     )
   777                     #handles: #(#Any 0.276 1.0)
   788                     #handles: #(#Any 0.276 1.0)
   778                 )
   789                 )
   784                 )
   795                 )
   785               )
   796               )
   786           )
   797           )
   787       )
   798       )
   788 
   799 
   789     "Modified: / 7.8.1998 / 22:52:28 / cg"
   800     "Modified: / 12.3.1999 / 00:15:05 / cg"
   790 ! !
   801 ! !
   791 
   802 
   792 !ImageEditor class methodsFor:'menu specs'!
   803 !ImageEditor class methodsFor:'menu specs'!
       
   804 
       
   805 colorMapMenu
       
   806     "This resource specification was automatically generated
       
   807      by the MenuEditor of ST/X."
       
   808 
       
   809     "Do not manually edit this!! If it is corrupted,
       
   810      the MenuEditor may not be able to read the specification."
       
   811 
       
   812     "
       
   813      MenuEditor new openOnClass:ImageEditor andSelector:#menuSpec
       
   814      (Menu new fromLiteralArrayEncoding:(ImageEditor menuSpec)) startUp
       
   815     "
       
   816 
       
   817     <resource: #menu>
       
   818 
       
   819     ^
       
   820      
       
   821        #(#Menu
       
   822           
       
   823            #(
       
   824              #(#MenuItem
       
   825                 #label: 'Add Color'
       
   826                 #translateLabel: true
       
   827                 #value: #addColorToColormap
       
   828             )
       
   829           ) nil
       
   830           nil
       
   831       )
       
   832 
       
   833     "Created: / 12.3.1999 / 00:19:00 / cg"
       
   834 !
   793 
   835 
   794 menu
   836 menu
   795     "This resource specification was automatically generated
   837     "This resource specification was automatically generated
   796      by the MenuEditor of ST/X."
   838      by the MenuEditor of ST/X."
   797 
   839 
  1863     "Modified: / 29.7.1998 / 18:49:20 / cg"
  1905     "Modified: / 29.7.1998 / 18:49:20 / cg"
  1864 ! !
  1906 ! !
  1865 
  1907 
  1866 !ImageEditor methodsFor:'user actions - colormap'!
  1908 !ImageEditor methodsFor:'user actions - colormap'!
  1867 
  1909 
       
  1910 addColorToColormap
       
  1911     |d img cMap newCMap|
       
  1912 
       
  1913     img := self image.
       
  1914     d := img depth.
       
  1915     cMap := img colorMap.
       
  1916     ((d == 1)
       
  1917     or:[cMap size == (1 bitShift:d)]) ifTrue:[
       
  1918         d >= 8 ifTrue:[
       
  1919             self warn:'No space for more colors in colormap.'.
       
  1920             ^ self
       
  1921         ].
       
  1922         (self confirm:'No space for more colors in colormap.\Change depth ?' withCRs)
       
  1923         ifFalse:[
       
  1924             ^ self
       
  1925         ]
       
  1926     ].
       
  1927     newCMap := cMap asArray copyWith:(Color black).
       
  1928     img colorMap:newCMap.
       
  1929     self listOfColors contents: newCMap.
       
  1930 
       
  1931     "Created: / 12.3.1999 / 00:20:28 / cg"
       
  1932     "Modified: / 12.3.1999 / 02:09:01 / cg"
       
  1933 !
       
  1934 
  1868 colorMapChanged
  1935 colorMapChanged
  1869     |img|
  1936     |img|
  1870 
  1937 
  1871     img := self image.
  1938     img := self image.
  1872     img release.
  1939     img release.
  1891      prevMode maskThreshold maskImage| 
  1958      prevMode maskThreshold maskImage| 
  1892 
  1959 
  1893     self withExecuteCursorDo:[
  1960     self withExecuteCursorDo:[
  1894         oldImage := self image.
  1961         oldImage := self image.
  1895 
  1962 
  1896         prevMode := colorMapMode.
  1963         prevMode := colorMapMode value.
  1897         oldImage depth > 8 ifTrue:[
  1964         oldImage depth > 8 ifTrue:[
  1898             prevMode := nil
  1965             prevMode := nil
  1899         ].
  1966         ].
  1900 
  1967 
  1901         newColorMap := self class listOfColorMaps at:aMode.
  1968         newColorMap := self class listOfColorMaps at:aMode.
  2064             self findColorMapMode.
  2131             self findColorMapMode.
  2065             self updateLabelsAndHistory.
  2132             self updateLabelsAndHistory.
  2066         ]
  2133         ]
  2067     ]
  2134     ]
  2068 
  2135 
  2069     "Modified: / 30.9.1998 / 23:44:19 / cg"
  2136     "Modified: / 11.3.1999 / 16:20:09 / cg"
  2070 !
  2137 !
  2071 
  2138 
  2072 compressColorMap
  2139 compressColorMap
  2073     "calculates a new color map for the image, using only used colors"
  2140     "calculates a new color map for the image, using only used colors"
  2074 
  2141