ImageEditor.st
changeset 3418 8d56341c2706
parent 3417 4960f19dca36
child 3419 dda4a17fdefc
equal deleted inserted replaced
3417:4960f19dca36 3418:8d56341c2706
   673     <resource: #programImage>
   673     <resource: #programImage>
   674 
   674 
   675     ^ ToolbarIconLibrary startImageEditorIcon
   675     ^ ToolbarIconLibrary startImageEditorIcon
   676 !
   676 !
   677 
   677 
       
   678 emptyIcon
       
   679     "This resource specification was automatically generated
       
   680      by the ImageEditor of ST/X."
       
   681 
       
   682     "Do not manually edit this!! If it is corrupted,
       
   683      the ImageEditor may not be able to read the specification."
       
   684 
       
   685     "
       
   686      self emptyIcon inspect
       
   687      ImageEditor openOnClass:self andSelector:#emptyIcon
       
   688      Icon flushCachedIcons
       
   689     "
       
   690 
       
   691     <resource: #image>
       
   692 
       
   693     ^Icon
       
   694         constantNamed:'ImageEditor class emptyIcon'
       
   695         ifAbsentPut:[(Depth4Image width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
       
   696 @@@@@@@@@@@b')
       
   697             colorMapFromArray:#[0 0 0]
       
   698             mask:((ImageMask width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@a'); yourself); yourself]
       
   699 !
       
   700 
       
   701 emptyIcon2
       
   702     "This resource specification was automatically generated
       
   703      by the ImageEditor of ST/X."
       
   704 
       
   705     "Do not manually edit this!! If it is corrupted,
       
   706      the ImageEditor may not be able to read the specification."
       
   707 
       
   708     "
       
   709      self emptyIcon2 inspect
       
   710      ImageEditor openOnClass:self andSelector:#emptyIcon2
       
   711      Icon flushCachedIcons
       
   712     "
       
   713 
       
   714     <resource: #image>
       
   715 
       
   716     ^Icon
       
   717         constantNamed:'ImageEditor class emptyIcon2'
       
   718         ifAbsentPut:[(Depth4Image width:28 height:14) bits:(ByteArray fromPackedString:'
       
   719 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
       
   720 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
       
   721 @@@@@@@@@@@@@@@@@@@@@@@a')
       
   722             colorMapFromArray:#[0 0 0]
       
   723             mask:((Depth1Image width:28 height:14) bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@b'); yourself); yourself]
       
   724 !
       
   725 
   678 fillCircleIcon
   726 fillCircleIcon
   679     "This resource specification was automatically generated
   727     "This resource specification was automatically generated
   680      by the ImageEditor of ST/X."
   728      by the ImageEditor of ST/X."
   681 
   729 
   682     "Do not manually edit this!! If it is corrupted,
   730     "Do not manually edit this!! If it is corrupted,
   693     ^Icon
   741     ^Icon
   694         constantNamed:'ImageEditor class fillCircleIcon'
   742         constantNamed:'ImageEditor class fillCircleIcon'
   695         ifAbsentPut:[(Depth1Image width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@@@A@@@@@@@@@@@@@@@C@@@@@@@@@@@@@@@a')
   743         ifAbsentPut:[(Depth1Image width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@@@A@@@@@@@@@@@@@@@C@@@@@@@@@@@@@@@a')
   696             colorMapFromArray:#[0 0 0 255 0 0]
   744             colorMapFromArray:#[0 0 0 255 0 0]
   697             mask:((ImageMask width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@@N@C>@_<A?0O? ?>C?8G?@_<@? @8@@@@@a'); yourself); yourself]
   745             mask:((ImageMask width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@@N@C>@_<A?0O? ?>C?8G?@_<@? @8@@@@@a'); yourself); yourself]
       
   746 !
       
   747 
       
   748 fillDiagonalGradientRectIcon
       
   749     "This resource specification was automatically generated
       
   750      by the ImageEditor of ST/X."
       
   751 
       
   752     "Do not manually edit this!! If it is corrupted,
       
   753      the ImageEditor may not be able to read the specification."
       
   754 
       
   755     "
       
   756      self fillDiagonalGradientRectIcon inspect
       
   757      ImageEditor openOnClass:self andSelector:#fillDiagonalGradientRectIcon
       
   758      Icon flushCachedIcons
       
   759     "
       
   760 
       
   761     <resource: #image>
       
   762 
       
   763     ^Icon
       
   764         constantNamed:'ImageEditor class fillDiagonalGradientRectIcon'
       
   765         ifAbsentPut:[(Depth4Image width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@QDQDQD@@@DQDQDQ@@@ADH"H"H@@@QBH"H"@@@DP"L3L0@@ADH#L3L@@@QBH3DQ@@@DP"L1DP@@ADH#LQD@@@@@@@@@
       
   766 @@@@@@@@@@@b')
       
   767             colorMapFromArray:#[0 0 0 255 0 0 127 0 0 191 0 0 91 0 0]
       
   768             mask:((ImageMask width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@C?0O?@?<C?0O?@?<C?0O?@?<C?0@@@@@@@a'); yourself); yourself]
   698 !
   769 !
   699 
   770 
   700 fillGradientRectIcon
   771 fillGradientRectIcon
   701     <resource: #image>
   772     <resource: #image>
   702     "This resource specification was automatically generated
   773     "This resource specification was automatically generated
   729                 yourself
   800                 yourself
   730         ]
   801         ]
   731 !
   802 !
   732 
   803 
   733 fillHorizontalGradientRectIcon
   804 fillHorizontalGradientRectIcon
   734     <resource: #image>
       
   735     "This resource specification was automatically generated
   805     "This resource specification was automatically generated
   736      by the ImageEditor of ST/X."
   806      by the ImageEditor of ST/X."
       
   807 
   737     "Do not manually edit this!! If it is corrupted,
   808     "Do not manually edit this!! If it is corrupted,
   738      the ImageEditor may not be able to read the specification."
   809      the ImageEditor may not be able to read the specification."
       
   810 
   739     "
   811     "
   740      self fillHorizontalGradientRectIcon inspect
   812      self fillHorizontalGradientRectIcon inspect
   741      ImageEditor openOnClass:self andSelector:#fillHorizontalGradientRectIcon
   813      ImageEditor openOnClass:self andSelector:#fillHorizontalGradientRectIcon
   742      Icon flushCachedIcons"
   814      Icon flushCachedIcons
   743     
   815     "
   744     ^ Icon constantNamed:'ImageEditor class fillHorizontalGradientRectIcon'
   816 
   745         ifAbsentPut:[
   817     <resource: #image>
   746             (Depth4Image new)
   818 
   747                 width:14;
   819     ^Icon
   748                 height:14;
   820         constantNamed:'ImageEditor class fillHorizontalGradientRectIcon'
   749                 photometric:(#palette);
   821         ifAbsentPut:[(Depth4Image width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@ADH#LQD@@@QBH3DQ@@@DP"L1DP@@ADH#LQD@@@QBH3DQ@@@DP"L1DP@@ADH#LQD@@@QBH3DQ@@@DP"L1DP@@ADH#LQD@@@@@@@@@
   750                 bitsPerSample:(#[ 4 ]);
   822 @@@@@@@@@@@b')
   751                 samplesPerPixel:(1);
   823             colorMapFromArray:#[0 0 0 255 0 0 127 0 0 191 0 0 91 0 0]
   752                 bits:(ByteArray 
   824             mask:((ImageMask width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@C?0O?@?<C?0O?@?<C?0O?@?<C?0@@@@@@@a'); yourself); yourself]
   753                             fromPackedString:'@@@@@@@@@@@@@@@@@@@@@DP"L1D@@@ADH#LQ@@@@QBH3DP@@@DP"L1D@@@ADH#LQ@@@@QBH3DP@@@DP"L1D@@@ADH#LQ@@@@QBH3DP@@@DP"L1D@@@@@@@@@
       
   754 @@@@@@@@@@@b');
       
   755                 colorMapFromArray:#[ 0 0 0 255 0 0 127 0 0 191 0 0 63 0 0 ];
       
   756                 mask:((ImageMask new)
       
   757                             width:14;
       
   758                             height:14;
       
   759                             bits:(ByteArray 
       
   760                                         fromPackedString:'@@@@@C?0O?@?<C?0O?@?<C?0O?@?<C?0@@@@@@@a');
       
   761                             yourself);
       
   762                 yourself
       
   763         ]
       
   764 !
   825 !
   765 
   826 
   766 fillIcon
   827 fillIcon
   767     <resource: #image>
   828     <resource: #image>
   768     "This resource specification was automatically generated
   829     "This resource specification was automatically generated
   826                 yourself
   887                 yourself
   827         ]
   888         ]
   828 !
   889 !
   829 
   890 
   830 fillVerticalGradientRectIcon
   891 fillVerticalGradientRectIcon
   831     <resource: #image>
       
   832     "This resource specification was automatically generated
   892     "This resource specification was automatically generated
   833      by the ImageEditor of ST/X."
   893      by the ImageEditor of ST/X."
       
   894 
   834     "Do not manually edit this!! If it is corrupted,
   895     "Do not manually edit this!! If it is corrupted,
   835      the ImageEditor may not be able to read the specification."
   896      the ImageEditor may not be able to read the specification."
   836     "
   897 
   837      self fillGradientRectIcon inspect
   898     "
   838      ImageEditor openOnClass:self andSelector:#fillGradientRectIcon
   899      self fillVerticalGradientRectIcon inspect
   839      Icon flushCachedIcons"
   900      ImageEditor openOnClass:self andSelector:#fillVerticalGradientRectIcon
   840     
   901      Icon flushCachedIcons
   841     ^ Icon constantNamed:'ImageEditor class fillGradientRectIcon'
   902     "
   842         ifAbsentPut:[
   903 
   843             (Depth4Image new)
   904     <resource: #image>
   844                 width:14;
   905 
   845                 height:14;
   906     ^Icon
   846                 photometric:(#palette);
   907         constantNamed:'ImageEditor class fillVerticalGradientRectIcon'
   847                 bitsPerSample:(#[ 4 ]);
   908         ifAbsentPut:[(Depth4Image width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@DQDQDQD@@ADQDQDQ@@@H"H"H"H@@BH"H"H"@@@3L3L3L0@@L3L3L3L@@ADQDQDQ@@@QDQDQDP@@DQDQDQD@@@@@@@@@
   848                 samplesPerPixel:(1);
   909 @@@@@@@@@@@b')
   849                 bits:(ByteArray 
   910             colorMapFromArray:#[0 0 0 255 0 0 127 0 0 191 0 0 91 0 0]
   850                             fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ADQDQDQ@@@QDQDQDP@@BH"H"H"@@@"H"H"H @@L3L3L3L@@CL3L3L3@@@QDQDQDP@@DQDQDQD@@@@@@@@@
   911             mask:((ImageMask width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@C?0O?@?<C?0O?@?<C?0O?@?<C?0@@@@@@@a'); yourself); yourself]
   851 @@@@@@@@@@@b');
       
   852                 colorMapFromArray:#[ 0 0 0 255 0 0 127 0 0 191 0 0 63 0 0 ];
       
   853                 mask:((ImageMask new)
       
   854                             width:14;
       
   855                             height:14;
       
   856                             bits:(ByteArray 
       
   857                                         fromPackedString:'@@@@@C?0O?@?<C?0O?@?<C?0O?@?<C?0@@@@@@@a');
       
   858                             yourself);
       
   859                 yourself
       
   860         ]
       
   861 
       
   862     "Created: / 19-01-2012 / 13:44:51 / cg"
       
   863 !
   912 !
   864 
   913 
   865 flipHorizontalIcon
   914 flipHorizontalIcon
   866     <resource: #image>
   915     <resource: #image>
   867     "This resource specification was automatically generated
   916     "This resource specification was automatically generated
  3721             labelImage: (ResourceRetriever ImageEditor fillIcon 'Fill')
  3770             labelImage: (ResourceRetriever ImageEditor fillIcon 'Fill')
  3722             choice: editMode
  3771             choice: editMode
  3723             choiceValue: fill
  3772             choiceValue: fill
  3724           )
  3773           )
  3725          (MenuItem
  3774          (MenuItem
       
  3775             enabled: imageIsLoadedHolder
       
  3776             label: 'Gradient Fill'
       
  3777             isVisible: false
       
  3778             submenu: 
       
  3779            (Menu
       
  3780               (
       
  3781                (MenuItem
       
  3782                   activeHelpKey: drawModeFill
       
  3783                   enabled: imageIsLoadedHolder
       
  3784                   label: 'Horizontal'
       
  3785                   labelImage: (ResourceRetriever ImageEditor fillHorizontalGradientRectIcon 'Horizontal')
       
  3786                   choice: editMode
       
  3787                   choiceValue: fillHorizontalGradient
       
  3788                 )
       
  3789                (MenuItem
       
  3790                   activeHelpKey: drawModeFill
       
  3791                   enabled: imageIsLoadedHolder
       
  3792                   label: 'Vertical'
       
  3793                   labelImage: (ResourceRetriever ImageEditor fillVerticalGradientRectIcon 'Vertical')
       
  3794                   choice: editMode
       
  3795                   choiceValue: fillVerticalGradient
       
  3796                 )
       
  3797                (MenuItem
       
  3798                   activeHelpKey: drawModeFill
       
  3799                   enabled: imageIsLoadedHolder
       
  3800                   label: 'Diagonal'
       
  3801                   labelImage: (ResourceRetriever ImageEditor fillDiagonalGradientRectIcon 'Diagonal')
       
  3802                   choice: editMode
       
  3803                   choiceValue: fillDiagonalGradient
       
  3804                 )
       
  3805                )
       
  3806               nil
       
  3807               nil
       
  3808             )
       
  3809           )
       
  3810          (MenuItem
  3726             label: '-'
  3811             label: '-'
  3727           )
  3812           )
  3728          (MenuItem
  3813          (MenuItem
  3729             activeHelpKey: drawModeMaskOutsideRectangle
  3814             activeHelpKey: drawModeMaskOutsideRectangle
  3730             enabled: imageHasMaskAndIsNotReadOnlyHolder
  3815             enabled: imageHasMaskAndIsNotReadOnlyHolder
  6818         maskOffset := 1.
  6903         maskOffset := 1.
  6819     ] ifFalse:[
  6904     ] ifFalse:[
  6820         maskOffset := 0.
  6905         maskOffset := 0.
  6821     ].
  6906     ].
  6822     cMap := img colorMap.
  6907     cMap := img colorMap.
  6823     (cMap isNil or:[cMap isMappedPalette or:[cMap isFixedPalette]]) ifTrue:[
  6908     (cMap isNil) ifTrue:[
  6824         oldColors := drawingColormap
  6909         oldColors := drawingColormap
  6825     ] ifFalse:[    
  6910     ] ifFalse:[    
  6826         oldColors := selectedColorIndices collect:[:idx | cMap at:idx-maskOffset].
  6911         (cMap isMappedPalette or:[cMap isFixedPalette]) ifTrue:[
       
  6912             oldColors := cMap asArray
       
  6913         ] ifFalse:[    
       
  6914             oldColors := selectedColorIndices collect:[:idx | cMap at:idx-maskOffset].
       
  6915         ].
  6827     ].
  6916     ].
  6828     imageEditView makeUndo.
  6917     imageEditView makeUndo.
  6829 
  6918 
  6830     modifiedColormap := cMap asNewArray.
  6919     modifiedColormap := cMap asNewArray.
  6831 
  6920 
  6832     newColors := oldColors collect:aBlock.
  6921     newColors := oldColors collect:aBlock.
  6833     selectedColorIndices with:newColors do:[:idx :newColor | 
  6922     selectedColorIndices do:[:idx |
  6834         modifiedColormap at:idx-maskOffset put:newColor
  6923         modifiedColormap at:idx-maskOffset put:(newColors at:idx)
  6835     ].
  6924     ].
  6836 
  6925 
  6837     newImage := img species new
  6926     newImage := img species new
  6838                     width:img width
  6927                     width:img width
  6839                     height:img height
  6928                     height:img height
  6840                     depth:img depth
  6929                     depth:img depth
  6841                     fromArray:img bits.
  6930                     fromArray:img bits.
  6842 
  6931 
  6843     (cMap isNil or:[cMap isMappedPalette or:[cMap isFixedPalette]]) ifTrue:[
  6932     (cMap isNil) ifTrue:[
  6844         "/ only a dummy...
  6933         "/ only a dummy...
  6845     ] ifFalse:[    
  6934     ] ifFalse:[    
  6846         newImage colorMap:modifiedColormap.  
  6935         newImage colorMap:modifiedColormap.  
       
  6936         newImage photometric:#palette.  
  6847     ].
  6937     ].
  6848     newImage fileName:img fileName.
  6938     newImage fileName:img fileName.
  6849     newImage mask:(img mask copy).
  6939     newImage mask:(img mask copy).
  6850 
  6940 
  6851     (imageEditView image:newImage) notNil ifTrue:[
  6941     (imageEditView image:newImage) notNil ifTrue:[
  6852         self fetchImageData.
  6942         self fetchImageData.
  6853     ].
  6943     ].
  6854     self selectedColors value:selectedColorIndices.
  6944     self selectedColors value:selectedColorIndices.
  6855 
  6945 
  6856     "Modified: / 03-02-2017 / 22:05:33 / cg"
  6946     "Modified: / 22-02-2017 / 19:45:29 / cg"
  6857 !
  6947 !
  6858 
  6948 
  6859 reduceNumberOfColors
  6949 reduceNumberOfColors
  6860     |s n anyChange img usedColors|
  6950     |s n anyChange img usedColors|
  6861 
  6951