ImageEditView.st
author Claus Gittinger <cg@exept.de>
Sun, 20 Oct 2019 13:39:52 +0200
changeset 6174 dec07e94dbf9
parent 6161 3353ad05fdb3
child 6185 cdf3556a2bdd
permissions -rw-r--r--
#FEATURE by exept class: NoteBookView added: #tabForWhich:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6161
3353ad05fdb3 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 6160
diff changeset
     1
"{ Encoding: utf8 }"
3353ad05fdb3 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 6160
diff changeset
     2
636
d53428252193 revised version
tz
parents: 633
diff changeset
     3
"
704
01140e14c065 Fix copyright.
Stefan Vogel <sv@exept.de>
parents: 694
diff changeset
     4
 COPYRIGHT (c) 1997 by eXept Software AG
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
     5
	      All Rights Reserved
636
d53428252193 revised version
tz
parents: 633
diff changeset
     6
d53428252193 revised version
tz
parents: 633
diff changeset
     7
 This software is furnished under a license and may be used
d53428252193 revised version
tz
parents: 633
diff changeset
     8
 only in accordance with the terms of that license and with the
d53428252193 revised version
tz
parents: 633
diff changeset
     9
 inclusion of the above copyright notice. This software may not
d53428252193 revised version
tz
parents: 633
diff changeset
    10
 be provided or otherwise made available to, or used by, any
d53428252193 revised version
tz
parents: 633
diff changeset
    11
 other person. No title to or ownership of the software is
d53428252193 revised version
tz
parents: 633
diff changeset
    12
 hereby transferred.
d53428252193 revised version
tz
parents: 633
diff changeset
    13
"
1763
7d6d64622ee4 change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents: 1706
diff changeset
    14
"{ Package: 'stx:libwidg2' }"
7d6d64622ee4 change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents: 1706
diff changeset
    15
4714
69df9f744066 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
    16
"{ NameSpace: Smalltalk }"
69df9f744066 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
    17
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    18
ImageView subclass:#ImageEditView
4041
2d635ff57406 class definition
Claus Gittinger <cg@exept.de>
parents: 4032
diff changeset
    19
	instanceVariableNames:'readOnly magnification imageReaderClass resourceClass
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
    20
		resourceSelector mouseKeyColorMode undoImages originalImage
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
    21
		modifiedHolder editMode lastPastePoint imageInfoHolder
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
    22
		activityInfoHolder pickedColorHolder drawingColors drawingPixels
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
    23
		drawingColorHolders drawingPixelHolders clickInfoCallBack
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
    24
		penWidth sprayProcess sprayPosition spraySpot drawingAlpha
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
    25
		floodFillMaxHueError floodFillMaxLightError
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
    26
		userAllowedToChangeDrawingColor'
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
    27
	classVariableNames:'Clipboard ClipboardMagnified ClipboardImage
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
    28
		ClipboardImageMagnified LastMagnification GridMagnificationLimit
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
    29
		MaxUndos LastSaveDirectory LastSaveClass EditModePoint
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
    30
		EditModeBox EditModeFilledBox EditModeFill EditModeCopy
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
    31
		EditModePasteUnder EditModePaste EditModePasteWithMask
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
    32
		EditModeSpecialOperation EditModeSpray EditModeCircle
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
    33
		EditModeSmooth EditModeFilledCircle
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
    34
		EditModeSpecialOperationCropSubImage EditModeMaskOutsideRect
6150
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
    35
		EditModeMaskOutsideCircle EditModePasteMasked EditModePointBlend'
1035
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
    36
	poolDictionaries:''
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
    37
	category:'Views-Misc'
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    38
!
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    39
636
d53428252193 revised version
tz
parents: 633
diff changeset
    40
!ImageEditView class methodsFor:'documentation'!
d53428252193 revised version
tz
parents: 633
diff changeset
    41
d53428252193 revised version
tz
parents: 633
diff changeset
    42
copyright
d53428252193 revised version
tz
parents: 633
diff changeset
    43
"
704
01140e14c065 Fix copyright.
Stefan Vogel <sv@exept.de>
parents: 694
diff changeset
    44
 COPYRIGHT (c) 1997 by eXept Software AG
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
    45
	      All Rights Reserved
636
d53428252193 revised version
tz
parents: 633
diff changeset
    46
d53428252193 revised version
tz
parents: 633
diff changeset
    47
 This software is furnished under a license and may be used
d53428252193 revised version
tz
parents: 633
diff changeset
    48
 only in accordance with the terms of that license and with the
d53428252193 revised version
tz
parents: 633
diff changeset
    49
 inclusion of the above copyright notice. This software may not
d53428252193 revised version
tz
parents: 633
diff changeset
    50
 be provided or otherwise made available to, or used by, any
d53428252193 revised version
tz
parents: 633
diff changeset
    51
 other person. No title to or ownership of the software is
d53428252193 revised version
tz
parents: 633
diff changeset
    52
 hereby transferred.
d53428252193 revised version
tz
parents: 633
diff changeset
    53
"
d53428252193 revised version
tz
parents: 633
diff changeset
    54
!
d53428252193 revised version
tz
parents: 633
diff changeset
    55
d53428252193 revised version
tz
parents: 633
diff changeset
    56
documentation
d53428252193 revised version
tz
parents: 633
diff changeset
    57
"
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2690
diff changeset
    58
    An ImageEditView is a view which can be used by applications
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2690
diff changeset
    59
    like the Image Editor for editing or inspecting (bitmap-) images.
636
d53428252193 revised version
tz
parents: 633
diff changeset
    60
d53428252193 revised version
tz
parents: 633
diff changeset
    61
    [see also:]
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2690
diff changeset
    62
        ImageEditor Image
636
d53428252193 revised version
tz
parents: 633
diff changeset
    63
d53428252193 revised version
tz
parents: 633
diff changeset
    64
    [author:]
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2690
diff changeset
    65
        Thomas Zwick
636
d53428252193 revised version
tz
parents: 633
diff changeset
    66
"
d53428252193 revised version
tz
parents: 633
diff changeset
    67
! !
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    68
1245
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    69
!ImageEditView class methodsFor:'initialization'!
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    70
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    71
initialize
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
    72
    MaxUndos := 10.
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
    73
    GridMagnificationLimit := 6 @ 6.
1245
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    74
2889
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
    75
    EditModePoint := #point.
6150
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
    76
    EditModePointBlend := #pointBlend.
2889
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
    77
    EditModeBox := #box.
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
    78
    EditModeCircle := #circle.
2889
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
    79
    EditModePaste := #paste.
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
    80
    EditModePasteUnder := #pasteUnder.
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
    81
    EditModePasteWithMask := #pasteWithMask.
5772
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
    82
    EditModePasteMasked := #pasteMasked.
2889
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
    83
    EditModeFilledBox := #filledBox.
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
    84
    EditModeFilledCircle := #filledCircle.
2889
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
    85
    EditModeFill := #fill.
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
    86
    EditModeCopy := #copy.
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
    87
    EditModeSpray := #spray.
4715
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
    88
    EditModeSmooth := #smooth.
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
    89
    EditModeMaskOutsideRect := #maskOutsideRect. 
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
    90
    EditModeMaskOutsideCircle := #maskOutsideCircle. 
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
    91
    EditModeSpecialOperation := #specialOperation.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
    92
    EditModeSpecialOperationCropSubImage := #specialOperationCropSubImage.
2889
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
    93
1245
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    94
    "
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    95
     self initialize
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    96
    "
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
    97
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
    98
    "Modified: / 20-02-2017 / 16:54:11 / cg"
5772
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
    99
    "Modified: / 27-05-2018 / 10:42:00 / Claus Gittinger"
1245
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   100
! !
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   101
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   102
!ImageEditView class methodsFor:'accessing'!
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   103
2889
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   104
editModeBox
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   105
    ^ EditModeBox
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   106
!
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   107
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   108
editModeCopy
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   109
    ^ EditModeCopy
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   110
!
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   111
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   112
editModeFill
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   113
    ^ EditModeFill
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   114
!
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   115
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   116
editModeFilledBox
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   117
    ^ EditModeFilledBox
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   118
!
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   119
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   120
editModePaste
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   121
    ^ EditModePaste
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   122
!
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   123
5772
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
   124
editModePasteMasked
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
   125
    ^ EditModePasteMasked
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
   126
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
   127
    "Created: / 27-05-2018 / 10:43:22 / Claus Gittinger"
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
   128
!
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
   129
2889
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   130
editModePasteUnder
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   131
    ^ EditModePasteUnder
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   132
!
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   133
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   134
editModePasteWithMask
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   135
    ^ EditModePasteWithMask
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   136
!
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   137
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   138
editModePoint
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   139
    ^ EditModePoint
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   140
!
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   141
4715
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
   142
editModeSmooth
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
   143
    ^ EditModeSmooth
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
   144
!
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
   145
2889
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   146
editModeSpecialOperation
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   147
    ^ EditModeSpecialOperation
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   148
!
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   149
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   150
gridMagnificationLimit
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   151
    ^ GridMagnificationLimit
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   152
!
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   153
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   154
gridMagnificationLimit:anInteger
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   155
    GridMagnificationLimit := anInteger
3980
Claus Gittinger <cg@exept.de>
parents: 3972
diff changeset
   156
!
Claus Gittinger <cg@exept.de>
parents: 3972
diff changeset
   157
Claus Gittinger <cg@exept.de>
parents: 3972
diff changeset
   158
lastSaveDirectory
Claus Gittinger <cg@exept.de>
parents: 3972
diff changeset
   159
    ^ LastSaveDirectory
Claus Gittinger <cg@exept.de>
parents: 3972
diff changeset
   160
Claus Gittinger <cg@exept.de>
parents: 3972
diff changeset
   161
    "Created: / 14-12-2010 / 14:49:01 / cg"
Claus Gittinger <cg@exept.de>
parents: 3972
diff changeset
   162
!
Claus Gittinger <cg@exept.de>
parents: 3972
diff changeset
   163
Claus Gittinger <cg@exept.de>
parents: 3972
diff changeset
   164
lastSaveDirectory:aStringOrFilename
Claus Gittinger <cg@exept.de>
parents: 3972
diff changeset
   165
    LastSaveDirectory := aStringOrFilename
Claus Gittinger <cg@exept.de>
parents: 3972
diff changeset
   166
Claus Gittinger <cg@exept.de>
parents: 3972
diff changeset
   167
    "Created: / 14-12-2010 / 14:49:18 / cg"
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   168
! !
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   169
2480
6b82ad413d70 added copyToClipboard
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   170
!ImageEditView class methodsFor:'helpers'!
6b82ad413d70 added copyToClipboard
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   171
6b82ad413d70 added copyToClipboard
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   172
copyImageToClipboard:copiedImage
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   173
    ClipboardImageMagnified := nil.
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   174
    ClipboardImage := copiedImage.
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   175
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   176
    "Modified: / 08-10-2017 / 08:55:10 / cg"
2480
6b82ad413d70 added copyToClipboard
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   177
! !
6b82ad413d70 added copyToClipboard
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   178
2634
dc5098a445d4 resources
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
   179
!ImageEditView class methodsFor:'resources'!
dc5098a445d4 resources
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
   180
dc5098a445d4 resources
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
   181
classResources
dc5098a445d4 resources
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
   182
    ^ ImageEditor classResources
dc5098a445d4 resources
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
   183
! !
dc5098a445d4 resources
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
   184
7
19b36b78ee01 *** empty log message ***
claus
parents: 5
diff changeset
   185
!ImageEditView methodsFor:'accessing'!
19b36b78ee01 *** empty log message ***
claus
parents: 5
diff changeset
   186
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   187
activityInfoHolder
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   188
    "return the value of the instance variable 'activityInfoHolder' (automatically generated)"
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   189
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   190
    ^ activityInfoHolder
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   191
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   192
    "Created: / 29.7.1998 / 18:49:39 / cg"
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   193
!
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   194
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   195
activityInfoHolder:something
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   196
    "set the value of the instance variable 'activityInfoHolder' (automatically generated)"
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   197
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   198
    activityInfoHolder := something.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   199
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   200
    "Created: / 29.7.1998 / 18:49:39 / cg"
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   201
!
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   202
2590
b811d560e00a modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
   203
clearModified
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   204
    self modified:false
2590
b811d560e00a modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
   205
!
b811d560e00a modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
   206
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   207
clickInfoCallBack:aTwoArgBlock
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   208
     clickInfoCallBack := aTwoArgBlock
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   209
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   210
    "Created: / 10.2.2000 / 23:07:14 / cg"
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   211
!
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   212
2440
a9abeb0e3562 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2415
diff changeset
   213
clipBoard
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   214
    |clipboardObject|
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   215
    
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   216
    clipboardObject := self getClipboardObject.
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   217
    clipboardObject isImage ifTrue:[
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   218
        ^ clipboardObject
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   219
    ].
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   220
    ^ ClipboardImage.
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   221
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   222
    "Modified: / 08-10-2017 / 08:52:27 / cg"
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   223
!
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   224
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   225
clipBoardImage
5772
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
   226
    "if there is an image in the clobal clipboard, 
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
   227
     return that (and thus support copy-paste from another smalltalk application).
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   228
     Otherwise return the local clipboardImage from a classVar to support copy-paste 
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   229
     within this smalltalk session."
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   230
     
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   231
    |clipboardObject|
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   232
    
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   233
    clipboardObject := self getClipboardObject.
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   234
    clipboardObject isImage ifTrue:[
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   235
        ^ clipboardObject
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   236
    ].
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   237
    ^ ClipboardImage.
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   238
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   239
    "Created: / 08-10-2017 / 08:55:59 / cg"
5772
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
   240
    "Modified (comment): / 27-05-2018 / 11:12:58 / Claus Gittinger"
2440
a9abeb0e3562 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2415
diff changeset
   241
!
a9abeb0e3562 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2415
diff changeset
   242
5593
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   243
drawingAlpha
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   244
    "return the alpha value for drawing; 
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   245
     if the current drawing color is nil, ONLY the alpha value will be changed"
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   246
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   247
    ^ drawingAlpha ? 100
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   248
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   249
    "Created: / 05-09-2017 / 09:11:32 / cg"
5594
26e8562cdf99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
   250
    "Modified: / 05-09-2017 / 10:47:18 / cg"
5593
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   251
!
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   252
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   253
drawingAlpha:anAlphaValue
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   254
    "set the alpha value for drawing;
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   255
     if the current drawing color is nil, ONLY the alpha value will be changed"
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   256
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   257
    drawingAlpha := anAlphaValue
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   258
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   259
    "Created: / 05-09-2017 / 09:11:26 / cg"
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   260
!
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   261
3610
11e215de80a0 color selection when undoing
Claus Gittinger <cg@exept.de>
parents: 3564
diff changeset
   262
drawingColorHolders
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
   263
    drawingColorHolders isNil ifTrue:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
   264
        drawingColorHolders := Array with:(nil asValue) with:(nil asValue).   "/ left/right mouse colors
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
   265
    ].    
3610
11e215de80a0 color selection when undoing
Claus Gittinger <cg@exept.de>
parents: 3564
diff changeset
   266
    ^ drawingColorHolders
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
   267
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
   268
    "Modified: / 23-02-2017 / 10:14:49 / cg"
3610
11e215de80a0 color selection when undoing
Claus Gittinger <cg@exept.de>
parents: 3564
diff changeset
   269
!
11e215de80a0 color selection when undoing
Claus Gittinger <cg@exept.de>
parents: 3564
diff changeset
   270
11e215de80a0 color selection when undoing
Claus Gittinger <cg@exept.de>
parents: 3564
diff changeset
   271
drawingColors
5593
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   272
    "return the two colors in which I will draw (left / right mouse button colors)"
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   273
3610
11e215de80a0 color selection when undoing
Claus Gittinger <cg@exept.de>
parents: 3564
diff changeset
   274
    ^ drawingColorHolders collect:[:each | each value].
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
   275
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
   276
    "Modified: / 23-02-2017 / 10:17:14 / cg"
5593
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   277
    "Modified (comment): / 05-09-2017 / 09:12:14 / cg"
3610
11e215de80a0 color selection when undoing
Claus Gittinger <cg@exept.de>
parents: 3564
diff changeset
   278
!
11e215de80a0 color selection when undoing
Claus Gittinger <cg@exept.de>
parents: 3564
diff changeset
   279
2009
4f556ff9fec5 pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents: 2007
diff changeset
   280
drawingColors:anArrayTwoColors
5593
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   281
    "set the two colors in which I will draw (left / right mouse button colors)"
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   282
    
2009
4f556ff9fec5 pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents: 2007
diff changeset
   283
    (drawingColorHolders at:1) value:(anArrayTwoColors at:1).
4f556ff9fec5 pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents: 2007
diff changeset
   284
    (drawingColorHolders at:2) value:(anArrayTwoColors at:2).
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
   285
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
   286
    "Modified: / 23-02-2017 / 10:17:21 / cg"
5593
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   287
    "Modified (comment): / 05-09-2017 / 09:12:07 / cg"
2009
4f556ff9fec5 pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents: 2007
diff changeset
   288
!
4f556ff9fec5 pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents: 2007
diff changeset
   289
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   290
editMode
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   291
    "is one of the edit modes:
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   292
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   293
        EditModePoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   294
        EditModeBox
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   295
        EditModePaste
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   296
        EditModePasteUnder
5772
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
   297
        EditModePasteMasked
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   298
        EditModePasteWithMask 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   299
        EditModeFilledBox
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   300
        EditModeFill 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   301
        EditModeCopy 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   302
        EditModeSpecialOperation 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   303
        EditModeSpray 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   304
        EditModeCircle 
6150
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
   305
        EditModeSmooth
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
   306
        EditModePointBlend
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   307
    "
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   308
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   309
    ^editMode
5772
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
   310
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
   311
    "Modified (comment): / 27-05-2018 / 10:41:44 / Claus Gittinger"
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   312
!
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   313
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   314
editMode: anEditModeSymbol
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   315
    "must be one of the edit modes:
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   316
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   317
        EditModePoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   318
        EditModeBox
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   319
        EditModePaste
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   320
        EditModePasteUnder
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   321
        EditModePasteWithMask 
5772
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
   322
        EditModePasteMasked
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   323
        EditModeFilledBox
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   324
        EditModeFill 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   325
        EditModeCopy 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   326
        EditModeSpecialOperation 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   327
        EditModeSpray 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   328
        EditModeCircle 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   329
        EditModeSmooth 
6150
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
   330
        EditModePointBlend 
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   331
    "
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   332
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   333
    editMode := anEditModeSymbol
5772
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
   334
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
   335
    "Modified (comment): / 27-05-2018 / 10:42:21 / Claus Gittinger"
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   336
!
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   337
5483
87e33f13ffe2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5481
diff changeset
   338
floodFillMaxHueError:aFraction
87e33f13ffe2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5481
diff changeset
   339
    floodFillMaxHueError := aFraction.
87e33f13ffe2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5481
diff changeset
   340
87e33f13ffe2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5481
diff changeset
   341
    "Modified (format): / 17-02-2017 / 15:26:59 / cg"
87e33f13ffe2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5481
diff changeset
   342
!
87e33f13ffe2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5481
diff changeset
   343
87e33f13ffe2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5481
diff changeset
   344
floodFillMaxLightError:aFraction
87e33f13ffe2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5481
diff changeset
   345
    floodFillMaxLightError := aFraction.
87e33f13ffe2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5481
diff changeset
   346
87e33f13ffe2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5481
diff changeset
   347
    "Modified (format): / 17-02-2017 / 15:27:03 / cg"
87e33f13ffe2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5481
diff changeset
   348
!
87e33f13ffe2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5481
diff changeset
   349
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   350
image:anImage scroll:doScroll
3706
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
   351
    self image:anImage scroll:doScroll invalidate:true
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
   352
!
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
   353
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
   354
image:anImage scroll:doScroll invalidate:doInvalidate
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   355
    |retVal fileName|
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   356
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   357
    anImage isImage ifTrue:[           
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   358
        true "(image isNil or: [self checkModified])" ifTrue: [
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   359
            image notNil ifTrue: [
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   360
                fileName := image fileName.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   361
                anImage fileName isNil ifTrue: [anImage fileName: fileName].
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   362
            ].
3706
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
   363
            super image:anImage scroll:doScroll invalidate:doInvalidate.
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   364
            retVal := self.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   365
        ].
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   366
    ] ifFalse: [
3706
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
   367
        super image:nil scroll:true invalidate:doInvalidate.
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   368
    ].
3706
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
   369
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   370
    "/ self changed:#image.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   371
    image isNil ifTrue:[
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   372
        self clearModified.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   373
    ] ifFalse:[
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   374
        self setModified.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   375
    ].
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   376
    self updateImageInfo: self imageInfoString. 
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   377
    ^ retVal
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   378
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   379
    "Modified: / 10.2.2000 / 23:33:12 / cg"
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   380
!
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   381
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   382
imageInfoHolder
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   383
    ^ imageInfoHolder
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   384
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   385
    "Created: / 29.7.1998 / 18:29:50 / cg"
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   386
!
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   387
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   388
imageInfoHolder:something
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   389
    imageInfoHolder := something.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   390
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   391
    "Created: / 29.7.1998 / 18:29:50 / cg"
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   392
!
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   393
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   394
magnification
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   395
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   396
    ^magnification
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   397
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   398
!
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   399
636
d53428252193 revised version
tz
parents: 633
diff changeset
   400
magnification: aPoint
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   401
    |oldOrg|
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   402
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   403
    magnification ~= aPoint
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   404
    ifTrue:
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   405
    [
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   406
        oldOrg := self viewOrigin / magnification.
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   407
        magnification := aPoint asPoint.
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   408
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   409
        self scrollTo:(oldOrg * magnification) rounded redraw:false.        
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   410
"/        self scrollToTopLeft.
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   411
        self contentsChanged.
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   412
        self invalidate.
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   413
        ClipboardImageMagnified := nil.
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   414
    ]
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   415
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   416
    "Modified: / 08-10-2017 / 08:54:54 / cg"
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   417
!
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   418
2913
7e07bb5586e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2910
diff changeset
   419
modified
7e07bb5586e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2910
diff changeset
   420
    ^ modifiedHolder value
7e07bb5586e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2910
diff changeset
   421
!
7e07bb5586e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2910
diff changeset
   422
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2690
diff changeset
   423
modified:aBoolean
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2690
diff changeset
   424
    modifiedHolder value:aBoolean
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2690
diff changeset
   425
!
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2690
diff changeset
   426
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2690
diff changeset
   427
modifiedHolder
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2690
diff changeset
   428
    ^ modifiedHolder
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2690
diff changeset
   429
!
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2690
diff changeset
   430
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   431
mouseKeyColorMode
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   432
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   433
    ^mouseKeyColorMode printString
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   434
!
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   435
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   436
mouseKeyColorMode:aMode
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   437
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   438
    mouseKeyColorMode := aMode
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   439
!
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   440
3265
f22de2c4383d pen width
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   441
penWidth
f22de2c4383d pen width
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   442
    ^ penWidth ? 1
f22de2c4383d pen width
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   443
f22de2c4383d pen width
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   444
    "Created: / 01-11-2007 / 23:34:49 / cg"
f22de2c4383d pen width
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   445
!
f22de2c4383d pen width
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   446
5405
50dd27514854 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5364
diff changeset
   447
penWidth:anInteger
50dd27514854 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5364
diff changeset
   448
    penWidth := anInteger
3265
f22de2c4383d pen width
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   449
f22de2c4383d pen width
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   450
    "Created: / 01-11-2007 / 23:34:56 / cg"
f22de2c4383d pen width
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   451
!
f22de2c4383d pen width
Claus Gittinger <cg@exept.de>
parents: 2917
diff changeset
   452
4041
2d635ff57406 class definition
Claus Gittinger <cg@exept.de>
parents: 4032
diff changeset
   453
readOnly
2d635ff57406 class definition
Claus Gittinger <cg@exept.de>
parents: 4032
diff changeset
   454
    ^ readOnly
2d635ff57406 class definition
Claus Gittinger <cg@exept.de>
parents: 4032
diff changeset
   455
!
2d635ff57406 class definition
Claus Gittinger <cg@exept.de>
parents: 4032
diff changeset
   456
5405
50dd27514854 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5364
diff changeset
   457
readOnly:aBoolean
50dd27514854 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5364
diff changeset
   458
    readOnly := aBoolean.
4041
2d635ff57406 class definition
Claus Gittinger <cg@exept.de>
parents: 4032
diff changeset
   459
!
2d635ff57406 class definition
Claus Gittinger <cg@exept.de>
parents: 4032
diff changeset
   460
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   461
removelastUndo
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   462
    undoImages removeLast
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   463
!
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   464
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   465
resourceClass
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   466
    ^ resourceClass
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   467
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   468
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   469
resourceClass: aClassOrClassNameString
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   470
    "support for names will vanish - obsolete left over from tz"
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   471
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   472
    resourceClass := aClassOrClassNameString.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   473
    resourceClass notNil ifTrue:[
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   474
        resourceClass isBehavior ifFalse: [ 
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   475
            resourceClass := Smalltalk classNamed:aClassOrClassNameString 
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   476
        ]
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   477
    ]
2908
a759fa87d598 some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
   478
!
a759fa87d598 some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
   479
a759fa87d598 some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
   480
resourceClassName
a759fa87d598 some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
   481
    resourceClass isNil ifTrue:[^ ''].
a759fa87d598 some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
   482
    ^ resourceClass name
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   483
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   484
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   485
resourceMessage
2909
7d6f5d4ba273 some code cleanup
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   486
    (resourceClass isNil or:[resourceSelector isNil]) ifTrue:[^ ''].
2908
a759fa87d598 some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
   487
    ^ resourceClass name, ' ', resourceSelector
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   488
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   489
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   490
resourceSelector
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   491
    ^ resourceSelector
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   492
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   493
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   494
resourceSelector: aStringOrSymbol
2909
7d6f5d4ba273 some code cleanup
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   495
    aStringOrSymbol isNil ifTrue:[
7d6f5d4ba273 some code cleanup
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   496
        resourceSelector := nil
7d6f5d4ba273 some code cleanup
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   497
    ] ifFalse:[
7d6f5d4ba273 some code cleanup
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   498
        resourceSelector := aStringOrSymbol asSymbol
7d6f5d4ba273 some code cleanup
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   499
    ]
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   500
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   501
5480
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
   502
selectMaskForDrawing
5483
87e33f13ffe2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5481
diff changeset
   503
    image mask isNil ifTrue:[ 
87e33f13ffe2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5481
diff changeset
   504
        Logger warning:'image has no mask'.
87e33f13ffe2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5481
diff changeset
   505
        ^ self.    
87e33f13ffe2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5481
diff changeset
   506
    ].
5484
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
   507
    "/ self selectedColorIndex:1.
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
   508
    self selectedColor:(Color noColor).
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
   509
    self selectedColorIndex:nil.
5480
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
   510
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
   511
    "Created: / 16-02-2017 / 09:57:40 / cg"
5484
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
   512
    "Modified: / 17-02-2017 / 16:30:50 / cg"
5480
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
   513
!
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
   514
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   515
selectedColor
3730
3f07e7082aff preps for aloha channel
Claus Gittinger <cg@exept.de>
parents: 3729
diff changeset
   516
    |clr|
3f07e7082aff preps for aloha channel
Claus Gittinger <cg@exept.de>
parents: 3729
diff changeset
   517
3f07e7082aff preps for aloha channel
Claus Gittinger <cg@exept.de>
parents: 3729
diff changeset
   518
    clr := (drawingColorHolders at:mouseKeyColorMode) value.
3931
d2a15871d837 changed: #selectedColor
Claus Gittinger <cg@exept.de>
parents: 3865
diff changeset
   519
    clr isNil ifTrue:[ clr := Color black ].
5593
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
   520
    
3730
3f07e7082aff preps for aloha channel
Claus Gittinger <cg@exept.de>
parents: 3729
diff changeset
   521
    image hasAlphaChannel ifTrue:[
5594
26e8562cdf99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
   522
        clr isPseudoColor ifTrue:[
26e8562cdf99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
   523
            "/ the mask is selected - return a pseudoColor holding ONLY the alpha value
26e8562cdf99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
   524
            "/ will be detected in the drawing operations to change the alpha value only
26e8562cdf99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
   525
            ^ TranslucentColor new
26e8562cdf99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
   526
                    alpha:((drawingAlpha ? 100) / 100)
26e8562cdf99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
   527
        ].
26e8562cdf99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
   528
    
3730
3f07e7082aff preps for aloha channel
Claus Gittinger <cg@exept.de>
parents: 3729
diff changeset
   529
        ^ (TranslucentColor 
3f07e7082aff preps for aloha channel
Claus Gittinger <cg@exept.de>
parents: 3729
diff changeset
   530
                scaledRed:clr scaledRed
3f07e7082aff preps for aloha channel
Claus Gittinger <cg@exept.de>
parents: 3729
diff changeset
   531
                scaledGreen:clr scaledGreen
3f07e7082aff preps for aloha channel
Claus Gittinger <cg@exept.de>
parents: 3729
diff changeset
   532
                scaledBlue:clr scaledBlue)
5594
26e8562cdf99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
   533
                alpha:((drawingAlpha ? 100) / 100)
3730
3f07e7082aff preps for aloha channel
Claus Gittinger <cg@exept.de>
parents: 3729
diff changeset
   534
    ].
3f07e7082aff preps for aloha channel
Claus Gittinger <cg@exept.de>
parents: 3729
diff changeset
   535
    ^ clr
3931
d2a15871d837 changed: #selectedColor
Claus Gittinger <cg@exept.de>
parents: 3865
diff changeset
   536
5594
26e8562cdf99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
   537
    "Modified (format): / 05-09-2017 / 12:21:53 / cg"
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   538
!
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   539
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   540
selectedColor: aColor
4853
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
   541
    (drawingColorHolders at:(mouseKeyColorMode min:drawingColorHolders size)) value:aColor
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
   542
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
   543
    "Modified: / 23-02-2017 / 10:17:02 / cg"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   544
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   545
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   546
selectedColorIndex
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   547
    ^ (drawingPixelHolders at:mouseKeyColorMode) value
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   548
!
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   549
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   550
selectedColorIndex: aPixelIndex
4853
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
   551
    (drawingPixelHolders at:(mouseKeyColorMode min:drawingPixelHolders size)) value: aPixelIndex
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   552
!
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   553
2590
b811d560e00a modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
   554
setModified
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
   555
    "remember being modified (to ask about saving, when closing)"
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
   556
    
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   557
    self modified:true
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
   558
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
   559
    "Modified (comment): / 22-02-2017 / 22:24:34 / cg"
2590
b811d560e00a modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
   560
!
b811d560e00a modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
   561
4111
Claus Gittinger <cg@exept.de>
parents: 4041
diff changeset
   562
spraySpot
Claus Gittinger <cg@exept.de>
parents: 4041
diff changeset
   563
    ^ spraySpot
Claus Gittinger <cg@exept.de>
parents: 4041
diff changeset
   564
Claus Gittinger <cg@exept.de>
parents: 4041
diff changeset
   565
    "Created: / 15-02-2012 / 22:38:04 / cg"
Claus Gittinger <cg@exept.de>
parents: 4041
diff changeset
   566
!
Claus Gittinger <cg@exept.de>
parents: 4041
diff changeset
   567
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   568
spraySpot:something
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   569
    spraySpot := something.
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   570
!
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   571
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   572
undoImages
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
   573
    ^ undoImages
5484
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
   574
!
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
   575
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
   576
userAllowedToChangeDrawingColor:aBoolean
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
   577
    "for special applications, whre user is only allowed to draw
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
   578
     in the predefined color (eg. expecco)"
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
   579
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
   580
    userAllowedToChangeDrawingColor := aBoolean
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
   581
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
   582
    "Created: / 17-02-2017 / 16:24:37 / cg"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   583
! !
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   584
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   585
!ImageEditView methodsFor:'drawing'!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   586
1036
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   587
drawFrame
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   588
    "draws a black frame around the image's bounds"
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   589
    
5432
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
   590
    gc paint:self blackColor.
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
   591
    gc lineWidth: (magnification x//3 min: 3).
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
   592
    gc displayRectangle: ((0@0) extent:(image extent * magnification) + margin).
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
   593
    gc lineWidth:1.
1036
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   594
!
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   595
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   596
drawFramesIn: aRectangle
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   597
    "draws the pixel frame grid"
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   598
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   599
    |origin lineStartingPoint lineEndingPoint oldColor mX mY|
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   600
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   601
    magnification >= GridMagnificationLimit ifTrue: [
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   602
        mX := magnification x.
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   603
        mY := magnification y.
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   604
        
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   605
        origin := aRectangle origin - 1.
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   606
        lineStartingPoint := origin + (0 @ mY).
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   607
        lineEndingPoint   := lineStartingPoint + (aRectangle width@0).
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   608
5432
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
   609
        oldColor := gc paint.
5584
b26858ed0e2f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5583
diff changeset
   610
        gc paint:Color gray.
b26858ed0e2f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5583
diff changeset
   611
        "/ gc xoring:[
5432
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
   612
            gc displayLineFrom: lineStartingPoint to: lineEndingPoint.
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   613
            lineStartingPoint x to: lineStartingPoint x + aRectangle width - mX by: mX 
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   614
            do:[:x|   
5432
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
   615
                gc displayLineFrom: x@(origin y) to: x@(origin y + mY)
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   616
            ].
5584
b26858ed0e2f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5583
diff changeset
   617
        "/ ].
5432
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
   618
        gc paint: oldColor.
1036
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   619
    ]
5584
b26858ed0e2f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5583
diff changeset
   620
b26858ed0e2f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5583
diff changeset
   621
    "Modified: / 29-08-2017 / 21:58:07 / cg"
1036
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   622
!
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   623
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   624
drawPasteRectangleAt: aPoint
2889
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   625
    |currentPoint gridCorrection extent|
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   626
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   627
    magnification >= GridMagnificationLimit ifFalse: [gridCorrection := 0] ifTrue: [gridCorrection := 1].
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   628
    currentPoint := aPoint // magnification*magnification + margin. 
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   629
2085
4cf52f994f0a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
   630
    self repairDamage.
4cf52f994f0a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
   631
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   632
    currentPoint ~= lastPastePoint ifTrue:[              
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   633
        ClipboardImageMagnified isNil ifTrue:[
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   634
            ClipboardImageMagnified := (ClipboardImage magnifiedBy: magnification) onDevice:device
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   635
        ].   
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   636
        extent := ClipboardImageMagnified extent.
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   637
1967
1b4524f3105f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1957
diff changeset
   638
        "/ currentPoint := currentPoint - self viewOrigin.
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   639
2085
4cf52f994f0a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
   640
        self redraw: (((lastPastePoint ? currentPoint)"-self viewOrigin") extent: extent).
3267
ee55a3b2f6fc changed #pointAt:
Claus Gittinger <cg@exept.de>
parents: 3266
diff changeset
   641
        "/ self repairDamage.
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   642
2085
4cf52f994f0a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
   643
false "        (extent x > 400 or: [extent y > 400])" ifTrue:[
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   644
            self xoring: [
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   645
                self fillRectangle: (currentPoint extent: extent)
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   646
            ]   
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   647
        ] ifFalse:[
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   648
            ClipboardImageMagnified notNil ifTrue:[
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   649
                self displayDeviceForm: ClipboardImageMagnified 
2089
8c0aed9152c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2086
diff changeset
   650
                                     x: currentPoint x - self viewOrigin x 
8c0aed9152c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2086
diff changeset
   651
                                     y: currentPoint y - self viewOrigin y.
8c0aed9152c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2086
diff changeset
   652
            ].
2889
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
   653
            editMode == EditModePastUnder ifTrue:[
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   654
                self redrawImageX:currentPoint x y:currentPoint y width:extent x height:extent y unmaskedOnly:true
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   655
            ]
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   656
        ]  
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   657
    ]. 
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   658
    lastPastePoint := currentPoint.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   659
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   660
    "Modified: / 08-10-2017 / 08:54:49 / cg"
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   661
!
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   662
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   663
fillFramedRectangle: aRectangle
61b7601829ea with modal support
tz
parents: 636
diff changeset
   664
61b7601829ea with modal support
tz
parents: 636
diff changeset
   665
    self fillRectangle: aRectangle.
61b7601829ea with modal support
tz
parents: 636
diff changeset
   666
    self drawFramesIn: aRectangle
61b7601829ea with modal support
tz
parents: 636
diff changeset
   667
!
61b7601829ea with modal support
tz
parents: 636
diff changeset
   668
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   669
redraw:aRectangle
2838
8525a35121d2 changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents: 2824
diff changeset
   670
    self 
8525a35121d2 changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents: 2824
diff changeset
   671
        invalidate:(aRectangle origin "+ self viewOrigin" extent:aRectangle extent)
8525a35121d2 changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents: 2824
diff changeset
   672
        repairNow:true. 
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   673
2053
5c19fe5b2db3 invalidate rather than redraw
Claus Gittinger <cg@exept.de>
parents: 2034
diff changeset
   674
    "Modified: / 15.11.2001 / 16:43:53 / cg"
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   675
!
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   676
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   677
redrawImageX:x y:y width:w height:h
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   678
    self redrawImageX:x y:y width:w height:h unmaskedOnly:false
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   679
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   680
    "Modified: / 18.5.1999 / 20:14:03 / cg"
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   681
!
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   682
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   683
redrawImageX:x y:y width:w height:h unmaskedOnly:unmaskedOnly
3319
ae7f91c67895 comment
Claus Gittinger <cg@exept.de>
parents: 3278
diff changeset
   684
    "redraw the magnified (editing) view of the image"
636
d53428252193 revised version
tz
parents: 633
diff changeset
   685
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   686
    self 
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   687
        redrawImageX:x y:y width:w height:h 
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   688
        unmaskedOnly:unmaskedOnly processColorsWith:[:colorIn | colorIn].
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   689
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   690
    "Created: / 18.5.1999 / 20:13:39 / cg"
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   691
    "Modified: / 18.5.1999 / 20:36:20 / cg"
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   692
!
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   693
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   694
redrawImageX:x y:y width:w height:h unmaskedOnly:unmaskedOnly processColorsWith:aColorBlock
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   695
    "redraw the magnified (editing) view of the image"
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   696
5591
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   697
    |ih iw magX magY minX maxX minY maxY lastColor lastY runW x0 
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   698
     isMasked mask photometric
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   699
     lastPixelColor
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   700
     sizeOfMaskPoint offsetOfMaskPoint
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   701
     useNearestColor isRGBA isRGBLike drawPixel 
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   702
     showPixelValue pixelValueFont savedFont ascent|
1180
dcb9dede5128 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   703
4999
e0111330133e device access
Claus Gittinger <cg@exept.de>
parents: 4967
diff changeset
   704
    useNearestColor := device visualType == #PseudoColor.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   705
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   706
    mask := image mask.
5591
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   707
    photometric := image photometric.
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   708
    isRGBA := photometric == #rgba.
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   709
    isRGBLike := #(rgb rgba argb) includes:photometric.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   710
    ih := image height.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   711
    iw := image width.
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   712
    magX := magnification x.
61b7601829ea with modal support
tz
parents: 636
diff changeset
   713
    magY := magnification y.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   714
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   715
    minX := (x // magX - 1) max: 0.
725
0e051202859d checkin from browser
tz
parents: 724
diff changeset
   716
    minX >= iw ifTrue:[minX := (iw - 1) max: 0].
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   717
    minY := (y // magY - 1) max: 0.
725
0e051202859d checkin from browser
tz
parents: 724
diff changeset
   718
    minY >= ih ifTrue:[minY := (ih - 1) max: 0].
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   719
    maxX := (x + w) // magX + 1.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   720
    maxX > iw ifTrue:[maxX := iw].
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   721
    maxY := (y + h) // magY + 1.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   722
    maxY > ih ifTrue:[maxY := ih].
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   723
5591
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   724
    showPixelValue := "(image depth <= 12) and:["(magX > 32) and:[magY > 32]"]".
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   725
    showPixelValue ifTrue:[
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   726
        pixelValueFont := TextView defaultFont asSize:(magY // 6).
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   727
        pixelValueFont := pixelValueFont onDevice:gc device.
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   728
        savedFont := gc font.
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   729
        gc font:pixelValueFont.
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   730
        ascent := pixelValueFont ascent + 2.
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   731
    ].
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   732
    
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   733
    drawPixel :=
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   734
        [:x :y :clr |
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   735
            |origin pixelColor pixelValue s|
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   736
            
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   737
            origin := (x * magX + margin)@(y * magY + margin).
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   738
            (unmaskedOnly and:[isMasked]) ifFalse:[
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   739
                self fillFramedRectangle: (origin extent: runW@magY).
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   740
                isMasked ifTrue:[
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   741
                    gc xoring:[
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   742
                        gc fillRectangle: (origin + offsetOfMaskPoint extent: sizeOfMaskPoint)
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   743
                    ]
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   744
                ] ifFalse:[
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   745
                    pixelValueFont notNil ifTrue:[
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   746
                        pixelColor := gc paint.
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   747
                        gc paint:(pixelColor contrastingColorFor:pixelColor).
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   748
                        pixelValue := image pixelAtX:x y:y.
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   749
                        isRGBLike ifTrue:[
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   750
                            s := pixelValue hexPrintString.
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   751
                        ] ifFalse:[
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   752
                            s := pixelValue printString.
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   753
                        ].    
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   754
                        gc displayString:s x:(origin x + 1) y:(origin y + ascent).
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   755
                    ].    
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   756
                ].    
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   757
            ]
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   758
        ].
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   759
        
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   760
    lastY := -1.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   761
    x0 := minX.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   762
    runW := 0.
5591
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   763
    isMasked := false.
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   764
    sizeOfMaskPoint := (magnification//3) min:8.
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   765
    offsetOfMaskPoint := (magnification - sizeOfMaskPoint) // 2.
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   766
    
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   767
    image 
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   768
        colorsFromX:minX y:minY toX:maxX-1 y:maxY-1 
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   769
        do:[:xx :yy :colorIn|
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   770
            |color|
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   771
            
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   772
            color := aColorBlock value:colorIn.
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   773
            
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   774
            shown ifFalse:[^ self].
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   775
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   776
            yy ~~ lastY ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   777
                runW ~~ 0 ifTrue:[
5591
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   778
                    drawPixel value:x0 value:lastY value:lastColor.
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   779
                    runW := 0.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   780
                ]. 
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   781
                x0 := xx.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   782
                lastY := yy.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   783
            ]. 
1160
5d89296c4b04 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1158
diff changeset
   784
5591
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   785
            (color ~= lastColor or:[showPixelValue]) ifTrue:[
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   786
                runW ~~ 0 ifTrue:[
5591
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   787
                    drawPixel value:x0 value:yy value:lastColor.
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   788
                    runW := 0.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   789
                ].
5591
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   790
                
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   791
                lastColor := lastPixelColor := color.
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   792
                useNearestColor ifTrue:[
4999
e0111330133e device access
Claus Gittinger <cg@exept.de>
parents: 4967
diff changeset
   793
                    lastColor := lastColor nearestOn:device
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   794
                ].
5432
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
   795
                gc paint:lastColor.
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   796
                mask notNil ifTrue:[  
5591
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   797
                    isMasked := false.
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   798
                    (mask pixelAtX:xx y:yy) == 0 ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   799
                        unmaskedOnly ifFalse:[
5432
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
   800
                            gc paint: (lastColor := self viewBackground).
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   801
                        ].
5591
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   802
                        isMasked := true.
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   803
                    ].
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   804
                    lastColor := nil.
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   805
                ] ifFalse:[
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   806
                    isRGBA ifTrue:[
5591
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   807
                        isMasked := false.
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   808
                        colorIn alphaByte == 0 ifTrue:[
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   809
                            unmaskedOnly ifFalse:[
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   810
                                gc paint: (lastColor := self viewBackground).
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   811
                            ].
5591
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   812
                            isMasked := true.
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   813
                        ] ifFalse:[  
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   814
                        ].    
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   815
                        lastColor := nil.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   816
                    ]
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   817
                ].    
1160
5d89296c4b04 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1158
diff changeset
   818
                runW := 0.
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   819
                x0 := xx.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   820
            ].  
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   821
            runW := runW + magX
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   822
        ].
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   823
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   824
    runW ~~ 0 ifTrue:[
5591
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   825
        drawPixel value:x0 value:lastY value:lastColor.
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   826
    ].
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   827
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   828
    savedFont notNil ifTrue:[
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   829
        gc font:savedFont.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   830
    ].
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   831
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
   832
    "Created: / 18-05-1999 / 20:13:39 / cg"
5591
1d2029c136ec #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5590
diff changeset
   833
    "Modified: / 01-09-2017 / 11:39:09 / cg"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   834
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   835
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   836
redrawX:x y:y width:w height:h
636
d53428252193 revised version
tz
parents: 633
diff changeset
   837
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   838
    |xI yI devImage imgWidth imgHeight mX mY magnifiedWidth magnifiedHeight|
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   839
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   840
    image isNil ifTrue:[^self].
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   841
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   842
    magnification = (1@1) ifTrue: [
4212
4b84444912b5 exception access
Claus Gittinger <cg@exept.de>
parents: 4203
diff changeset
   843
        Error handle:[:ex |
2092
36ef3048dbf4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2089
diff changeset
   844
            Transcript showCR:'cannot convert image: ', ex description.
1510
fd0cd6065dc6 catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   845
        ] do:[
4999
e0111330133e device access
Claus Gittinger <cg@exept.de>
parents: 4967
diff changeset
   846
            devImage := image onDevice:device.
1763
7d6d64622ee4 change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents: 1706
diff changeset
   847
            devImage ~~ image ifTrue:[
7d6d64622ee4 change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents: 1706
diff changeset
   848
                image := devImage.
1764
3dd553f8d9f0 oops - leftover halts
Claus Gittinger <cg@exept.de>
parents: 1763
diff changeset
   849
                self changed:#image.
1763
7d6d64622ee4 change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents: 1706
diff changeset
   850
            ].
1510
fd0cd6065dc6 catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   851
        ].
4999
e0111330133e device access
Claus Gittinger <cg@exept.de>
parents: 4967
diff changeset
   852
        image device == device ifTrue:[
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   853
            super redrawX:x y:y width:w height:h.
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   854
            self drawFrame.
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   855
            ^ self.
1510
fd0cd6065dc6 catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   856
        ].
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   857
    ].
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   858
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   859
    "/ self clippingRectangle: (x@y extent:w@h).
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   860
    "/ draw the image itself
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   861
    self redrawImageX:x y:y width:w height:h.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   862
4233
06183a48f783 Fix stc compiler warnings
Stefan Vogel <sv@exept.de>
parents: 4231
diff changeset
   863
    imgWidth := image width.
06183a48f783 Fix stc compiler warnings
Stefan Vogel <sv@exept.de>
parents: 4231
diff changeset
   864
    imgHeight := image height.
06183a48f783 Fix stc compiler warnings
Stefan Vogel <sv@exept.de>
parents: 4231
diff changeset
   865
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   866
    "/ beyond of image ?
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   867
    adjust == #center ifTrue:[
4233
06183a48f783 Fix stc compiler warnings
Stefan Vogel <sv@exept.de>
parents: 4231
diff changeset
   868
        xI := (width - imgWidth) // 2 - margin.
06183a48f783 Fix stc compiler warnings
Stefan Vogel <sv@exept.de>
parents: 4231
diff changeset
   869
        yI := (height - imgHeight) // 2 - margin.
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   870
    ] ifFalse:[
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   871
        xI := yI := margin
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   872
    ].
1967
1b4524f3105f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1957
diff changeset
   873
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   874
    mX := magnification x.
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   875
    mY := magnification y.
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   876
    magnifiedWidth := mX * imgWidth.
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   877
    magnifiedHeight := mY * imgHeight.
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   878
    
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   879
    "/ draw the rest to the right and at the bottom
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   880
    (x + w - 1) > (xI + magnifiedWidth) ifTrue:[
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   881
        self 
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   882
            clearRectangleX:(xI + magnifiedWidth) y:y
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   883
            width:(x + w - magnifiedWidth - xI) height:h
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   884
    ].
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   885
    (y + h - 1) > (yI + magnifiedHeight) ifTrue:[
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   886
        self 
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   887
            clearRectangleX:margin y:(yI + magnifiedHeight)
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   888
            width:w height:(y + h - magnifiedHeight - yI)  
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   889
    ].
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   890
    self drawFrame.
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   891
    self clippingBounds: nil.
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   892
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   893
    "Modified: / 31.7.1998 / 02:22:45 / cg"
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   894
!
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   895
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   896
startSpray
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   897
    spraySpot isNil ifTrue:[
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   898
        spraySpot := 8
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   899
    ].
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   900
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   901
    sprayProcess isNil ifTrue:[
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   902
        sprayProcess := [
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   903
                |p rnd norm sprayPoint dly angle x y dist|
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   904
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   905
                rnd := Random new.
3477
00d7bac0b2c4 changed #startSpray
Claus Gittinger <cg@exept.de>
parents: 3476
diff changeset
   906
                Distributions::NormalDistribution notNil ifTrue:[
00d7bac0b2c4 changed #startSpray
Claus Gittinger <cg@exept.de>
parents: 3476
diff changeset
   907
                    norm := Distributions::NormalDistribution mean:0 deviation:0.5.
00d7bac0b2c4 changed #startSpray
Claus Gittinger <cg@exept.de>
parents: 3476
diff changeset
   908
                ].
3487
5cc0a5d3e1f4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3477
diff changeset
   909
                dly := Delay forMilliseconds:20.
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   910
                [true] whileTrue:[
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   911
                    10 timesRepeat:[
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   912
                        p := sprayPosition.
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   913
                        p notNil ifTrue:[
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   914
                            angle := rnd next * 359.999.    "/ the angle is uniformly ditributed
3477
00d7bac0b2c4 changed #startSpray
Claus Gittinger <cg@exept.de>
parents: 3476
diff changeset
   915
                            norm notNil ifTrue:[
00d7bac0b2c4 changed #startSpray
Claus Gittinger <cg@exept.de>
parents: 3476
diff changeset
   916
                                dist := norm next * spraySpot.  "/ the distance is a normalDistribution
00d7bac0b2c4 changed #startSpray
Claus Gittinger <cg@exept.de>
parents: 3476
diff changeset
   917
                            ] ifFalse:[
00d7bac0b2c4 changed #startSpray
Claus Gittinger <cg@exept.de>
parents: 3476
diff changeset
   918
                                dist := (rnd nextBetween:-1 and:1) * spraySpot. 
00d7bac0b2c4 changed #startSpray
Claus Gittinger <cg@exept.de>
parents: 3476
diff changeset
   919
                            ].
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   920
                            sprayPoint := (Point r:dist degrees:angle)*magnification.
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   921
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   922
                            x := p x + sprayPoint x truncated.
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   923
                            y := p y + sprayPoint y truncated.
4111
Claus Gittinger <cg@exept.de>
parents: 4041
diff changeset
   924
                            self pointAt:(x@y) width:1.
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   925
                        ].
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   926
                    ].
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   927
                    dly wait.
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   928
                ].
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   929
        ] fork.
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   930
    ]
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   931
4111
Claus Gittinger <cg@exept.de>
parents: 4041
diff changeset
   932
    "Modified: / 15-02-2012 / 22:44:54 / cg"
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   933
!
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   934
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   935
stopSpray
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   936
    sprayProcess notNil ifTrue:[
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   937
        sprayProcess terminate.
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   938
        sprayProcess := nil
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   939
    ].
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   940
! !
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   941
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   942
!ImageEditView methodsFor:'event handling'!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   943
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   944
buttonMotion:state x:x y:y
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   945
    |p|
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   946
2072
abd4e246f393 care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   947
    (x < 0 or:[y < 0]) ifTrue:[
abd4e246f393 care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   948
        ^ self
abd4e246f393 care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   949
    ].
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   950
    "/ readOnly ifTrue:[^ self].
2072
abd4e246f393 care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   951
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   952
    p := x@y.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   953
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   954
    state ~~ 0 ifTrue:[
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   955
        "/ button down
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   956
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   957
        "/ self selectedColor notNil ifTrue:[ 
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   958
        (self imageContainsPoint:p) ifTrue:[
6150
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
   959
            ((editMode == EditModePoint) or:[editMode == EditModePointBlend]) ifTrue:[
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   960
                self pointAt:p.
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   961
                ^ self
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   962
            ].
4715
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
   963
            (editMode == EditModeSmooth) ifTrue:[
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
   964
                self smoothAt:p.
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
   965
                ^ self
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
   966
            ].
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   967
            sprayProcess notNil ifTrue:[
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   968
                sprayPosition := p.
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
   969
                ^ self
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   970
            ].
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   971
        ].
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   972
        self drawCursorAt:p.
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   973
        ^ self
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   974
    ].
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   975
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
   976
    "/ button is up (care for paste-mode, dragging the pasted image)
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   977
    self drawCursorAt:p.
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
   978
    
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
   979
    "/ if in pastemode, highlight the affected rectangle (image to be pasted is in ClipBoard)
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
   980
    (self inPasteMode and:[ ClipboardImage notNil ]) ifTrue: [
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
   981
        "/ with shift, paste is offset by pasted image's size
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
   982
        "/ (i.e. click-point will be corner of pasted rectangle)
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   983
        self sensor shiftDown ifTrue:[
5655
2254c5d79e3b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5654
diff changeset
   984
            p := p - (ClipboardImage extent * magnification)
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
   985
        ].
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
   986
        (self imageContainsPastePoint:p) ifTrue:[
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
   987
            (self sensor hasButtonMotionEventFor:self) ifFalse:[
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
   988
                self drawPasteRectangleAt:p
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
   989
            ]
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
   990
        ] ifFalse: [
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
   991
            self cursor:Cursor stop. 
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
   992
            self releasePasteDrawing
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
   993
        ]
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   994
    ]
1019
e68414752bc9 only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
   995
5655
2254c5d79e3b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5654
diff changeset
   996
    "Modified: / 07-12-2017 / 17:53:35 / cg"
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   997
!
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   998
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   999
buttonPress:button x:x y:y
2889
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
  1000
    |p clr masked|
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1001
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1002
    p := x@y.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1003
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  1004
    "/ with shift, paste is offset by pasted image's size
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  1005
    "/ (i.e. click-point will be corner of pasted rectangle)
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  1006
    (self inPasteMode and:[ ClipboardImage notNil ]) ifTrue:[
3278
c42700648b31 shift-paste
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  1007
        self sensor shiftDown ifTrue:[
5655
2254c5d79e3b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5654
diff changeset
  1008
            p := p - (ClipboardImage extent * magnification)
3278
c42700648b31 shift-paste
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  1009
        ]
c42700648b31 shift-paste
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  1010
    ].
c42700648b31 shift-paste
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  1011
    
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1012
    self drawCursorAt:p.
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1013
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  1014
    (self imageContainsPoint:p) ifTrue:[  
5480
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
  1015
        "/ shift click: select the pixel-color  
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  1016
        (self inPasteMode not and:[self sensor shiftDown]) ifTrue:[
5484
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
  1017
            userAllowedToChangeDrawingColor ifTrue:[
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
  1018
                (image maskAt:(p // magnification)) == 0 ifTrue:[
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
  1019
                    masked := true.
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
  1020
                ] ifFalse:[
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
  1021
                    masked := false.
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
  1022
                    clr := image colorAt:(p // magnification).
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
  1023
                ].
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
  1024
                pickedColorHolder notNil ifTrue:[
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
  1025
                    pickedColorHolder value:clr.
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
  1026
                ].
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
  1027
                self selectedColor:clr.
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
  1028
                masked ifTrue:[self selectedColorIndex:nil].
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
  1029
                self changed:#selectedColor with:clr.
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
  1030
            ].    
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1031
        ] ifFalse:[
5480
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
  1032
            "/ normal click: 
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  1033
            (readOnly not 
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  1034
              or:[editMode == EditModeCopy
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  1035
              or:[editMode == EditModeSpecialOperation]]
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  1036
            ) ifTrue:[
4853
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
  1037
                (button between:1 and:2) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
  1038
                    mouseKeyColorMode := button.
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
  1039
                    self makeUndo.
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
  1040
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
  1041
                    clickInfoCallBack notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
  1042
                        "/ still a kludge, but less ugly ...
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
  1043
                        clickInfoCallBack value:button value:p
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
  1044
                    ].
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
  1045
                    "/ editMode is something like #point, #rectangle etc.
5480
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
  1046
                    "/ so we call pointAt: / rectAt: / filledBoxAt: etc. here
4853
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
  1047
                    [
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
  1048
                        self perform: (editMode, 'At:') asSymbol with:p
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
  1049
                    ] on:Error do:[:ex | 
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
  1050
                        (Dialog confirm:('Error during operation: ', ex description,'\\Debug ?') withCRs )
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
  1051
                        ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
  1052
                            ex reject
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
  1053
                        ].
4041
2d635ff57406 class definition
Claus Gittinger <cg@exept.de>
parents: 4032
diff changeset
  1054
                    ].
2889
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
  1055
                ].
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
  1056
            ].
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1057
        ]
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1058
    ]
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1059
5655
2254c5d79e3b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5654
diff changeset
  1060
    "Modified: / 07-12-2017 / 17:53:23 / cg"
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1061
!
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1062
994
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
  1063
buttonRelease:button x:x y:y
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
  1064
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
  1065
    self drawCursorAt: x@y.
4041
2d635ff57406 class definition
Claus Gittinger <cg@exept.de>
parents: 4032
diff changeset
  1066
    readOnly ifTrue:[^ self].
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1067
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  1068
    (self imageContainsPoint: x@y) ifTrue: [
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
  1069
        sprayProcess notNil ifTrue:[
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
  1070
            self stopSpray
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
  1071
        ].
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
  1072
1763
7d6d64622ee4 change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents: 1706
diff changeset
  1073
        image release.
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1074
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  1075
        "/        "/ cg: what a kludge - please change to use a valueHolder,
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  1076
        "/        "/ which gets the information ...
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  1077
        "/        masterApplication imagePreView invalidate.
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1078
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1079
        "/ cg: still a kludge - but less ugly
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1080
        self changed:#subImageIn with:(image bounds).
994
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
  1081
    ]
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1082
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  1083
    "Modified: / 16-02-2017 / 16:57:24 / cg"
994
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
  1084
!
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
  1085
2508
ffb079bfe8b6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2507
diff changeset
  1086
inPasteMode
2889
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
  1087
    ^ (editMode notNil and:[editMode startsWith:#paste])
2508
ffb079bfe8b6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2507
diff changeset
  1088
!
ffb079bfe8b6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2507
diff changeset
  1089
5669
bd36e715726a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  1090
keyboardZoom:largerBoolean
5671
511ca27ab8d6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5669
diff changeset
  1091
    "CTRL+/- zoom action"
511ca27ab8d6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5669
diff changeset
  1092
511ca27ab8d6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5669
diff changeset
  1093
    self magnification:(
511ca27ab8d6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5669
diff changeset
  1094
        largerBoolean 
511ca27ab8d6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5669
diff changeset
  1095
            ifTrue:[(magnification + 1) min:63]
511ca27ab8d6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5669
diff changeset
  1096
            ifFalse:[(magnification - 1) max:1])
5277
4d6ef5c2aa64 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1097
!
4d6ef5c2aa64 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1098
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1099
pointerLeave:state
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1100
688
e1c30adb37bf updates coord info label while defining boxes
tz
parents: 686
diff changeset
  1101
    super pointerLeave: state.
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1102
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1103
    self updateImageInfo: self imageInfoString.
1019
e68414752bc9 only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
  1104
    self cursor:Cursor normal.
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1105
2508
ffb079bfe8b6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2507
diff changeset
  1106
    self inPasteMode ifTrue: [
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1107
        self releasePasteDrawing
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1108
    ]
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1109
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1110
    "Modified: / 29.7.1998 / 18:27:42 / cg"
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1111
! !
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1112
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1113
!ImageEditView methodsFor:'image editing'!
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1114
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1115
askForSpecialOperation
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1116
    "let user ask for which special operation to apply to the selected imageBox,
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1117
     then perform it."    
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1118
    
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1119
    |listOfOpSpecs listOfOpNames listOfOpSelectors operation|
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1120
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1121
    listOfOpSpecs := OrderedCollection new.
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1122
    
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1123
    listOfOpSpecs addAll:
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1124
        #(
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1125
           ('edit separately'   editIcon         #edit)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1126
           ('extract subimage'  cropSubImageIcon #editSubImage)
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1127
        ).
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1128
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1129
    self readOnly ifFalse:[
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1130
        listOfOpSpecs addAll:
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1131
            #(
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1132
               ('-'                     nil nil)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1133
               ('flip vertical'         flipVerticalIcon   flipVertical)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1134
               ('flip horizontal'       flipHorizontalIcon flipHorizontal)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1135
               ('-'                     nil nil)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1136
               ('slightly brightened'   slightlyBrighterIcon slightlyBrightened)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1137
               ('slightly darkened'     slightlyDarkerIcon   slightlyDarkened)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1138
               ('brightened'            brighterIcon         brightened)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1139
               ('darkened'              darkerIcon           darkened)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1140
               ('-'                     nil nil)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1141
               ('make grey'             nil makeGrey)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1142
               ('greyed'                nil greyed)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1143
               ('grey pattern'          nil greyPattern)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1144
               ('grey pattern (unmasked)'   nil unmaskedGreyPattern)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1145
               ('-'                     nil nil)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1146
               ('reversed'              nil reversed)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1147
               ('-'                     nil nil)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1148
               ('change hue'            nil changeHue)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1149
               ('colorize'              nil colorize)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1150
               ('-'                     nil nil)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1151
               ('gradient fill horizontal'  fillHorizontalGradientRectIcon gradientFillHorizontal)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1152
               ('gradient fill vertical'    fillVerticalGradientRectIcon gradientFillVertical)
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1153
                "/ unfinished
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1154
               "/ ('gradient fill diagonal'    fillDiagonalGradientRectIcon gradientFillDiagonal)
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1155
               ('-'                     nil nil) 
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1156
               ('auto gradient fill horizontal'  fillHorizontalGradientRectIcon autoGradientFillHorizontal)
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1157
               ('auto gradient fill vertical'    fillVerticalGradientRectIcon autoGradientFillVertical)
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1158
                "/ unfinished
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1159
               "/ ('auto gradient fill diagonal'    fillDiagonalGradientRectIcon autoGradientFillDiagonal)
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1160
             ).
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1161
    ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1162
    
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1163
    listOfOpNames := listOfOpSpecs collect:[:entry |
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1164
                        |name iconSelector icon|
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1165
                        name := entry first.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1166
                        iconSelector := entry second.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1167
                        iconSelector notNil ifTrue:[ 
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1168
                            icon := self class perform:iconSelector ifNotUnderstood:[ImageEditor perform:iconSelector].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1169
                            LabelAndIcon label:name icon:icon
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1170
                        ] ifFalse:[
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1171
                            name
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1172
                        ].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1173
                     ].    
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1174
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1175
    listOfOpSelectors := listOfOpSpecs collect:#third. 
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1176
    
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1177
    operation := Dialog 
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1178
           choose:(resources string:'Which Operation:')
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1179
           fromList:listOfOpNames
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1180
           values:listOfOpSelectors
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1181
           lines:20
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1182
           cancel:nil.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1183
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1184
    ^ operation
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1185
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1186
    "Created: / 20-02-2017 / 17:37:23 / cg"
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1187
    "Modified: / 23-02-2017 / 15:54:42 / cg"
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1188
!
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  1189
5492
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1190
autoCropLeft:doLeft right:doRight top:doTop bottom:doBottom
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1191
    |yMinNew yMaxNew xMinNew xMaxNew
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1192
     pix stillCropping xMax yMax|
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1193
5531
686d94de0ac2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5510
diff changeset
  1194
    image isNil ifTrue:[^ self].
686d94de0ac2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5510
diff changeset
  1195
    
5492
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1196
    xMax := image width - 1.
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1197
    yMax := image height - 1.
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1198
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1199
    xMinNew := 0.
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1200
    doLeft ifTrue:[
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1201
        pix := image pixelAtX:xMinNew y:0.
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1202
        stillCropping := true.
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1203
        [stillCropping] whileTrue:[
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1204
            0 to:yMax do:[:y |
5531
686d94de0ac2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5510
diff changeset
  1205
                (image pixelAtX:xMinNew y:y) ~= pix ifTrue:[
5492
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1206
                    stillCropping := false
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1207
                ]
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1208
            ].
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1209
            stillCropping ifTrue:[
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1210
                xMinNew := xMinNew + 1.
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1211
                xMinNew >= image width ifTrue:[
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1212
                    self warn:(resources string:'Image is all the same color - no crop.').
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1213
                    ^ self
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1214
                ]
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1215
            ].
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1216
        ].
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1217
    ].
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1218
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1219
    xMaxNew := xMax.
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1220
    doRight ifTrue:[
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1221
        stillCropping := true.
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1222
        pix := image pixelAtX:xMaxNew y:0.
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1223
        [stillCropping] whileTrue:[
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1224
            0 to:yMax do:[:y |
5531
686d94de0ac2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5510
diff changeset
  1225
                (image pixelAtX:xMaxNew y:y) ~= pix ifTrue:[
5492
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1226
                    stillCropping := false
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1227
                ]
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1228
            ].
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1229
            stillCropping ifTrue:[
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1230
                xMaxNew := xMaxNew - 1.
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1231
            ].
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1232
        ].
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1233
    ].
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1234
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1235
    yMinNew := 0.
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1236
    doTop ifTrue:[
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1237
        pix := image pixelAtX:xMinNew y:yMinNew.
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1238
        stillCropping := true.
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1239
        [stillCropping] whileTrue:[
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1240
            xMinNew to:xMaxNew do:[:x |
5531
686d94de0ac2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5510
diff changeset
  1241
                (image pixelAtX:x y:yMinNew) ~= pix ifTrue:[
5492
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1242
                    stillCropping := false
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1243
                ]
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1244
            ].
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1245
            stillCropping ifTrue:[
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1246
                yMinNew := yMinNew + 1.
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1247
            ].
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1248
        ].
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1249
    ].
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1250
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1251
    yMaxNew := yMax.
5531
686d94de0ac2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5510
diff changeset
  1252
    doBottom ifTrue:[
5492
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1253
        stillCropping := true.
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1254
        pix := image pixelAtX:xMaxNew y:yMaxNew.
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1255
        [stillCropping] whileTrue:[
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1256
            xMinNew to:xMaxNew do:[:x |
5531
686d94de0ac2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5510
diff changeset
  1257
                (image pixelAtX:x y:yMaxNew) ~= pix ifTrue:[
5492
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1258
                    stillCropping := false
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1259
                ]
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1260
            ].
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1261
            stillCropping ifTrue:[
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1262
                yMaxNew := yMaxNew - 1.
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1263
            ].
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1264
        ].
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1265
    ].
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1266
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1267
    (xMinNew == 0
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1268
    and:[xMaxNew == (image width - 1)
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1269
    and:[yMinNew == 0
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1270
    and:[yMaxNew == (image height - 1)]]]) ifTrue:[
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1271
        self warn:(resources string:'No border found - no crob.').
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1272
        ^ self
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1273
    ].
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1274
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1275
"/    self warn:'extract subImage ' 
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1276
"/              , (xMinNew @ yMinNew) printString
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1277
"/              , ' -> '
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1278
"/              , (xMaxNew @ yMaxNew) printString.
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1279
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1280
    self makeUndo.
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1281
    self 
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1282
        makeSubImageX:xMinNew y:yMinNew 
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1283
        width:(xMaxNew - xMinNew + 1)
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1284
        height:(yMaxNew - yMinNew + 1)
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1285
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1286
    "Created: / 20-02-2017 / 17:59:05 / cg"
5531
686d94de0ac2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5510
diff changeset
  1287
    "Modified: / 12-04-2017 / 09:33:08 / cg"
5492
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1288
!
f3e1ee8eaf5a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5491
diff changeset
  1289
2480
6b82ad413d70 added copyToClipboard
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
  1290
copyImageToClipboard
5531
686d94de0ac2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5510
diff changeset
  1291
    image isNil ifTrue:[^ self].
686d94de0ac2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5510
diff changeset
  1292
2480
6b82ad413d70 added copyToClipboard
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
  1293
    self class copyImageToClipboard:image.
4264
6e31e342f38c class: ImageEditView
Stefan Vogel <sv@exept.de>
parents: 4249
diff changeset
  1294
    self setClipboardObject:image.
5531
686d94de0ac2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5510
diff changeset
  1295
686d94de0ac2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5510
diff changeset
  1296
    "Modified: / 12-04-2017 / 09:27:07 / cg"
2480
6b82ad413d70 added copyToClipboard
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
  1297
!
6b82ad413d70 added copyToClipboard
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
  1298
1228
0aae4f7389ca renamed - crob -> crop
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
  1299
cropLeft:doLeft right:doRight top:doTop bottom:doBottom
5531
686d94de0ac2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5510
diff changeset
  1300
    <resource: #obsolete>
686d94de0ac2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5510
diff changeset
  1301
686d94de0ac2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5510
diff changeset
  1302
    self autoCropLeft:doLeft right:doRight top:doTop bottom:doBottom
686d94de0ac2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5510
diff changeset
  1303
686d94de0ac2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5510
diff changeset
  1304
    "Created: / 07-09-1998 / 14:25:52 / cg"
686d94de0ac2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5510
diff changeset
  1305
    "Modified: / 12-04-2017 / 09:31:04 / cg"
1121
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1306
!
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1307
5435
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1308
drawingColorOrNil
6161
3353ad05fdb3 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 6160
diff changeset
  1309
    |cmap clr|
5435
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1310
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1311
    cmap := image colorMap.
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1312
    (cmap isNil or:[cmap isFixedPalette or:[cmap isMappedPalette]]) ifTrue:[
6161
3353ad05fdb3 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 6160
diff changeset
  1313
        clr := self selectedColor.
3353ad05fdb3 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 6160
diff changeset
  1314
        "/ care for mask in 24bit mode.
3353ad05fdb3 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 6160
diff changeset
  1315
        clr redByte notNil ifTrue:[
3353ad05fdb3 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 6160
diff changeset
  1316
            ^ clr
3353ad05fdb3 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 6160
diff changeset
  1317
        ].
5435
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1318
    ].
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1319
    ^ nil
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1320
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1321
    "Created: / 03-02-2017 / 21:58:01 / cg"
5594
26e8562cdf99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  1322
    "Modified: / 05-09-2017 / 10:49:34 / cg"
5435
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1323
!
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1324
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1325
drawingPixelOrNil
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1326
    |cmap|
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1327
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1328
    cmap := image colorMap.
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1329
    (cmap isNil or:[cmap isFixedPalette or:[cmap isMappedPalette]]) ifTrue:[
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1330
        ^ nil.
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1331
    ].
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1332
    ^ self selectedColorIndex.
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1333
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1334
    "Created: / 03-02-2017 / 21:58:28 / cg"
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1335
!
3707d107eb24 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5434
diff changeset
  1336
4032
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1337
flipSubImage:how in:imageBox
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1338
    "/ now, do it
4624
bc987849ea84 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
  1339
    "/ caveat: this should go into image class
4032
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1340
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1341
    |x0 y0 x1 y1 image t|
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1342
4623
efe94f736058 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
  1343
    self makeUndo.
efe94f736058 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
  1344
4032
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1345
    x0 := imageBox left.
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1346
    y0 := imageBox top.
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1347
    x1 := imageBox right-1.
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1348
    y1 := imageBox bottom-1.
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1349
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1350
    image := self image.
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1351
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1352
    how == #vertical ifTrue:[
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1353
        0 to:((y1-y0)//2) do:[:dy |
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1354
            x0 to:x1 do:[:x |
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1355
                t := image pixelAtX:x y:(y0+dy).
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1356
                image pixelAtX:x y:(y0+dy) put:(image pixelAtX:x y:(y1-dy)).
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1357
                image pixelAtX:x y:(y1-dy) put:t.
4624
bc987849ea84 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
  1358
                image mask notNil ifTrue:[
bc987849ea84 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
  1359
                    t := image maskAtX:x y:(y0+dy).
bc987849ea84 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
  1360
                    image maskAtX:x y:(y0+dy) put:(image maskAtX:x y:(y1-dy)).
bc987849ea84 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
  1361
                    image maskAtX:x y:(y1-dy) put:t.
bc987849ea84 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
  1362
                ].
4032
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1363
            ].
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1364
        ]
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1365
    ] ifFalse:[
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1366
        0 to:((x1-x0)//2) do:[:dx |
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1367
            y0 to:y1 do:[:y |
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1368
                t := image pixelAtX:(x0+dx) y:y.
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1369
                image pixelAtX:(x0+dx) y:y put:(image pixelAtX:(x1-dx) y:y).
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1370
                image pixelAtX:(x1-dx) y:y put:t.
4623
efe94f736058 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
  1371
4624
bc987849ea84 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
  1372
                image mask notNil ifTrue:[
bc987849ea84 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
  1373
                    t := image maskAtX:(x0+dx) y:y.
bc987849ea84 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
  1374
                    image maskAtX:(x0+dx) y:y put:(image maskAtX:(x1-dx) y:y).
bc987849ea84 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
  1375
                    image maskAtX:(x1-dx) y:y put:t.
bc987849ea84 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
  1376
                ].
4032
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1377
            ].
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1378
        ]
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1379
    ].
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1380
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1381
    self setModified.
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1382
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1383
    "Created: / 07-04-2011 / 09:34:23 / cg"
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1384
!
f293d37675b5 added: #flipSubImage:in:
Claus Gittinger <cg@exept.de>
parents: 4000
diff changeset
  1385
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1386
gradientFillIn:imageBox orientation:orientation auto:auto
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1387
    "/ with auto, pick 2 bounding pixels and do a gradient fill with those;
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1388
    "/ (don't know what diagonal should do, yet)
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1389
    "/ if auto is false, use color1/color2 for the fill
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1390
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1391
    |x0 y0 x1 y1 image n color1 color2 
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1392
     r0 g0 b0 dR dG dB i cX cY A B qAB a b pD1x pD1y pD2x pD2y
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1393
     dxH dyH hX hY dH dP f |
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1394
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1395
    self makeUndo.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1396
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1397
    x0 := imageBox left.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1398
    y0 := imageBox top.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1399
    x1 := imageBox right-1.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1400
    y1 := imageBox bottom-1.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1401
    image := self image.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1402
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1403
    self setModified.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1404
    
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1405
    auto ifTrue:[
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1406
        orientation == #vertical ifTrue:[
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1407
            n := y1-y0-1.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1408
            n = 0 ifTrue:[^ self].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1409
            x0 to:x1 do:[:x |
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1410
                color1 := image colorAtX:x y:y0.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1411
                color2 := image colorAtX:x y:y1.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1412
                r0 := color1 red.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1413
                g0 := color1 green.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1414
                b0 := color1 blue.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1415
                dR := (color2 red - color1 red) / n.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1416
                dG := (color2 green - color1 green) / n.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1417
                dB := (color2 blue - color1 blue) / n.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1418
                i := 1.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1419
                y0+1 to:y1-1 do:[:y |
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1420
                    |clr|
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1421
                    clr := Color red:(r0 + (i*dR)) green:(g0 + (i*dG)) blue:(b0 + (i*dB)).
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1422
                    image colorAtX:x y:y put:clr.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1423
                    i := i+1.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1424
                ].    
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1425
            ].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1426
            ^ self.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1427
        ].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1428
        
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1429
        orientation == #horizontal ifTrue:[
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1430
            n := x1-x0-1.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1431
            n = 0 ifTrue:[^ self].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1432
            y0 to:y1 do:[:y |
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1433
                color1 := image colorAtX:x0 y:y.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1434
                color2 := image colorAtX:x1 y:y.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1435
                r0 := color1 red.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1436
                g0 := color1 green.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1437
                b0 := color1 blue.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1438
                dR := (color2 red - color1 red) / n.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1439
                dG := (color2 green - color1 green) / n.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1440
                dB := (color2 blue - color1 blue) / n.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1441
                i := 1.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1442
                x0+1 to:x1-1 do:[:x |
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1443
                    |clr|
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1444
                    clr := Color red:(r0 + (i*dR)) green:(g0 + (i*dG)) blue:(b0 + (i*dB)).
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1445
                    image colorAtX:x y:y put:clr.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1446
                    i := i+1.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1447
                ].    
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1448
            ].    
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1449
            ^ self.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1450
        ].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1451
        ^ self.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1452
    ].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1453
    
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1454
    color1 := (self drawingColorHolders at:1) value.
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1455
    color1 isNil ifTrue:[ color1 := Color black ].
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1456
    color2 := (self drawingColorHolders at:2) value.
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1457
    color2 isNil ifTrue:[ color2 := Color white ].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1458
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1459
    r0 := color1 red.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1460
    g0 := color1 green.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1461
    b0 := color1 blue.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1462
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1463
    orientation == #vertical ifTrue:[
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1464
        n := y1-y0.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1465
        n = 0 ifTrue:[^ self].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1466
        
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1467
        dR := (color2 red - r0) / n.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1468
        dG := (color2 green - g0) / n.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1469
        dB := (color2 blue - b0) / n.
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1470
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1471
        x0 to:x1 do:[:x |
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1472
            i := 0.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1473
            y0 to:y1 do:[:y |
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1474
                |clr|
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1475
                clr := Color red:(r0 + (i*dR)) green:(g0 + (i*dG)) blue:(b0 + (i*dB)).
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1476
                image colorAtX:x y:y put:clr.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1477
                i := i+1.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1478
            ].    
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1479
        ].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1480
        ^ self.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1481
    ].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1482
    orientation == #horizontal ifTrue:[
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1483
        n := x1-x0.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1484
        n = 0 ifTrue:[^ self ].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1485
        
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1486
        dR := (color2 red - r0) / n.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1487
        dG := (color2 green - g0) / n.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1488
        dB := (color2 blue - b0) / n.
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1489
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1490
        y0 to:y1 do:[:y |
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1491
            i := 1.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1492
            x0+1 to:x1-1 do:[:x |
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1493
                |clr|
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1494
                clr := Color red:(r0 + (i*dR)) green:(g0 + (i*dG)) blue:(b0 + (i*dB)).
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1495
                image colorAtX:x y:y put:clr.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1496
                i := i+1.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1497
            ].    
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1498
        ].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1499
        ^ self.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1500
    ].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1501
    
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1502
    orientation == #diagonal ifTrue:[
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1503
        cX := (x1+1 + x0) / 2.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1504
        cY := (y1+1 + y0) / 2.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1505
        A := cY-y0. 
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1506
        B := cX-x0.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1507
        (A=0 or:[B=0]) ifTrue:[^ self].
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1508
        
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1509
        qAB := A/B.
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1510
        
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1511
        "/ {(cX-10) rounded . (cX-5) rounded . cX rounded . (cX+5)rounded . (cX+10)rounded } 
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1512
        x0 to:x1 
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1513
        do:[:x |
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1514
            b := cX-x.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1515
            b = 0 ifTrue:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1516
                pD1x := pD2x := cX.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1517
                pD1y := pD2y := cY.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1518
            ] ifFalse:[    
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1519
                "/ (A/B) = (a/b) -> a = (A/B)*b
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1520
                a := qAB*b.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1521
                pD1x := ((cX-b) max:x0) min:x1. 
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1522
                pD1y := ((cY+a) max:y0) min:y1. 
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1523
                pD2x := ((cX-b) max:x0) min:x1. 
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1524
                pD2y := ((cY-a) max:y0) min:y1.  
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1525
            ].
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1526
            "/ {(cY-10)rounded . (cY-5)rounded . cY rounded. (cY+5)rounded. (cY+10)rounded } 
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1527
            y0 to:y1 
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1528
            do:[:y |
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1529
                "/ the edge-point to interpolate against...
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1530
                "/ take a line from C through x/y and compute where it hits the edge H
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1531
                a := y-cY.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1532
                b := x-cX.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1533
                (a = 0) ifTrue:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1534
                    "/ exactly in the middle
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1535
                    hX := (x < cX) ifTrue:[x0] ifFalse:[x1].
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1536
                    hY := cY.
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1537
                ] ifFalse:[    
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1538
                    (b = 0) ifTrue:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1539
                        hX := cX.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1540
                        hY := (y < cY) ifTrue:[y0] ifFalse:[y1].
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1541
                    ] ifFalse:[    
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1542
                        "/ (dH/A) = (b/a) -> dH = (b/a)*A
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1543
                        y <= pD1y ifTrue:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1544
                            "/ in left-upper half
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1545
                            (y <= pD2y) ifTrue:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1546
                                "/ in upper quadrant
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1547
                                dxH := (b/a)*A.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1548
                                hX := cX-dxH.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1549
                                hY := y0.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1550
                            ] ifFalse:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1551
                                "/ in left quadrant
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1552
                                dyH := (a/b)*B negated.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1553
                                hY := cY+dyH.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1554
                                hX := x0.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1555
                            ].    
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1556
                        ] ifFalse:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1557
                            "/ in right-lower half
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1558
                            y >= pD2y ifTrue:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1559
                                "/ in lower quadrant 
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1560
                                dxH := (b/a)*A negated.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1561
                                hX := cX-dxH.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1562
                                hY := y1.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1563
                            ] ifFalse:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1564
                                "/ in right quadrant
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1565
                                dyH := (a/b)*B.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1566
                                hY := cY+dyH.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1567
                                hX := x1.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1568
                            ].
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1569
                        ].
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1570
                    ].
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1571
                    hX := hX min:x1.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1572
                    hY := hY min:y1.
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1573
                ].
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1574
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1575
                "/ the color at H
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1576
                color2 := image colorAtX:hX rounded y:hY rounded.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1577
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1578
                "/ the distance between H and C
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1579
                dH := (hX@hY) dist:(cX@cY).
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1580
                "/ the distance between P and C
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1581
                dP := (x@y) dist:(cX@cY).
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1582
                "/ the fraction (0 at H; 1 at C) 
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1583
                f := 1 - (dP / dH).
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1584
                self assert:(f between:0 and:1).
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1585
                
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1586
                "/ the new color
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1587
                dR := color2 red + ((r0-color2 red ) * f).
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1588
                dG := color2 green + ((g0-color2 green) * f).
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1589
                dB := color2 blue + ((b0-color2 blue) * f).
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1590
                image colorAtX:x y:y put:(Color red:dR green:dG blue:dB).
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1591
                
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1592
"/                y <= pD1y ifTrue:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1593
"/                    "/ in left-upper half
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1594
"/                    (y <= pD2y) ifTrue:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1595
"/                        "/ in upper quadrant
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1596
"/                        image colorAtX:x y:y put:Color red.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1597
"/                    ] ifFalse:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1598
"/                        "/ in left quadrant
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1599
"/                        image colorAtX:x y:y put:Color green.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1600
"/                    ].    
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1601
"/                ] ifFalse:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1602
"/                    "/ in right-lower half
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1603
"/                    y >= pD2y ifTrue:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1604
"/                        "/ in lower quadrant 
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1605
"/                        image colorAtX:x y:y put:Color blue.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1606
"/                    ] ifFalse:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1607
"/                        "/ in right quadrant 
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1608
"/                        image colorAtX:x y:y put:Color yellow.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1609
"/                    ].
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1610
"/                    
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1611
"/                ].
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1612
            ].
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1613
        ].
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1614
        "/ image colorAtX:cX rounded y:cY rounded put:Color magenta.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1615
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1616
"/            clr2 := image colorAtX:p2X y:p2Y.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1617
"/            
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1618
"/            cTop := image colorAtX:x y:y0.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1619
"/            cBot := image colorAtX:x y:y1.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1620
"/            "/ point on diagonal
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1621
"/            xD := x.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1622
"/            yD := (y1-y0)/(x1-x0)*x.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1623
"/            "/ color at point on diagonal
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1624
"/            "/ cDiag := image colorAtX:xD rounded y:yD rounded.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1625
"/            "/ the distance of the diagonal point from the origin
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1626
"/            dd := ((x-x0) squared + (yD-y0) squared) sqrt.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1627
"/            "/ desired color at point on diagonal
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1628
"/            cDiag := Color red:(color1 red + (dd*dR)) green:(color1 green + (dd*dG)) blue:(color1 blue + (dd*dB)).
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1629
"/"/ image colorAtX:xD rounded y:yD rounded put:cDiag.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1630
"/            
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1631
"/            n1 := yD-y0+1. "/ num points between top at x and diagonalPoint at x
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1632
"/            n2 := y1-yD+1. "/ num points between diagonalPoint at x and bottom at x 
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1633
"/            y0 to:y1 do:[:y |
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1634
"/                |clr d dR2 dG2 dB2|
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1635
"/
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1636
"/                y < yD ifTrue:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1637
"/                    "/ gradient from top-color at x to diagonal point at x
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1638
"/                    d := y-y0.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1639
"/                    dR2 := (cDiag red - cTop red) / n1.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1640
"/                    dG2 := (cDiag green - cTop green) / n1.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1641
"/                    dB2 := (cDiag blue - cTop blue) / n1.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1642
"/                    clr := Color red:(cTop red + (d*dR2)) green:(cTop green + (d*dG2)) blue:(cTop blue + (d*dB2)).
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1643
"/                image colorAtX:x y:y put:clr.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1644
"/                ] ifFalse:[    
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1645
"/                    "/ gradient from diagonal point at x to bottom point at x
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1646
"/                    d := y-yD.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1647
"/                    dR2 := (cBot red - cDiag red) / n2.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1648
"/                    dG2 := (cBot green - cDiag green) / n2.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1649
"/                    dB2 := (cBot blue - cDiag blue) / n2.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1650
"/                    clr := Color red:(cDiag red + (d*dR2)) green:(cDiag green + (d*dG2)) blue:(cDiag blue + (d*dB2)).
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1651
"/                    "/ clr := image colorAtX:x y:y.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1652
"/                image colorAtX:x y:y put:clr.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1653
"/                ].
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1654
"/            ]
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1655
"/        ].
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1656
        ^ self.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1657
    ].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1658
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1659
    "Created: / 22-02-2017 / 21:00:01 / cg"
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1660
    "Modified: / 23-02-2017 / 15:41:23 / cg"
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1661
!
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  1662
4723
c5f32ebfec14 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  1663
magnifyAntiAliasedImageTo:newSize
4730
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  1664
    self newImageWithUndo: (image hardAntiAliasedMagnifiedBy: newSize/image extent).
4723
c5f32ebfec14 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  1665
!
c5f32ebfec14 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  1666
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1667
magnifyImageTo:newSize
4730
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  1668
    self newImageWithUndo: (image magnifiedBy: newSize/image extent).
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1669
!
d53428252193 revised version
tz
parents: 633
diff changeset
  1670
5586
5cd1ecb1db66 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5585
diff changeset
  1671
magnifySmoothingBy:scale
5cd1ecb1db66 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5585
diff changeset
  1672
    self newImageWithUndo: (image hardSmoothingMagnifiedBy:scale).
5cd1ecb1db66 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5585
diff changeset
  1673
5cd1ecb1db66 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5585
diff changeset
  1674
    "Created: / 30-08-2017 / 15:35:15 / cg"
5cd1ecb1db66 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5585
diff changeset
  1675
!
5cd1ecb1db66 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5585
diff changeset
  1676
5587
9905471b62fd #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5586
diff changeset
  1677
magnifySmoothingTo:newSize
9905471b62fd #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5586
diff changeset
  1678
    self newImageWithUndo: (image hardSmoothingMagnifiedBy: newSize/image extent).
9905471b62fd #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5586
diff changeset
  1679
9905471b62fd #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5586
diff changeset
  1680
    "Created: / 30-08-2017 / 15:46:46 / cg"
9905471b62fd #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5586
diff changeset
  1681
!
9905471b62fd #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5586
diff changeset
  1682
2168
d531fe16bae2 more colormap operations
Claus Gittinger <cg@exept.de>
parents: 2149
diff changeset
  1683
makeNewColorMapByMapping:functionOfColor
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1684
    "wrong name: no longer needs a colormap - can also process the pixels
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1685
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1686
     undoable make a new image by processing colors with a function.
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1687
     If the image is a true-color image (rgb), the function is applied
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1688
     to every pixel's color and a new pixel-array is created (this is slow).
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1689
     Currently not done (why?):
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1690
        If the image is a palette image,
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1691
        the function is applied to the colormap only and a new colormap is
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1692
        created (i.e. this is very fast).
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1693
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1694
     This is the internal low level function to brighten, darken
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1695
     or hue-shift the image.
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1696
     Returns true, if there was any change."
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1697
     
2566
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1698
    |xMax yMax map revMap anyChange
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1699
     newColors newColorArray newImage pixelAction
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1700
     prevRGBIn prevRGBOut|
2168
d531fe16bae2 more colormap operations
Claus Gittinger <cg@exept.de>
parents: 2149
diff changeset
  1701
1886
e5b5a8850dc5 added make grayScale
Claus Gittinger <cg@exept.de>
parents: 1885
diff changeset
  1702
    anyChange := false.
e5b5a8850dc5 added make grayScale
Claus Gittinger <cg@exept.de>
parents: 1885
diff changeset
  1703
e5b5a8850dc5 added make grayScale
Claus Gittinger <cg@exept.de>
parents: 1885
diff changeset
  1704
    xMax := image width - 1.
e5b5a8850dc5 added make grayScale
Claus Gittinger <cg@exept.de>
parents: 1885
diff changeset
  1705
    yMax := image height - 1.
e5b5a8850dc5 added make grayScale
Claus Gittinger <cg@exept.de>
parents: 1885
diff changeset
  1706
e5b5a8850dc5 added make grayScale
Claus Gittinger <cg@exept.de>
parents: 1885
diff changeset
  1707
    newImage := image class width:image width height:image height depth:image depth.
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1708
    
1886
e5b5a8850dc5 added make grayScale
Claus Gittinger <cg@exept.de>
parents: 1885
diff changeset
  1709
    newImage photometric:image photometric.
e5b5a8850dc5 added make grayScale
Claus Gittinger <cg@exept.de>
parents: 1885
diff changeset
  1710
    newImage bits:(ByteArray new:(image bits size)).
e5b5a8850dc5 added make grayScale
Claus Gittinger <cg@exept.de>
parents: 1885
diff changeset
  1711
    newImage mask:(image mask copy).
e5b5a8850dc5 added make grayScale
Claus Gittinger <cg@exept.de>
parents: 1885
diff changeset
  1712
2566
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1713
    image colorMap notNil ifTrue:[
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1714
        "/ huh - what is going on here???    
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1715
        "/ whx not just collect over the colormap???
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1716
        
2566
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1717
        newColors := Set new.
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1718
        newColorArray := OrderedCollection new.
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1719
        map := Array new:256.
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1720
        revMap := OrderedCollection new.
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1721
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1722
        pixelAction := 
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1723
            [:x :y |
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1724
                |pix n_pix clr n_clr|
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1725
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1726
                pix := image pixelAtX:x y:y.
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1727
                (n_pix := map at:pix+1) isNil ifTrue:[
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1728
                    clr := image colorAtX:x y:y.
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1729
                    n_clr := functionOfColor value:clr.
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1730
                    (newColors includes:n_clr) ifFalse:[
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1731
                        newColors add:n_clr.
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1732
                        newColorArray add:n_clr.
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1733
                        revMap add:pix.
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1734
                        map at:pix+1 put:(n_pix := revMap size - 1).
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1735
                    ] ifTrue:[
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1736
                        "/ mhmh - multiple pixels mapped to the same color
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1737
                        n_pix := (newColorArray indexOf:n_clr) - 1.
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1738
                        map at:pix+1 put:n_pix.
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1739
                    ]
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1740
                ].
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1741
                newImage pixelAtX:x y:y put:n_pix.
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1742
            ].
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1743
    ] ifFalse:[
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1744
        ((image depth == 24) and:[image photometric == #rgb]) ifTrue:[
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1745
            pixelAction := 
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1746
                [:x :y |
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1747
                    |rgb clr n_rgb|
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1748
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1749
                    rgb := image pixelAtX:x y:y.
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1750
                    rgb == prevRGBIn ifTrue:[
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1751
                        n_rgb := prevRGBOut
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1752
                    ] ifFalse:[    
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1753
                        clr := Color rgbValue:rgb.
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1754
                        n_rgb := (functionOfColor value:clr) rgbValue.
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1755
                        prevRGBIn := rgb.
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1756
                        prevRGBOut := n_rgb.
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1757
                    ].
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1758
                    newImage pixelAtX:x y:y put:n_rgb.
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1759
                ].
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1760
        ] ifFalse:[
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1761
            pixelAction := 
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1762
                [:x :y |
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1763
                    |clr n_clr|
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1764
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1765
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1766
                    clr := image colorAtX:x y:y.
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1767
                    n_clr := functionOfColor value:clr.
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1768
                    newImage colorAtX:x y:y put:n_clr.
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1769
                ].
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1770
        ].    
2566
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1771
    ].
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1772
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1773
    0 to:yMax do:[:y |
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1774
        0 to:xMax do:[:x |
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1775
            pixelAction value:x value:y
1886
e5b5a8850dc5 added make grayScale
Claus Gittinger <cg@exept.de>
parents: 1885
diff changeset
  1776
        ]
e5b5a8850dc5 added make grayScale
Claus Gittinger <cg@exept.de>
parents: 1885
diff changeset
  1777
    ].
e5b5a8850dc5 added make grayScale
Claus Gittinger <cg@exept.de>
parents: 1885
diff changeset
  1778
2566
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1779
    image colorMap notNil ifTrue:[
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1780
        newImage colorMap:(MappedPalette withColors:newColorArray).
d0894c5f6d4d allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents: 2556
diff changeset
  1781
    ].
4730
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  1782
    self newImageWithUndo:newImage.
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1783
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1784
    "/ for now, always return true 
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1785
    "/ (do not check if functionOfColor returns somthing different)
1886
e5b5a8850dc5 added make grayScale
Claus Gittinger <cg@exept.de>
parents: 1885
diff changeset
  1786
    ^ true
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1787
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  1788
    "Modified (comment): / 31-08-2017 / 12:11:25 / cg"
1886
e5b5a8850dc5 added make grayScale
Claus Gittinger <cg@exept.de>
parents: 1885
diff changeset
  1789
!
e5b5a8850dc5 added make grayScale
Claus Gittinger <cg@exept.de>
parents: 1885
diff changeset
  1790
1121
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1791
makeSubImageX:oldX y:oldY width:newWidth height:newHeight
3706
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  1792
    |oldWidth oldHeight newImage newMaskImage needRedraw redrawRect1 redrawRect2 |
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  1793
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  1794
    oldWidth := image width.
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  1795
    oldHeight := image height.
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  1796
    self assert:(newWidth <= oldWidth).
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  1797
    self assert:(newHeight <= oldHeight).
1121
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1798
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1799
    newImage := image class width:newWidth height:newHeight depth:image depth.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1800
    newImage photometric:image photometric.
5468
2ca6776b4271 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5435
diff changeset
  1801
    image photometric == #palette ifTrue:[
2ca6776b4271 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5435
diff changeset
  1802
        newImage colorMap:image colorMap copy.
2ca6776b4271 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5435
diff changeset
  1803
    ].
1121
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1804
    newImage bits:(ByteArray new:(newImage bytesPerRow * newHeight)).
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1805
3706
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  1806
    image mask notNil ifTrue:[
1121
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1807
        newMaskImage := Depth1Image width:newWidth height:newHeight.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1808
        newMaskImage photometric: image mask photometric.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1809
        newMaskImage colorMap: image mask colorMap copy.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1810
        newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newHeight).
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1811
        newImage mask: newMaskImage
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1812
    ].
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1813
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1814
    newImage copyFrom:image x:oldX y:oldY toX:0 y:0 width:newWidth height:newHeight.
3706
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  1815
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  1816
    needRedraw := true.
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  1817
    (oldX == 0 and:[oldY == 0]) ifTrue:[
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  1818
        needRedraw := false.
5332
32b9a3b4abdb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5314
diff changeset
  1819
        redrawRect1 := ((newWidth@0) * magnification) corner:(((oldWidth@oldHeight)+1) * magnification).
32b9a3b4abdb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5314
diff changeset
  1820
        redrawRect2 := ((0@newHeight) * magnification) corner:(((oldWidth@oldHeight)+1) * magnification).
3706
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  1821
    ].
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  1822
    self image:newImage scroll:false invalidate:needRedraw.
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  1823
    redrawRect1 notNil ifTrue:[
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  1824
        self invalidateRectangle:redrawRect1 repairNow:false.
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  1825
    ].
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  1826
    redrawRect2 notNil ifTrue:[
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  1827
        self invalidateRectangle:redrawRect2 repairNow:false.
e95e7f0e4f82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  1828
    ].
2590
b811d560e00a modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  1829
    self setModified.
1121
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1830
5332
32b9a3b4abdb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5314
diff changeset
  1831
    "Created: / 07-09-1998 / 13:00:16 / cg"
5468
2ca6776b4271 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5435
diff changeset
  1832
    "Modified: / 13-02-2017 / 14:48:46 / cg"
1121
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1833
!
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1834
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  1835
makeUndo
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1836
    |theCopy|
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1837
    
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1838
    image notNil ifTrue:[        
3278
c42700648b31 shift-paste
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  1839
        [undoImages size >= MaxUndos] whileTrue:[
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  1840
            undoImages removeFirst.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  1841
        ].
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1842
        theCopy := image copy.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1843
        undoImages add:theCopy.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1844
        originalImage isNil ifTrue:[ originalImage := theCopy ].
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  1845
    ]
3278
c42700648b31 shift-paste
Claus Gittinger <cg@exept.de>
parents: 3277
diff changeset
  1846
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  1847
    "Modified: / 23-02-2017 / 15:43:55 / cg"
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  1848
!
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  1849
2135
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1850
pasteAt: aPoint mode:modeSymbol
5480
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
  1851
    "called from button-press/button motion while in paste mode:
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
  1852
     paste the image in the clipboard at aPoint"
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1853
2838
8525a35121d2 changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents: 2824
diff changeset
  1854
    |answer anyColorMissing choosenBox imagePoint imgX imgY copiedImage imageBox newColorMap
2764
3302aab746d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2756
diff changeset
  1855
     existingColors newColors allColors currentColorMap newColormap anyColorAdded oldColorMap|
1888
ef622d292093 colormap conversion
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1856
4203
a257aa6878ac class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4149
diff changeset
  1857
    Error handle:[:ex|
a257aa6878ac class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4149
diff changeset
  1858
        ex creator == Image unrepresentableColorSignal ifFalse:[
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1859
            ex reject
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1860
        ].
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1861
        self undo.
5061
f8346c455a4b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5029
diff changeset
  1862
        self warn:(resources stringWithCRs:'Paste failed !!\Increasing the images depth might help.'). 
1823
d11286b90d3b paste mask
Claus Gittinger <cg@exept.de>
parents: 1781
diff changeset
  1863
    ] do: [   
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1864
        windowGroup withExecuteCursorDo:[
2838
8525a35121d2 changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents: 2824
diff changeset
  1865
            choosenBox := self dragRectangleStartingAt: aPoint emphasis: #inverseFilledBox.
8525a35121d2 changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents: 2824
diff changeset
  1866
            choosenBox isNil ifTrue:[ ^ self ].
8525a35121d2 changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents: 2824
diff changeset
  1867
8525a35121d2 changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents: 2824
diff changeset
  1868
            imagePoint := choosenBox origin//magnification.
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1869
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  1870
            copiedImage := ClipboardImage copy.
5417
054dfa979ced #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5415
diff changeset
  1871
            copiedImage isNil ifTrue:[^ self].
054dfa979ced #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5415
diff changeset
  1872
            
2440
a9abeb0e3562 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2415
diff changeset
  1873
            true "/ image photometric == #palette 
1888
ef622d292093 colormap conversion
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1874
            ifTrue:[
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1875
                "/ for all colors in the pasted image,
5472
f87d19419651 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5468
diff changeset
  1876
                "/ check, if it's in the colormap of the
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1877
                "/ target image.
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1878
2764
3302aab746d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2756
diff changeset
  1879
                anyColorMissing := anyColorAdded := false.
3302aab746d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2756
diff changeset
  1880
                oldColorMap := image colorMap.
5434
29822bceb67d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
  1881
                (oldColorMap notNil and:[image photometric == #palette]) ifTrue:[
2764
3302aab746d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2756
diff changeset
  1882
                    newColorMap := oldColorMap asOrderedCollection.
1957
9a4347986d96 paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents: 1903
diff changeset
  1883
                    copiedImage usedValues do:[:pixel |
2764
3302aab746d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2756
diff changeset
  1884
                        |pastedColor |
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1885
1957
9a4347986d96 paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents: 1903
diff changeset
  1886
                        pastedColor := copiedImage colorFromValue:pixel.
2764
3302aab746d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2756
diff changeset
  1887
3762
1baf6a044dd2 changed: #pasteAt:mode:
Claus Gittinger <cg@exept.de>
parents: 3730
diff changeset
  1888
                        (newColorMap includes:pastedColor) ifFalse:[
2764
3302aab746d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2756
diff changeset
  1889
                            newColorMap size < (1 bitShift:image depth) ifTrue:[
1957
9a4347986d96 paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents: 1903
diff changeset
  1890
                                "/ add to colormap
9a4347986d96 paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents: 1903
diff changeset
  1891
                                newColorMap add:pastedColor.
2764
3302aab746d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2756
diff changeset
  1892
                                anyColorAdded := true.
1957
9a4347986d96 paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents: 1903
diff changeset
  1893
        "/                        Transcript showCR:'adding color:' , pastedColor displayString , ' to targets colorMap'.
9a4347986d96 paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents: 1903
diff changeset
  1894
                            ] ifFalse:[
9a4347986d96 paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents: 1903
diff changeset
  1895
        "/                        Transcript showCR:'color:' , pastedColor displayString , ' not found in targets colorMap'.
1987
eb9f2f7f1450 paste image
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
  1896
"/                                copiedImage colorMap notNil ifTrue:[
eb9f2f7f1450 paste image
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
  1897
"/                                    copiedImage colorMap at: pixel+1 put: Color black.
eb9f2f7f1450 paste image
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
  1898
"/                                ].
1957
9a4347986d96 paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents: 1903
diff changeset
  1899
                                anyColorMissing := true.
9a4347986d96 paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents: 1903
diff changeset
  1900
                            ]
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1901
                        ]
1957
9a4347986d96 paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents: 1903
diff changeset
  1902
                    ].
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1903
                ].
2764
3302aab746d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2756
diff changeset
  1904
1888
ef622d292093 colormap conversion
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1905
                anyColorMissing ifTrue:[
ef622d292093 colormap conversion
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1906
                    answer := Dialog
5061
f8346c455a4b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5029
diff changeset
  1907
                                confirmWithCancel:(resources stringWithCRs:'Some color(s) cannot be represented (colorMap full).\Use nearest or compute colorMap ?') 
2172
737d8733fb01 brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents: 2168
diff changeset
  1908
                                labels:#( 'Cancel' 'New ColorMap' 'Use Nearest' )
737d8733fb01 brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents: 2168
diff changeset
  1909
                                values:#(  nil new nearest)
737d8733fb01 brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents: 2168
diff changeset
  1910
                                default:3.
1888
ef622d292093 colormap conversion
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1911
ef622d292093 colormap conversion
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1912
                    answer isNil ifTrue:[^ self].
1986
630db3277f10 support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1913
630db3277f10 support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1914
                    currentColorMap := image colorMap.
1987
eb9f2f7f1450 paste image
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
  1915
                    imgX := imagePoint x.
eb9f2f7f1450 paste image
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
  1916
                    imgY := imagePoint y.
1986
630db3277f10 support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1917
1888
ef622d292093 colormap conversion
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1918
                    answer == #nearest ifTrue:[
ef622d292093 colormap conversion
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1919
                        0 to:copiedImage height-1 do:[:y |
ef622d292093 colormap conversion
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1920
                            0 to:copiedImage width-1 do:[:x |
ef622d292093 colormap conversion
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1921
                                |clr n_clr|
ef622d292093 colormap conversion
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1922
1987
eb9f2f7f1450 paste image
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
  1923
                                (copiedImage maskAtX:x y:y) == 0 ifTrue:[
eb9f2f7f1450 paste image
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
  1924
                                    image mask isNil ifTrue:[
eb9f2f7f1450 paste image
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
  1925
                                        image createMask.
eb9f2f7f1450 paste image
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
  1926
                                    ].
eb9f2f7f1450 paste image
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
  1927
                                    image maskAtX:imgX+x y:imgY+y put:0.
eb9f2f7f1450 paste image
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
  1928
                                ] ifFalse:[
2582
5f9a25414195 atX:y: changed to #colorAtX :y:
penk
parents: 2566
diff changeset
  1929
                                    clr := copiedImage colorAtX:x y:y.
1987
eb9f2f7f1450 paste image
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
  1930
                                    n_clr := clr nearestIn:currentColorMap.
2582
5f9a25414195 atX:y: changed to #colorAtX :y:
penk
parents: 2566
diff changeset
  1931
                                    image colorAtX:imgX+x y:imgY+y put:n_clr
1987
eb9f2f7f1450 paste image
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
  1932
                                ]
1888
ef622d292093 colormap conversion
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1933
                            ]
ef622d292093 colormap conversion
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1934
                        ].
1987
eb9f2f7f1450 paste image
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
  1935
                        image restored.
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  1936
                        self redraw: (imageBox := (imagePoint * magnification extent: (ClipboardImage extent * magnification)) expandedBy: 1@1).
2590
b811d560e00a modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  1937
                        self setModified.
6081
52da01945044 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5926
diff changeset
  1938
                        self changed:#imageColors.
1987
eb9f2f7f1450 paste image
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
  1939
                        ^ self.
2135
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1940
                    ].
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1941
                    answer == #new ifTrue:[
5926
ac15d2063d25 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5921
diff changeset
  1942
                        existingColors := image usedColors asSet.
ac15d2063d25 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5921
diff changeset
  1943
                        newColors := copiedImage usedColors.
ac15d2063d25 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5921
diff changeset
  1944
                        allColors := (Set withAll:existingColors) addAll:newColors; yourself.
2135
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1945
                        allColors size > (1 bitShift:image depth) ifTrue:[
5926
ac15d2063d25 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5921
diff changeset
  1946
                            self warn:(resources string:'Sorry: too many colors - please change the depth, then paste again').
2135
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1947
                            self undo.
1986
630db3277f10 support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1948
                            ^ self.
630db3277f10 support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1949
                        ].
2135
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1950
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1951
                        newColormap := OrderedCollection new.
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1952
                        newColormap addAll:image usedColors.
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1953
                        newColormap addAll:copiedImage usedColors.
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1954
                        "/ translate image to use new colorMap...
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1955
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1956
                        "/ translate image to use new colors ...
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1957
                        0 to:image height-1 do:[:y |
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1958
                            0 to:image width-1 do:[:x |
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1959
                                |clr n_idx|
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1960
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1961
                                (image maskAtX:x y:y) == 1 ifTrue:[
2582
5f9a25414195 atX:y: changed to #colorAtX :y:
penk
parents: 2566
diff changeset
  1962
                                    clr := image colorAtX:x y:y.
2135
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1963
                                    n_idx := newColormap indexOf:clr.
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1964
                                    image pixelAtX:x y:y put:n_idx-1.
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1965
                                ]
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1966
                            ]
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1967
                        ].
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1968
                        image colorMap:newColormap.
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1969
                        currentColorMap := newColormap.    
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1970
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1971
                        "/ paste new image...    
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1972
                        0 to:copiedImage height-1 do:[:y |
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1973
                            0 to:copiedImage width-1 do:[:x |
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1974
                                |clr idx|
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1975
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1976
                                (copiedImage maskAtX:x y:y) == 1
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1977
                                ifTrue:[
2582
5f9a25414195 atX:y: changed to #colorAtX :y:
penk
parents: 2566
diff changeset
  1978
                                    clr := copiedImage colorAtX:x y:y.
2135
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1979
                                    idx := currentColorMap indexOf:clr.
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1980
                                    idx == 0 ifTrue:[
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1981
                                        currentColorMap add:clr.
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1982
                                        idx := currentColorMap size.
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1983
                                        idx > (1 bitShift:image depth) ifTrue:[
5061
f8346c455a4b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5029
diff changeset
  1984
                                            self warn:(resources string:'Sorry: too many colors').
2135
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1985
                                            self undo.
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1986
                                            ^ self.
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1987
                                        ].
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1988
                                    ].
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1989
                                    image pixelAtX:imgX+x y:imgY+y put:idx-1.
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1990
                                    image maskAtX:imgX+x y:imgY+y put:1.
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1991
                                ]
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1992
                            ]
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1993
                        ].
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  1994
                        image restored.
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  1995
                        self redraw: (imageBox := (imagePoint * magnification extent: (ClipboardImage extent * magnification)) expandedBy: 1@1).
2590
b811d560e00a modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  1996
                        self setModified.
6081
52da01945044 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5926
diff changeset
  1997
                        self changed:#imageColors.
1888
ef622d292093 colormap conversion
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1998
                        ^ self.
ef622d292093 colormap conversion
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1999
                    ].
5061
f8346c455a4b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5029
diff changeset
  2000
                    self warn:(resources string:'Sorry: unimplemented function').
2135
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  2001
                    self undo.
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  2002
                    ^ self.
1888
ef622d292093 colormap conversion
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  2003
                ].
2764
3302aab746d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2756
diff changeset
  2004
                anyColorAdded ifTrue:[
2490
62230519175a slowly getting rid of the Colormap class
Claus Gittinger <cg@exept.de>
parents: 2489
diff changeset
  2005
                    image colorMap:(MappedPalette withColors:newColorMap).
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2006
                ].
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2007
            ].
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  2008
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2009
            copiedImage := image class fromImage: copiedImage.
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  2010
            (newColorMap isNil 
2135
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  2011
            and:[modeSymbol isNil
1987
eb9f2f7f1450 paste image
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
  2012
            and:[copiedImage mask isNil] ]) ifTrue:[
5654
587fc5c36cc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5653
diff changeset
  2013
                "/ use image's copy functionality
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  2014
                "/ however, this copies the mask as well,
5772
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2015
                "/ which is only useful for paste-mode nil (paste pixel+mask)
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2016
                image copyFrom: copiedImage x:0 y:0 toX: imagePoint x y: imagePoint y width: copiedImage width height: copiedImage height.
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2017
            ] ifFalse:[
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2018
                imgX := imagePoint x.
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2019
                imgY := imagePoint y.
1028
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
  2020
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2021
                0 to:copiedImage height-1 do:[:y |
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2022
                    0 to:copiedImage width-1 do:[:x |
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2023
                        |wasMasked newMasked dstX dstY oldColor|
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  2024
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2025
                        dstX := imgX + x.
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2026
                        dstY := imgY + y.
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2027
                        wasMasked := (image maskAtX:dstX y:dstY) == 0.
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2028
                        newMasked := (copiedImage maskAtX:x y:y) == 0.
994
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
  2029
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2030
                        "/ with modeUnder, 
5654
587fc5c36cc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5653
diff changeset
  2031
                        "/ only replace, if its masked,
5772
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2032
                        (modeSymbol isNil 
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2033
                            or:[modeSymbol == #withMask
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2034
                            or:[modeSymbol == #masked
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2035
                            or:[wasMasked]]]
5654
587fc5c36cc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5653
diff changeset
  2036
                        ) ifTrue:[
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  2037
                            newMasked ifFalse:[
2764
3302aab746d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2756
diff changeset
  2038
                                image colorAtX:dstX y:dstY put:(copiedImage colorAtX:x y:y).
1823
d11286b90d3b paste mask
Claus Gittinger <cg@exept.de>
parents: 1781
diff changeset
  2039
                                wasMasked ifTrue:[
5654
587fc5c36cc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5653
diff changeset
  2040
                                    "/ wasMasked before; no longer masked now
5772
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2041
                                    (modeSymbol == #withMask 
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2042
                                    or:[modeSymbol == #under
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2043
                                    or:[modeSymbol == #masked]]) ifTrue:[
5654
587fc5c36cc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5653
diff changeset
  2044
                                        image maskAtX:dstX y:dstY put:1
587fc5c36cc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5653
diff changeset
  2045
                                    ].
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  2046
                                ].
1823
d11286b90d3b paste mask
Claus Gittinger <cg@exept.de>
parents: 1781
diff changeset
  2047
                            ] ifTrue:[
d11286b90d3b paste mask
Claus Gittinger <cg@exept.de>
parents: 1781
diff changeset
  2048
                                wasMasked ifFalse:[
5654
587fc5c36cc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5653
diff changeset
  2049
                                    "/ masked now; was not masked before
2135
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  2050
                                    modeSymbol == #withMask ifTrue:[
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  2051
                                        image maskAtX:dstX y:dstY put:0
09782f280a97 added "paste with mask"
Claus Gittinger <cg@exept.de>
parents: 2092
diff changeset
  2052
                                    ]
1823
d11286b90d3b paste mask
Claus Gittinger <cg@exept.de>
parents: 1781
diff changeset
  2053
                                ]
d11286b90d3b paste mask
Claus Gittinger <cg@exept.de>
parents: 1781
diff changeset
  2054
                            ].
1987
eb9f2f7f1450 paste image
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
  2055
                        ].
eb9f2f7f1450 paste image
Claus Gittinger <cg@exept.de>
parents: 1986
diff changeset
  2056
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2057
                    ]
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2058
                ].
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2059
            ].
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2060
            image restored.
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  2061
            self redraw: (imageBox := (imagePoint * magnification extent: (ClipboardImage extent * magnification)) expandedBy: 1@1).
1028
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
  2062
"/            masterApplication imagePreView redraw: (imageBox expandedBy: 1).
2590
b811d560e00a modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  2063
            self setModified.
6081
52da01945044 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5926
diff changeset
  2064
            self changed:#imageColors.
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  2065
        ]
1028
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
  2066
   ]
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
  2067
5654
587fc5c36cc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5653
diff changeset
  2068
    "Modified: / 07-12-2017 / 15:56:42 / cg"
6081
52da01945044 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5926
diff changeset
  2069
    "Modified: / 29-06-2019 / 23:21:19 / Claus Gittinger"
636
d53428252193 revised version
tz
parents: 633
diff changeset
  2070
!
d53428252193 revised version
tz
parents: 633
diff changeset
  2071
2086
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2072
shiftImageHorizontal:shiftH vertical:shiftV
2489
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2073
    self shiftImageHorizontal:shiftH vertical:shiftV wrap:false
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2074
!
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2075
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2076
shiftImageHorizontal:shiftH vertical:shiftV wrap:doWrap
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2077
    "shift the pixels; 
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2078
     shift<0 is left-shift/up-shift; shift>0 is right-shift/down-shift;
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2079
     doWrap controls if shifted-out pixels are to be shifted in at the opposite side.
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2080
     i.e.:
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2081
        0123456789 -> 3456789789 (shift: -3)    0123456789 -> 0120123456 (shift:3)
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2082
     or, with wrap:
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2083
        0123456789 -> 3456789012 (shift: -3)    0123456789 -> 7890123456 (shift:3)
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2084
    "
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2085
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2086
    |newImage|
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2087
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2088
    newImage := self shifted:image horizontal:shiftH vertical:shiftV wrap:doWrap.
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2089
    self image:newImage.
2590
b811d560e00a modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  2090
    self setModified.
2489
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2091
!
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2092
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2093
shifted:image horizontal:shiftH vertical:shiftV wrap:doWrap
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2094
    "shift the pixels; 
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2095
     shift<0 is left-shift/up-shift; shift>0 is right-shift/down-shift;
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2096
     doWrap controls if shifted-out pixels are to be shifted in at the opposite side.
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2097
     i.e.:
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2098
        0123456789 -> 3456789789 (shift: -3)    0123456789 -> 0120123456 (shift:3)
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2099
     or, with wrap:
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2100
        0123456789 -> 3456789012 (shift: -3)    0123456789 -> 7890123456 (shift:3)
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2101
    "
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2102
2086
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2103
    |w h srcX srcY dstX dstY newImage|
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2104
2489
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2105
    doWrap ifTrue:[
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2106
        "/ if wrapping, split into two operations to make wrap-code below simpler.
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2107
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2108
        shiftH ~~ 0 ifTrue:[
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2109
            shiftV ~~ 0 ifTrue:[
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2110
                newImage := self shifted:image    horizontal:shiftH vertical:0 wrap:doWrap.
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2111
                newImage := self shifted:newImage horizontal:0      vertical:shiftV wrap:doWrap.
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2112
                ^ newImage
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2113
            ].
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2114
        ].
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2115
    ].
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2116
    (shiftV == 0 and:[shiftH == 0]) ifTrue:[
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2117
        ^ image
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2118
    ].
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2119
2086
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2120
    w := image width.
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2121
    h := image height.
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2122
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2123
    newImage := image copy.
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2124
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2125
    srcX := srcY := dstX := dstY := 0.
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2126
    shiftH < 0 ifTrue:[
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2127
        srcX := shiftH negated
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2128
    ] ifFalse:[
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2129
        dstX := shiftH
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2130
    ].
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2131
    shiftV < 0 ifTrue:[
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2132
        srcY := shiftV negated
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2133
    ] ifFalse:[
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2134
        dstY := shiftV
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2135
    ].
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2136
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2137
    newImage copyFrom:image x:srcX y:srcY toX:dstX y:dstY width:w-shiftH abs height:h-shiftV abs.
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2138
2489
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2139
    doWrap ifTrue:[
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2140
        srcX := srcY := dstX := dstY := 0.
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2141
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2142
        "/ already simplified - see above
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2143
        shiftH ~~ 0 ifTrue:[
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2144
            "/ shiftV known to be 0
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2145
            shiftH < 0 ifTrue:[
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2146
                dstX := w-1-shiftH negated
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2147
            ] ifFalse:[
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2148
                srcX := w-1-shiftH
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2149
            ].
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2150
            w := shiftH abs.
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2151
        ] ifFalse:[
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2152
            "/ shiftH known to be 0
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2153
            shiftV < 0 ifTrue:[
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2154
                dstY := h-1-shiftV negated
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2155
            ] ifFalse:[
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2156
                srcY := h-1-shiftV
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2157
            ].
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2158
            h := shiftV abs.
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2159
        ].
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2160
        newImage copyFrom:image x:srcX y:srcY toX:dstX y:dstY width:w height:h.
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2161
        ^ newImage
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2162
    ].
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2163
f5654b8104f4 shift + wrap
Claus Gittinger <cg@exept.de>
parents: 2480
diff changeset
  2164
    ^ newImage.
2086
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2165
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2166
    "Created: / 7.9.1998 / 13:00:16 / cg"
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2167
    "Modified: / 7.9.1998 / 14:15:32 / cg"
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2168
!
3e32adf8adab added shift operation
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2169
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2170
specialOperation:operation on:imageBox withColor:clr
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  2171
    "ask for and perform one of the special operations on the previously selected imageBox;
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2172
     then redraw as required"    
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2173
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2174
    self invalidate.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2175
    self windowGroup processExposeEvents.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2176
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2177
    operation isNil ifTrue:[^ false].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2178
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2179
    (self performSpecialOperation:operation on:imageBox withColor:self selectedColor) ifFalse:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2180
        ^ false
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2181
    ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2182
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2183
    image restored.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2184
    self invalidate. "/ : (choosedBox expandedBy: 1).
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2185
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2186
    "/ self redraw: (choosedBox expandedBy: 1).
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2187
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2188
    "/        "/ cg: what a kludge - please change to use a valueHolder,
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2189
    "/        "/ which gets the information ...
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2190
    "/        masterApplication imagePreView redraw: (imageBox expandedBy: 1).
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2191
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2192
    "/ cg: still a kludge - but less ugly
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2193
    self changed:#subImageIn with:(imageBox expandedBy: 1).
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2194
    self setModified.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2195
    ^ true
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2196
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2197
    "Created: / 20-02-2017 / 17:35:33 / cg"
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  2198
    "Modified (comment): / 22-02-2017 / 19:56:47 / cg"
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2199
!
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2200
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2201
text:aString at:aPoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2202
    "draw a character"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2203
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2204
    |tempForm|
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2205
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2206
    tempForm := Form extent:(image extent) depth:1 onDevice:device.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2207
    tempForm clear.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2208
    tempForm paint:(Color colorId:1).
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2209
    tempForm displayString:aString at:aPoint.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2210
    0 to:image extent x - 1 do:[:x |
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2211
        0 to:image extent y - 1 do:[:y |
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2212
            (tempForm valueAt:(x@y)) == 1 ifTrue:[
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2213
                self pointAt:(x@y) width:1
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2214
            ].
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2215
        ]
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2216
    ].
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2217
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2218
    "Modified: / 15-02-2012 / 22:47:44 / cg"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2219
!
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2220
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2221
undo
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  2222
    |newImage|
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  2223
    
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  2224
    undoImages notEmpty ifTrue:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  2225
        newImage := undoImages removeLast.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  2226
    ] ifFalse:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  2227
        (Dialog confirm:(resources string:'No more undo images remembered. Back to the initial image?'))
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  2228
            ifFalse:[^ self].
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  2229
        newImage := originalImage copy
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  2230
    ].
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  2231
    
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  2232
    windowGroup withExecuteCursorDo:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  2233
        |oldImage|
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  2234
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  2235
        oldImage := self image.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  2236
        self clearModified.
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  2237
        self image:newImage scroll:(newImage extent ~= oldImage extent).
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2238
    ]
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2239
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  2240
    "Modified: / 23-02-2017 / 15:47:15 / cg"
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2241
! !
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2242
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2243
!ImageEditView methodsFor:'image editing-editmode button actions'!
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2244
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2245
boxAt: aPoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2246
    "called from button-press/button motion while in box-drawing mode:
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2247
     drag a rectangular outline, 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2248
     when released, draw a rectangle with the currently selected color"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2249
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2250
    self 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2251
        commonBoxOperation:[:box :colorOrPixel |
5653
0cc4e96d490b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
  2252
            colorOrPixel isColor ifTrue:[
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2253
                image drawRectangle:box withColor:colorOrPixel.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2254
            ] ifFalse:[
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2255
                image drawRectangle:box withValue:colorOrPixel.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2256
            ].
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2257
        ]
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2258
        at:aPoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2259
5653
0cc4e96d490b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
  2260
    "Modified: / 07-12-2017 / 14:52:17 / cg"
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2261
!
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2262
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2263
circleAt: aPoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2264
    "called from button-press/button motion while in circle-drawing mode:
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2265
     drag an ellipse, 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2266
     when released, draw an ellipse with the currently selected color"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2267
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2268
    self 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2269
        commonBoxOperation:[:box :colorOrPixel |
5653
0cc4e96d490b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
  2270
            colorOrPixel isColor ifTrue:[
5506
47319def7d06 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5499
diff changeset
  2271
                image drawEllipse:box withColor:colorOrPixel lineWidth:penWidth.
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2272
            ] ifFalse:[
5506
47319def7d06 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5499
diff changeset
  2273
                image drawEllipse:box withValue:colorOrPixel lineWidth:penWidth.
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2274
            ].
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2275
        ]
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2276
        at:aPoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2277
5653
0cc4e96d490b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
  2278
    "Modified: / 07-12-2017 / 14:53:34 / cg"
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2279
!
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2280
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2281
commonBoxOperation:action at:aPoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2282
    "common code for filling/drawing."
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2283
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2284
    |choosenBox imageBox clr pix|
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2285
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2286
    (clr := self selectedColor) notNil ifTrue:[
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2287
        choosenBox := self dragRectangleStartingAt: aPoint emphasis: #box.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2288
        choosenBox notNil ifTrue:[
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2289
            imageBox := choosenBox origin//magnification extent: (choosenBox extent//magnification).
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2290
            (clr := self drawingColorOrNil) notNil ifTrue:[
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2291
                action value:imageBox value:clr.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2292
            ] ifFalse:[
5653
0cc4e96d490b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
  2293
                pix := self drawingPixelOrNil.
0cc4e96d490b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
  2294
                true "pix notNil" ifTrue:[ "/ nil is valid here, and means: masked
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2295
                    action value:imageBox value:pix.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2296
                ].
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2297
            ].
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2298
            image restored.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2299
            self redraw: (choosenBox expandedBy: 1).
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2300
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2301
            "/ cg: still a kludge - but less ugly
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2302
            self changed:#subImageIn with:(imageBox expandedBy: 1).
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2303
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2304
            self setModified.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2305
        ].
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2306
    ].
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2307
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2308
    "Created: / 16-02-2017 / 11:20:49 / cg"
5653
0cc4e96d490b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
  2309
    "Modified: / 07-12-2017 / 14:51:37 / cg"
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2310
!
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2311
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2312
copyAt: aPoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2313
    "called from button-press/button motion while in copy-drawing mode:
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2314
     drag a filled box, 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2315
     when released, copy the selected rectangle to the clipboard"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2316
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2317
    |choosenBox box copiedImage|
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2318
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2319
    choosenBox := self dragRectangleStartingAt: aPoint emphasis: #inverseFilledBox.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2320
    choosenBox notNil ifTrue:[
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2321
        box := choosenBox origin // magnification extent: (choosenBox extent // magnification).
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2322
        copiedImage := image subImageIn: box.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2323
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2324
        self class copyImageToClipboard:copiedImage.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2325
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2326
        self redraw:(choosenBox expandedBy:1)
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2327
    ]
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2328
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2329
    "Modified: / 21-08-1998 / 20:16:41 / cg"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2330
    "Modified (comment): / 16-02-2017 / 11:15:09 / cg"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2331
!
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2332
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2333
cropSubImageAt: aPoint
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2334
    "called from button-press/button motion while in crop-subImage mode:
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2335
     drag a filled box, 
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2336
     when released, change the image to the new bounds"
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2337
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2338
    |choosenBox imageBox|
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2339
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2340
    choosenBox := self dragRectangleStartingAt: aPoint emphasis: #inverseFilledBox.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2341
    choosenBox notNil ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2342
        imageBox := choosenBox origin//magnification extent: (choosenBox extent//magnification).
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2343
        self specialOperation:#editSubImage on:imageBox withColor:nil.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2344
    ]
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2345
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2346
    "Created: / 20-02-2017 / 17:27:50 / cg"
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2347
!
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2348
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2349
fillAt: aPoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2350
    "called from button-press motion while in floo-fill drawing mode:
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2351
     perform a flood-fill with the currently selected color"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2352
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2353
    windowGroup withExecuteCursorDo:[
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2354
        |filledPoints clr|
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2355
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2356
        (clr := self selectedColor) notNil ifTrue:[
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2357
            self updateActivity:'Flood filling - press CTRL-y to abort ...'.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2358
            [
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2359
                |pix|
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2360
6161
3353ad05fdb3 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 6160
diff changeset
  2361
                (clr := self drawingColorOrNil) ifTrue:[
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2362
                    pix := image valueFromColor:clr.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2363
                ] ifFalse:[
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2364
                    pix := self drawingPixelOrNil.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2365
                ].
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2366
                image floodFillAt:aPoint//magnification withValue:pix 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2367
                      maxDeviationInLight:floodFillMaxLightError 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2368
                      maxDeviationInHue:floodFillMaxHueError.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2369
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2370
                image restored.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2371
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2372
                self invalidate.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2373
                self changed:#subImageIn with:(image bounds).
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2374
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2375
                self setModified.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2376
            ] ifCurtailed:[
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2377
                self updateActivity:'Flood fill aborted.'
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2378
            ].
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2379
        ].
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2380
        self updateActivity:''
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2381
    ]
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2382
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2383
    "Modified: / 17-02-2017 / 15:30:38 / cg"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2384
!
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2385
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2386
filledBoxAt: aPoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2387
    "called from button-press/button motion while in filled rectangle-drawing mode:
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2388
     drag a filled box, 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2389
     when released, fill a rectangular area with the currently selected color"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2390
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2391
    self 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2392
        commonBoxOperation:[:box :colorOrPixel |
5594
26e8562cdf99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  2393
            image fillRectangle:box with:colorOrPixel.
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2394
        ]
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2395
        at:aPoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2396
5594
26e8562cdf99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  2397
    "Modified: / 05-09-2017 / 14:50:51 / cg"
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2398
!
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2399
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2400
filledCircleAt: aPoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2401
    "called from button-press/button motion while in filled circle-drawing mode:
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2402
     drag a filled ellipse, 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2403
     when released, fill an ellipse with the currently selected color"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2404
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2405
    self 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2406
        commonBoxOperation:[:box :colorOrPixel |
5653
0cc4e96d490b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
  2407
            colorOrPixel isColor ifTrue:[
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2408
                image fillEllipse:box withColor:colorOrPixel.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2409
            ] ifFalse:[
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2410
                image fillEllipse:box withValue:colorOrPixel.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2411
            ].
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2412
        ]
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2413
        at:aPoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2414
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2415
    "Created: / 16-02-2017 / 11:10:17 / cg"
5653
0cc4e96d490b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
  2416
    "Modified: / 07-12-2017 / 14:53:59 / cg"
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2417
!
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2418
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2419
maskOutsideCircleAt: aPoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2420
    "called from button-press/button motion while in filled rectangle-drawing mode:
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2421
     drag a box, 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2422
     when released, mask everything outside the rectangular area"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2423
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2424
    self 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2425
        commonBoxOperation:[:box :colorOrPixel |
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2426
            |newForm oldForm|
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2427
            
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2428
            newForm := Form extent:image extent depth:1 onDevice:Screen current.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2429
            newForm paint:(Color colorId:0).
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2430
            newForm fillRectangle:(newForm bounds).
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2431
            newForm paint:(Color colorId:1).
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2432
            newForm fillCircleIn:box.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2433
            oldForm := image mask asFormOn:Screen current.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2434
            newForm function:#and.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2435
            newForm paint:(Color colorId:1) on:(Color colorId:0).
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2436
            newForm copyFrom:oldForm x:0 y:0 toX:0 y:0 width:image width height:image height.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2437
            image mask:(ImageMask fromForm:newForm).
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2438
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2439
            "/ wrong: does not preserve already masked pixels...
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2440
            "/ image mask fillRectangle:(image bounds) withValue:0.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2441
            "/ image mask fillEllipse:box withValue:1.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2442
        ]
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2443
        at:aPoint.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2444
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2445
    image restored.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2446
    self invalidate.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2447
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2448
    "Created: / 16-02-2017 / 12:33:25 / cg"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2449
    "Modified: / 17-02-2017 / 16:47:47 / cg"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2450
!
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2451
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2452
maskOutsideRectAt: aPoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2453
    "called from button-press/button motion while in filled rectangle-drawing mode:
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2454
     drag a box, 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2455
     when released, mask everything outside the rectangular area"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2456
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2457
    self 
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2458
        commonBoxOperation:[:box :colorOrPixel |
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2459
            |newForm oldForm|
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2460
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2461
            newForm := Form extent:image extent depth:1 onDevice:Screen current.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2462
            newForm paint:(Color colorId:0).
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2463
            newForm fillRectangle:(newForm bounds).
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2464
            newForm paint:(Color colorId:1).
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2465
            newForm fillRectangle:box.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2466
            oldForm := image mask asFormOn:Screen current.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2467
            newForm function:#and.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2468
            newForm paint:(Color colorId:1) on:(Color colorId:0).
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2469
            newForm copyFrom:oldForm x:0 y:0 toX:0 y:0 width:image width height:image height.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2470
            image mask:(ImageMask fromForm:newForm).
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2471
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2472
            "/ wrong: does not preserve already masked pixels...
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2473
            "/image mask fillRectangle:(image bounds) withValue:0.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2474
            "/image mask fillRectangle:box withValue:1.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2475
        ]
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2476
        at:aPoint.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2477
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2478
    image restored.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2479
    self invalidate.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2480
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2481
    "Created: / 16-02-2017 / 12:33:06 / cg"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2482
    "Modified: / 17-02-2017 / 17:23:57 / cg"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2483
!
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2484
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2485
pasteAt: aPoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2486
    "called from button-press/button motion while in paste mode:
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2487
     paste the image in the clipboard at aPoint"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2488
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2489
    self pasteAt:aPoint mode:nil.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2490
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2491
    "Modified (comment): / 16-02-2017 / 11:13:54 / cg"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2492
!
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2493
5772
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2494
pasteMaskedAt: aPoint
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2495
    "called from button-press/button motion while in paste mode:
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2496
     paste the image in the clipboard at aPoint.
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2497
     In this mode, only pixels which are not masked in the source image
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2498
     are pasted."
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2499
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2500
    self pasteAt:aPoint mode:#masked.
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2501
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2502
    "Created: / 27-05-2018 / 10:43:11 / Claus Gittinger"
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2503
!
8f0b1b2f6a7e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2504
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2505
pasteUnderAt: aPoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2506
    "called from button-press/button motion while in paste mode:
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2507
     pasteUnder the image in the clipboard at aPoint.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2508
     In this mode, only pixels which are not equal to
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2509
     the current color or masked are pasted."
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2510
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2511
    self pasteAt:aPoint mode:#under.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2512
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2513
    "Modified (comment): / 16-02-2017 / 11:14:04 / cg"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2514
!
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2515
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2516
pasteWithMaskAt: aPoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2517
    "called from button-press/button motion while in paste mode:
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2518
     paste the image in the clipboard at aPoint.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2519
     In this mode, both the mask and the image pixel are pasted"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2520
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2521
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2522
    self pasteAt:aPoint mode:#withMask.
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2523
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2524
    "Modified (comment): / 16-02-2017 / 11:14:08 / cg"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2525
!
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2526
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2527
pointAt:aPoint
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2528
    "called from button-press/button motion while in point-drawing mode:
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2529
     draw a single pixel with the currently selected color"
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2530
5652
ba62eb22a43d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5618
diff changeset
  2531
    self pointAt:aPoint width:(self penWidth).
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2532
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2533
    "Modified: / 15-02-2012 / 22:47:30 / cg"
5652
ba62eb22a43d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5618
diff changeset
  2534
    "Modified (format): / 07-12-2017 / 14:46:17 / cg"
5485
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2535
!
fa049861df83 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2536
5604
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2537
pointAt:aPoint width:pw
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2538
    "called from button-press/button motion while in point-drawing mode:
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2539
     draw a single pixel (or dot of width pw) with the currently selected color"
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2540
5921
452bdfc2db29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5920
diff changeset
  2541
    |draw imagePoint clr pix newColor|
5604
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2542
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2543
    imagePoint := aPoint // magnification.
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2544
    (imagePoint x between:0 and:image width-1) ifFalse:[^ self].
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2545
    (imagePoint y between:0 and:image height-1) ifFalse:[^ self].
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2546
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2547
    draw := 
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2548
        [:point |
6150
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2549
            editMode == EditModePointBlend ifTrue:[
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2550
                (clr := self drawingColorOrNil) notNil ifTrue:[
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2551
                    newColor := (image colorAt:point) blendWith:clr.
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2552
                    image colorAt:point put:newColor
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2553
                ]
5604
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2554
            ] ifFalse:[
6150
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2555
                (clr := self drawingColorOrNil) notNil ifTrue:[
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2556
                    (clr isPseudoColor and:[image hasAlphaChannel]) ifTrue:[
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2557
                        "/ only set the alpha value
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2558
                        newColor := (image colorAt:point) alpha:clr alpha.
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2559
                    ] ifFalse:[    
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2560
                        newColor := clr.
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2561
                        "/ newColor alpha:clr alpha.
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2562
                        "/                    clr alpha = 1 ifTrue:[
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2563
                        "/                        newColor := clr.
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2564
                        "/                    ] ifFalse:[
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2565
                        "/                        clr alpha = 0 ifTrue:[
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2566
                        "/                            newColor := clr.
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2567
                        "/                        ] ifFalse:[    
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2568
                        "/                            oldColor := image colorAt:point.
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2569
                        "/                            newColor := clr alphaMixed:clr alpha with:oldColor.
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2570
                        "/                        ].
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2571
                        "/                    ].
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2572
                    ].
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2573
                    image atImageAndMask:point put:newColor
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2574
                ] ifFalse:[
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2575
                    "/ drawing with no color
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2576
                    pix := self drawingPixelOrNil. "/ nil is valid here, and means: masked
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2577
                    image atImageAndMask:point putValue:pix.
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2578
                ].             
5604
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2579
            ].             
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2580
            self invalidate:((point * magnification extent: magnification) expandedBy:1).
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2581
        ].
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2582
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2583
    draw value:imagePoint.
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2584
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2585
    pw > 1 ifTrue:[
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2586
        "/ draw with a wide pen
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2587
        (pw//2) negated to:(pw-(pw//2)-1) do:[:xOffs |
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2588
            (pw//2) negated to:(pw-(pw//2)-1) do:[:yOffs |
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2589
                imagePoint x + xOffs >= 0 ifTrue:[
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2590
                    imagePoint y + yOffs >= 0 ifTrue:[
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2591
                        draw value:(imagePoint + (xOffs@yOffs)).
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2592
                    ].
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2593
                ].
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2594
            ].
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2595
        ].
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2596
    ].
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2597
    self setModified.
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2598
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2599
    "Created: / 15-02-2012 / 22:47:08 / cg"
5652
ba62eb22a43d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5618
diff changeset
  2600
    "Modified: / 07-12-2017 / 14:49:48 / cg"
5604
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2601
!
0cfb9a0ea4eb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5600
diff changeset
  2602
6150
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2603
pointBlendAt:aPoint
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2604
    "called from button-press/button motion while in point-drawing mode:
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2605
     blend a single pixel with the currently selected color"
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2606
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2607
    self pointAt:aPoint width:(self penWidth).
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2608
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2609
    "Modified: / 15-02-2012 / 22:47:30 / cg"
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2610
    "Modified (format): / 07-12-2017 / 14:46:17 / cg"
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2611
!
d78950c03598 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6135
diff changeset
  2612
4715
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2613
smoothAt:aPoint
5480
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
  2614
    "called from button-press/button motion while in smoothing mode:
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
  2615
     smoth (average) a single pixel with pixels around"
4715
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2616
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2617
    |draw imagePoint x y w h|
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2618
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2619
    imagePoint := aPoint // magnification.
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2620
    w := image width.
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2621
    h := image height.
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2622
    ((x := imagePoint x) between:0 and:w-1) ifFalse:[^ self].
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2623
    ((y := imagePoint y) between:0 and:h-1) ifFalse:[^ self].
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2624
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2625
    draw := 
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2626
        [:point |
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2627
            |sumRed sumGreen sumBlue newClr|
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2628
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2629
            sumRed := sumGreen := sumBlue := 0.
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2630
            -1 to:1 do:[:dx |
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2631
                -1 to:1 do:[:dy |
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2632
                    |clr|
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2633
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2634
                    ((x + dx) between:0 and:w-1) ifTrue:[
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2635
                        ((y + dy) between:0 and:h-1) ifTrue:[   
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2636
                            clr := image colorAtX:(x + dx) y:(y + dy).
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2637
                            sumRed := sumRed + clr redByte.
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2638
                            sumGreen := sumGreen + clr greenByte.
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2639
                            sumBlue := sumBlue + clr blueByte.
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2640
                        ]
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2641
                    ].
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2642
                ]
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2643
            ].
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2644
            newClr := Color 
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2645
                        redByte:(sumRed / 9) rounded
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2646
                        greenByte:(sumGreen / 9) rounded 
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2647
                        blueByte:(sumBlue / 9) rounded. 
5480
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
  2648
4715
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2649
            image colorMap isNil ifTrue:[
5480
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
  2650
                "/ Transcript 
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
  2651
                "/     show:(image colorAt:point);
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
  2652
                "/     show:' -> ';
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
  2653
                "/     showCR:newClr.
4715
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2654
                image atImageAndMask:point put:newClr.
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2655
            ] ifFalse:[
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2656
                image atImageAndMask:point put:(image colorMap colorNearestTo:newClr).
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2657
            ].             
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2658
            self invalidate:((point * magnification extent: magnification) expandedBy:1).
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2659
        ].
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2660
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2661
    draw value:imagePoint.
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2662
    self setModified.
5480
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
  2663
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
  2664
    "Modified: / 16-02-2017 / 12:34:41 / cg"
4715
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2665
!
c851a10dd606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4714
diff changeset
  2666
1858
54138b1b3efd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  2667
specialOperationAt: aPoint
54138b1b3efd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  2668
    "special operation on a rectangular area"
54138b1b3efd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  2669
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2670
    |choosenBox operation imageBox|
2838
8525a35121d2 changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents: 2824
diff changeset
  2671
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  2672
    choosenBox := self dragRectangleStartingAt: aPoint emphasis:#inverseFilledBox.
2838
8525a35121d2 changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents: 2824
diff changeset
  2673
    choosenBox isNil ifTrue:[ ^ self ].
8525a35121d2 changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents: 2824
diff changeset
  2674
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2675
    operation := self askForSpecialOperation.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2676
    operation isNil ifTrue:[^ self].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2677
    
2838
8525a35121d2 changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents: 2824
diff changeset
  2678
    imageBox := choosenBox origin//magnification extent: (choosenBox extent//magnification).
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2679
    self specialOperation:operation on:imageBox withColor:self selectedColor.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2680
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2681
    "Modified: / 20-02-2017 / 17:38:32 / cg"
1858
54138b1b3efd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  2682
!
54138b1b3efd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1855
diff changeset
  2683
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
  2684
sprayAt: aPoint
5480
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
  2685
    "called from button-press/button motion while in spray mode:
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
  2686
     start spraying with the currently selected color"
3476
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
  2687
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
  2688
    |clr|
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
  2689
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
  2690
    (clr := self selectedColor) notNil ifTrue:[
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
  2691
        sprayPosition := aPoint.
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
  2692
        self startSpray.
4b4dce2bd87b +spray and circle
Claus Gittinger <cg@exept.de>
parents: 3435
diff changeset
  2693
    ].
5480
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
  2694
4333dad478a5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5472
diff changeset
  2695
    "Modified (comment): / 16-02-2017 / 11:12:28 / cg"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  2696
! !
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  2697
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2698
!ImageEditView methodsFor:'image manipulation'!
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2699
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2700
brightenImage
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2701
    "make the image brighter"
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2702
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2703
    image photometric == #palette ifTrue:[
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2704
        self makeNewColorMapByMapping:[:clr | clr lightened].
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2705
    ] ifFalse:[    
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2706
        self newImageWithUndo: (image copy lightened).
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2707
    ].
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2708
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2709
    "Modified: / 31-08-2017 / 12:09:39 / cg"
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2710
!
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2711
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2712
darkenImage
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2713
    "make the image darker"
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2714
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2715
    image photometric == #palette ifTrue:[
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2716
        self makeNewColorMapByMapping:[:clr | clr darkened].
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2717
    ] ifFalse:[    
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2718
        self newImageWithUndo: (image copy darkened).
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2719
    ].
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2720
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2721
    "Modified: / 31-08-2017 / 12:09:23 / cg"
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2722
!
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2723
5920
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2724
exchangeGreenBlueChannels
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2725
    "exchange red and blue channels"
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2726
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2727
    |newImage w h|
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2728
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2729
    image colorMap notNil ifTrue:[
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2730
        Dialog information:'This operation cannot be applied to palette images.'.
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2731
        ^ self.
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2732
    ].
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2733
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2734
    newImage := image copy.
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2735
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2736
    w := image width - 1.
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2737
    h := image height - 1.
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2738
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2739
    0 to:h do:[:y |
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2740
        0 to:w do:[:x |
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2741
            |oldColor newColor|
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2742
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2743
            oldColor := (image colorAtX:x y:y).
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2744
            newColor := Color redByte:(oldColor redByte)
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2745
                              greenByte:(oldColor blueByte)
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2746
                              blueByte:(oldColor greenByte)
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2747
                              alphaByte:(oldColor alphaByte).
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2748
            newImage colorAtX:x y:y put:newColor
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2749
        ]
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2750
    ].
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2751
    self newImageWithUndo:newImage.
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2752
!
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2753
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2754
exchangeRedBlueChannels
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2755
    "exchange red and blue channels"
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2756
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2757
    |newImage w h|
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2758
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2759
    image colorMap notNil ifTrue:[
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2760
        Dialog information:'This operation cannot be applied to palette images.'.
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2761
        ^ self.
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2762
    ].
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2763
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2764
    newImage := image copy.
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2765
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2766
    w := image width - 1.
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2767
    h := image height - 1.
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2768
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2769
    0 to:h do:[:y |
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2770
        0 to:w do:[:x |
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2771
            |oldColor newColor|
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2772
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2773
            oldColor := (image colorAtX:x y:y).
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2774
            newColor := Color redByte:(oldColor blueByte)
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2775
                              greenByte:(oldColor greenByte)
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2776
                              blueByte:(oldColor redByte)
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2777
                              alphaByte:(oldColor alphaByte).
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2778
            newImage colorAtX:x y:y put:newColor
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2779
        ]
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2780
    ].
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2781
    self newImageWithUndo:newImage.
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2782
!
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2783
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2784
exchangeRedGreenChannels
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2785
    "exchange red and green channels"
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2786
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2787
    |newImage w h|
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2788
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2789
    image colorMap notNil ifTrue:[
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2790
        Dialog information:'This operation cannot be applied to palette images.'.
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2791
        ^ self.
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2792
    ].
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2793
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2794
    newImage := image copy.
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2795
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2796
    w := image width - 1.
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2797
    h := image height - 1.
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2798
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2799
    0 to:h do:[:y |
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2800
        0 to:w do:[:x |
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2801
            |oldColor newColor|
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2802
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2803
            oldColor := (image colorAtX:x y:y).
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2804
            newColor := Color redByte:(oldColor greenByte)
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2805
                              greenByte:(oldColor redByte)
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2806
                              blueByte:(oldColor blueByte)
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2807
                              alphaByte:(oldColor alphaByte).
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2808
            newImage colorAtX:x y:y put:newColor
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2809
        ]
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2810
    ].
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2811
    self newImageWithUndo:newImage.
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2812
!
bf761a3591fd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5871
diff changeset
  2813
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2814
flipHorizontal
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2815
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2816
    self newImageWithUndo:(image copy flipHorizontal).
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2817
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2818
    "Modified (format): / 31-08-2017 / 12:13:03 / cg"
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2819
!
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2820
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2821
flipVertical
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2822
    self newImageWithUndo:(image copy flipVertical).
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2823
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2824
    "Modified: / 31-08-2017 / 12:13:11 / cg"
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2825
!
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2826
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2827
makeBorderedImageX:newX y:newY width:newWidth height:newHeight
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2828
    |newImage oldWidth oldHeight|
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2829
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2830
    oldWidth := image width.
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2831
    oldHeight := image height.
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2832
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2833
    newImage := image class width:newWidth height:newHeight depth:image depth.
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2834
    newImage photometric:image photometric.
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2835
    newImage colorMap:image colorMap copy.
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2836
    newImage bits:(ByteArray new:(newImage bytesPerRow * newHeight)).
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2837
2842
fe13fb01edd3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2841
diff changeset
  2838
    image mask notNil ifTrue:[
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2839
        |newMaskImage|
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2840
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2841
        newMaskImage := Depth1Image width:newWidth height:newHeight.
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2842
        newMaskImage photometric: image mask photometric.
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2843
        newMaskImage colorMap: image mask colorMap copy.
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2844
        newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newHeight).
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2845
        newImage mask: newMaskImage
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2846
    ].
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2847
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2848
    newImage copyFrom:image x:0 y:0 toX:newX y:newY width:oldWidth height:oldHeight.
4730
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  2849
    self newImageWithUndo:newImage.
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2850
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2851
    "Created: / 7.9.1998 / 13:00:16 / cg"
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2852
    "Modified: / 7.9.1998 / 14:15:32 / cg"
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2853
!
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2854
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2855
makeBrighter
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2856
    "make the image brighter (obsolete, backward compatible entry)"
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2857
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2858
    self brightenImage
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2859
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2860
    "Modified: / 31-08-2017 / 12:12:38 / cg"
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2861
!
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2862
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2863
makeDarker
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2864
    "make the image darker (obsolete, backward compatible entry)"
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2865
    
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2866
    self darkenImage
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2867
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2868
    "Modified: / 31-08-2017 / 12:12:41 / cg"
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2869
!
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2870
2841
0f0750749f34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2839
diff changeset
  2871
makeGrayScaleImage
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2872
    self makeNewColorMapByMapping:
4730
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  2873
        [:clr | Color brightness:(clr brightness)].
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2874
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2875
    "Modified: / 31-08-2017 / 12:12:30 / cg"
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2876
!
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2877
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2878
makeInverse
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2879
    self makeNewColorMapByMapping:
4730
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  2880
        [:clr | 
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2881
            Color 
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2882
                redByte:(255-clr redByte) 
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2883
                greenByte:(255-clr greenByte) 
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2884
                blueByte:(255-clr blueByte)
4730
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  2885
        ].
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2886
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2887
    "Modified: / 31-08-2017 / 12:47:20 / cg"
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2888
!
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2889
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2890
makeInvertedBits
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2891
    "invert the pixels
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2892
     for palette images, this will lead to funny results;
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2893
     for all others, this makes it a negative"
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2894
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2895
    |newImage|
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2896
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2897
    newImage := image copy.
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2898
    newImage bits invert.
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2899
    self newImageWithUndo:newImage.
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2900
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2901
    "Created: / 31-08-2017 / 12:48:33 / cg"
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2902
    "Modified (comment): / 31-08-2017 / 14:02:28 / cg"
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2903
!
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2904
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2905
makeNegative
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2906
    "make a real negative.
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2907
     For non-palette images, this is done by inverting the pixels;
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2908
     for palette images, we need new colors."
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2909
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2910
    image photometric ~~ #palette ifTrue:[
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2911
        self makeInvertedBits.
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2912
        ^ self.
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2913
    ].    
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2914
    
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2915
    self makeNewColorMapByMapping:
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2916
        [:clr | 
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2917
            Color 
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2918
                redByte:(255-clr redByte) 
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2919
                greenByte:(255-clr greenByte) 
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2920
                blueByte:(255-clr blueByte)
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2921
        ].
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2922
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2923
    "Created: / 31-08-2017 / 13:50:39 / cg"
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2924
!
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2925
3971
Claus Gittinger <cg@exept.de>
parents: 3931
diff changeset
  2926
makeSlightlyBrighter
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2927
    self makeNewColorMapByMapping:
4730
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  2928
        [:clr | 
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  2929
            clr brightness > Color lightGray brightness
5163
955f893d03f2 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5093
diff changeset
  2930
                ifTrue:[ clr blendWith:self whiteColor ] 
4730
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  2931
                ifFalse:[ clr blendWith:Color lightGray ]
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  2932
        ].
3971
Claus Gittinger <cg@exept.de>
parents: 3931
diff changeset
  2933
Claus Gittinger <cg@exept.de>
parents: 3931
diff changeset
  2934
    "Created: / 24-11-2010 / 11:08:18 / cg"
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2935
    "Modified: / 31-08-2017 / 12:11:34 / cg"
3971
Claus Gittinger <cg@exept.de>
parents: 3931
diff changeset
  2936
!
Claus Gittinger <cg@exept.de>
parents: 3931
diff changeset
  2937
Claus Gittinger <cg@exept.de>
parents: 3931
diff changeset
  2938
makeSlightlyDarker
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2939
    self makeNewColorMapByMapping:
4730
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  2940
        [:clr | 
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  2941
            clr brightness < Color darkGray brightness
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  2942
                ifTrue:[ clr blendWith:Color black ] 
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  2943
                ifFalse:[ clr blendWith:Color darkGray ]
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  2944
        ].
3971
Claus Gittinger <cg@exept.de>
parents: 3931
diff changeset
  2945
Claus Gittinger <cg@exept.de>
parents: 3931
diff changeset
  2946
    "Created: / 24-11-2010 / 11:08:08 / cg"
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2947
    "Modified: / 31-08-2017 / 12:11:39 / cg"
3971
Claus Gittinger <cg@exept.de>
parents: 3931
diff changeset
  2948
!
Claus Gittinger <cg@exept.de>
parents: 3931
diff changeset
  2949
4730
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  2950
newImageWithUndo:newImage
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2951
    "undoable set a new image (after processing)"
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2952
    
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2953
    self makeUndo.
4730
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  2954
    self image: newImage.
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2955
    self setModified.
5589
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2956
c10991d8d1a0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5588
diff changeset
  2957
    "Modified (comment): / 31-08-2017 / 12:09:11 / cg"
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2958
!
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  2959
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2960
performSpecialOperation:operation on:imageBox withColor:clr
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2961
    "actually perform one of the special operations on the previously selected imageBox"    
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2962
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2963
    |x0 y0 x1 y1 pixelAction requiredColors missingColors answer hue|
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2964
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2965
    x0 := imageBox left.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2966
    y0 := imageBox top.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2967
    x1 := imageBox right - 1.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2968
    y1 := imageBox bottom -1 .
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2969
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2970
    operation == #edit ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2971
        (self image subImageIn:imageBox) edit.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2972
        ^ false.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2973
    ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2974
    operation == #editSubImage ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2975
        self makeUndo.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2976
        self image:(self image subImageIn:imageBox).
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2977
        ^ false.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2978
    ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2979
    operation == #flipVertical ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2980
        self flipSubImage:#vertical in:imageBox.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2981
        ^ true.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2982
    ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2983
    operation == #flipHorizontal ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2984
        self flipSubImage:#horizontal in:imageBox.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2985
        ^ true.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  2986
    ].
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  2987
    operation == #autoGradientFillVertical ifTrue:[
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  2988
        self gradientFillIn:imageBox orientation:#vertical auto:true.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  2989
        ^ true.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  2990
    ].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  2991
    operation == #autoGradientFillHorizontal ifTrue:[
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  2992
        self gradientFillIn:imageBox orientation:#horizontal auto:true.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  2993
        ^ true.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  2994
    ].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  2995
    operation == #autoGradientFillDiagonal ifTrue:[
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  2996
        self gradientFillIn:imageBox orientation:#diagonal auto:true.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  2997
        ^ true.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  2998
    ].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  2999
    operation == #gradientFillVertical ifTrue:[
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  3000
        self gradientFillIn:imageBox orientation:#vertical auto:false.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  3001
        ^ true.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  3002
    ].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  3003
    operation == #gradientFillHorizontal ifTrue:[
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  3004
        self gradientFillIn:imageBox orientation:#horizontal auto:false.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  3005
        ^ true.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  3006
    ].
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  3007
    operation == #gradientFillDiagonal ifTrue:[
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  3008
        self gradientFillIn:imageBox orientation:#diagonal auto:false.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  3009
        ^ true.
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  3010
    ].
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3011
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3012
    operation == #slightlyBrightened ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3013
        pixelAction := [:x :y :clr | clr slightlyLightened].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3014
    ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3015
    operation == #slightlyDarkened ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3016
        pixelAction := [:x :y :clr | clr slightlyDarkened].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3017
    ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3018
    operation == #brightened ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3019
        pixelAction := [:x :y :clr | clr lightened].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3020
    ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3021
    operation == #darkened ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3022
        pixelAction := [:x :y :clr | clr darkened].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3023
    ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3024
    operation == #reversed ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3025
        pixelAction := [:x :y :clr | Color red:(100-clr red) green:(100-clr green) blue:(100-clr blue) ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3026
    ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3027
    operation == #makeGrey ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3028
        pixelAction := [:x :y :clr | Color grey:(clr greyIntensity)].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3029
    ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3030
    operation == #greyed ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3031
        pixelAction := [:x :y :clr | clr blendWith:Color gray].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3032
    ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3033
    operation == #greyPattern ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3034
        pixelAction := [:x :y :clr | x odd == y even 
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3035
                                        ifTrue:[Color gray] 
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3036
                                        ifFalse:[clr]].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3037
    ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3038
    operation == #unmaskedGreyPattern ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3039
        pixelAction := [:x :y :clr | x odd == y even 
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3040
                                        ifTrue:[self image maskAtX:x y:y put:1. Color gray] 
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3041
                                        ifFalse:[clr]].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3042
    ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3043
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3044
    operation == #changeHue ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3045
        hue := Dialog request:'Hue (0..360)\red->yellow->green->blue->red' withCRs.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3046
        hue := Number readFrom:hue onError:nil.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3047
        hue isNil ifTrue:[^ false].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3048
        pixelAction := [:x :y :clr | Color hue:(hue+(clr hue?0)) light:clr light saturation:clr saturation].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3049
    ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3050
    operation == #colorize ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3051
        hue := Dialog request:'Hue (0..360)\red->yellow->green->blue->red' withCRs.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3052
        hue := Number readFrom:hue onError:nil.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3053
        hue isNil ifTrue:[^ false].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3054
        pixelAction := [:x :y :clr | Color hue:hue light:clr light saturation:100]
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3055
    ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3056
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3057
    pixelAction isNil ifTrue:[
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  3058
        Dialog warn:(resources string:'Sorry - unimplemented pixelAction: ',operation asString). 
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3059
        ^ false
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3060
    ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3061
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3062
    image colorMap notNil ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3063
        "/ compute required colors ...
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3064
        requiredColors := Set new.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3065
        self image 
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3066
            colorsFromX:x0 y:y0 toX:x1 y:y1 
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3067
            do:[:x :y :clr | 
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3068
                requiredColors add:(pixelAction value:x value:y value:clr)
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3069
            ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3070
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3071
        missingColors := requiredColors reject:[:clr | (image colorMap includes:clr)].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3072
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3073
        missingColors notEmpty ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3074
            answer := Dialog
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3075
                        confirmWithCancel:(resources stringWithCRs:'Some color(s) cannot be represented in the images colorMap.\Use nearest or compute colorMap ?')
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3076
                        labels:#( 'Cancel' 'Add to ColorMap'  'Use Nearest')
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3077
                        values:#( nil add nearest)
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3078
                        default:3.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3079
            answer isNil ifTrue:[^ false].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3080
            answer == #add ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3081
                missingColors size + image colorMap size > (2 raisedTo:image depth) ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3082
                    self warn:(resources string:'Missing colors cannot be added to images colormap.').
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3083
                    ^ false
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3084
                ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3085
                missingColors do:[:eachColor |
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3086
                    image colorMap add:eachColor
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3087
                ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3088
                answer := #nearest.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3089
            ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3090
        ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3091
    ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3092
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3093
    "/ now, do it
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3094
    self image 
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3095
        colorsFromX:x0 y:y0 toX:x1 y:y1 
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3096
        do:[:x :y :clr |
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3097
            |newClr|
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3098
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3099
            newClr := pixelAction value:x value:y value:clr.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3100
            answer == #nearest ifTrue:[
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3101
                newClr := newClr nearestIn:image colorMap
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3102
            ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3103
            self image colorAtX:x y:y put:newClr
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3104
        ].
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3105
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3106
    self setModified.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3107
    ^ true.
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3108
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3109
    "Created: / 20-02-2017 / 17:30:00 / cg"
5497
c015e96a1563 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5493
diff changeset
  3110
    "Modified: / 22-02-2017 / 20:56:51 / cg"
5491
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3111
!
a78da5678d29 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  3112
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3113
reduceColorResolutionBy:numBits
5871
d327fa0c4f64 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5772
diff changeset
  3114
    "reduce by masking off numBits r/g/b bits"
d327fa0c4f64 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5772
diff changeset
  3115
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3116
    |newImage|
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3117
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3118
    numBits > 7 ifTrue:[
5061
f8346c455a4b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5029
diff changeset
  3119
        self warn:(resources string:'Max. number of bits to strip off is 7.').
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3120
        ^ false
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3121
    ].
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3122
    newImage := image withColorResolutionReducedBy:numBits.
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3123
    newImage isNil ifTrue:[
5061
f8346c455a4b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5029
diff changeset
  3124
        self warn:(resources string:'Could not reduce color resolution.').
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3125
        ^ false.
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3126
    ].
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3127
4730
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  3128
    self newImageWithUndo:newImage.
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3129
    ^ true
5871
d327fa0c4f64 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5772
diff changeset
  3130
d327fa0c4f64 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5772
diff changeset
  3131
    "Modified (comment): / 06-08-2018 / 00:45:42 / Claus Gittinger"
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3132
!
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3133
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3134
resizeImageTo:newSize
4730
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  3135
    self newImageWithUndo: (self resizedImage:image to:newSize).
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  3136
!
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  3137
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  3138
resizedImage:image to:newSize
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  3139
    "helper for image resize and mask resize.
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  3140
     return a resized version of image"
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3141
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3142
    |newImage newMaskImage|
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3143
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3144
    newImage := image class width: newSize x height: newSize y depth: image depth.
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3145
    newImage photometric:image photometric.
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3146
    newImage colorMap:image colorMap copy.
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3147
    newImage bits: (ByteArray new: newImage bytesPerRow * newSize y).
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3148
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3149
    image mask notNil ifTrue:[
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3150
        newMaskImage := Depth1Image width: newSize x height: newSize y.
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3151
        newMaskImage photometric: image mask photometric.
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3152
        newMaskImage colorMap: image mask colorMap copy.
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3153
        newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newSize y).
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3154
        newImage mask: newMaskImage
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3155
    ].
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3156
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3157
    newImage copyFrom:image x:0 y:0 toX:0 y:0 width: (image width min:newSize x) height: (image height min:newSize y).
4730
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  3158
    ^ newImage.
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3159
!
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3160
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3161
rotateImageBy:rotation
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3162
    "rotate by (degrees)"
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3163
4212
4b84444912b5 exception access
Claus Gittinger <cg@exept.de>
parents: 4203
diff changeset
  3164
    Error handle:[:ex|
3435
400079196849 3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents: 3319
diff changeset
  3165
        self warn: 'Image rotation failed!!\' withCRs, 'Increasing the image depth could help.'
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3166
    ] do:[   
4730
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  3167
        self newImageWithUndo: (image hardRotated: rotation).
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3168
    ]
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3169
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3170
    "Modified: / 29.7.1998 / 18:21:14 / cg"
3435
400079196849 3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents: 3319
diff changeset
  3171
!
400079196849 3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents: 3319
diff changeset
  3172
400079196849 3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents: 3319
diff changeset
  3173
threeDProjection:dx1 and:dx2
400079196849 3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents: 3319
diff changeset
  3174
    "3D projection"
400079196849 3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents: 3319
diff changeset
  3175
4212
4b84444912b5 exception access
Claus Gittinger <cg@exept.de>
parents: 4203
diff changeset
  3176
    Error handle:[:ex|
3435
400079196849 3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents: 3319
diff changeset
  3177
        self warn: 'Image projection failed!!\' withCRs, 'Increasing the image depth could help.'
400079196849 3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents: 3319
diff changeset
  3178
    ] do:[   
4730
bcf8e15b7606 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4723
diff changeset
  3179
        self newImageWithUndo:(image threeDProjected:dx1 and:dx2)
3435
400079196849 3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents: 3319
diff changeset
  3180
    ]
400079196849 3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents: 3319
diff changeset
  3181
400079196849 3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents: 3319
diff changeset
  3182
    "Modified: / 29.7.1998 / 18:21:14 / cg"
2839
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3183
! !
312c7d2616bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2838
diff changeset
  3184
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3185
!ImageEditView methodsFor:'image-dragging & info'!
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3186
2838
8525a35121d2 changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents: 2824
diff changeset
  3187
dragRectangleStartingAt:aPointIn emphasis:emphasis
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3188
    "draw a drag rectangle (filled or unfilled, depending on the emphasis arg).
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3189
     This is called by operation like 
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3190
     rectangle, filledRectangle, copy etc. 
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3191
     (i.e. any operation which operates on a box).
5695
0e68bf885fa0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5671
diff changeset
  3192
     The cpu stays in this method dragging the mouse pointer,
0e68bf885fa0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5671
diff changeset
  3193
     until the button is released.
0e68bf885fa0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5671
diff changeset
  3194
0e68bf885fa0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5671
diff changeset
  3195
     Emphasis is one of:
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3196
        box              - a frame is drawn
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3197
        inverseFilledBox - the dragged box is filled by the inverse color
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3198
        filledBox        - the dragged box is filled with black
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3199
        grayedBox        - the dragged box is drawn with a gray shadow
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3200
    "
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3201
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3202
    |currentPoint currentExtent firstPoint lastCurrentPoint gridCorrection 
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3203
     mp lastMp p whichQuarter scrollX scrollY aPoint sensor|
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3204
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3205
    aPoint := aPointIn.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3206
    firstPoint := currentPoint := lastCurrentPoint :=  aPoint//magnification*magnification.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3207
    magnification >= GridMagnificationLimit ifFalse: [gridCorrection := 0] ifTrue: [gridCorrection := 1].
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3208
5695
0e68bf885fa0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5671
diff changeset
  3209
    "/ polling loop here...
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3210
    sensor := self sensor.
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3211
    [sensor anyButtonPressed] whileTrue: [                                                  
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3212
        (sensor hasKeyEventFor:nil) ifTrue:[
2838
8525a35121d2 changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents: 2824
diff changeset
  3213
            self invalidate.
8525a35121d2 changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents: 2824
diff changeset
  3214
            ^ nil.
8525a35121d2 changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents: 2824
diff changeset
  3215
        ].
8525a35121d2 changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents: 2824
diff changeset
  3216
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3217
        mp := sensor mousePoint.
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3218
        mp = lastMp ifTrue:[
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3219
            Delay waitForSeconds:0.05
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3220
        ] ifFalse:[
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3221
            lastMp := mp.
4999
e0111330133e device access
Claus Gittinger <cg@exept.de>
parents: 4967
diff changeset
  3222
            mp := device translatePoint:mp fromView:nil toView:self.
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3223
            "/ mp is a device coordinate here ...
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3224
            scrollX := 0.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3225
            mp x > width ifTrue:[
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3226
                scrollX := mp x - width.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3227
            ] ifFalse:[
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3228
                mp x < 0 ifTrue:[
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3229
                    scrollX := mp x.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3230
                ]
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3231
            ].
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3232
            scrollY := 0.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3233
            mp y > height ifTrue:[
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3234
                scrollY := mp y - height.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3235
            ] ifFalse:[
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3236
                mp y < 0 ifTrue:[
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3237
                    scrollY := mp y.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3238
                ]
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3239
            ].
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3240
            (scrollX + scrollY) ~~ 0 ifTrue:[
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3241
                self scrollTo:(self viewOrigin + (scrollX @ scrollY)).
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3242
                lastMp := nil.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3243
            ].
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3244
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3245
            mp := mp + self viewOrigin.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3246
            "/ mp is now a logical coordinate.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3247
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3248
            currentPoint := (0@0) max: (image extent * magnification min: (p := mp)).
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3249
            currentPoint := currentPoint//magnification*magnification.
5593
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
  3250
            
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3251
            currentExtent := (firstPoint - currentPoint) abs.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3252
            whichQuarter := (firstPoint x - currentPoint x) > 0 
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3253
                 ifTrue:  [(firstPoint y - currentPoint y) > 0 ifTrue: ["4"1@1] ifFalse: ["3"1@0]]
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3254
                 ifFalse: [(firstPoint y - currentPoint y) > 0 ifTrue: ["1"0@1] ifFalse: ["2"0@0]].
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3255
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3256
            self showCursorAt: p andInformation: 
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3257
                ((firstPoint//magnification - whichQuarter + 1) printString, 
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3258
                ' to: ', 
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3259
                (currentPoint//magnification + whichQuarter) printString),
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3260
                ' (extent: ',
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3261
                (currentExtent//magnification) printString, ')'.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3262
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3263
            currentPoint ~= lastCurrentPoint ifTrue:[
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3264
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3265
                emphasis == #grayedBox ifTrue:[
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3266
                    "/ does not yet work                
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3267
                    |org ext|
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3268
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3269
                    "/ org := (firstPoint min: lastCurrentPoint) - 1.
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3270
                    "/ ext := (firstPoint - lastCurrentPoint) abs + 2.
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3271
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3272
                    (lastCurrentPoint x > currentPoint x
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3273
                      or:[ (lastCurrentPoint y > currentPoint y) ]
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3274
                    ) ifTrue:[
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3275
                        self 
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3276
                            redrawImageX:firstPoint x"-1" y:firstPoint y"-1" 
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3277
                            width:(lastCurrentPoint x-firstPoint x"+2") height:(lastCurrentPoint y-firstPoint y"+2")
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3278
                            unmaskedOnly:false processColorsWith:[:clr | clr ].
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3279
                        "/ self drawFramesIn:(firstPoint corner:lastCurrentPoint).   
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3280
                    ].
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3281
                    
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3282
                    self 
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3283
                        redrawImageX:firstPoint x"-1" y:firstPoint y"-1 "
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3284
                        width:(currentPoint x-firstPoint x"+2") height:(currentPoint y-firstPoint y"+2") 
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3285
                        unmaskedOnly:true processColorsWith:[:clr | Color gray: clr grayIntensity / 2 ].
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3286
                ].
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3287
                
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3288
                emphasis == #inverseFilledBox ifTrue: [
5414
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3289
                    |union invertOutside|
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3290
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3291
                    invertOutside := false.
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3292
"/                    union := (firstPoint corner:currentPoint) merge:(firstPoint corner:lastCurrentPoint).
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3293
"/                    ((lastCurrentPoint x > currentPoint x)
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3294
"/                    and:[ lastCurrentPoint y > currentPoint y ]) ifTrue:[
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3295
"/                        "/ a real shrink
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3296
"/                        invertOutside := true.
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3297
"/                        self xoring: [ 
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3298
"/                            union areasOutside:(firstPoint corner:lastCurrentPoint) do:[:r |
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3299
"/                                self fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection) 
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3300
"/                            ]
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3301
"/                        ]
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3302
"/                    ] ifFalse:[    
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3303
"/                        ((currentPoint x > lastCurrentPoint x)
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3304
"/                        and:[ currentPoint y > lastCurrentPoint y ]) ifTrue:[
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3305
"/                            "/ a real grow
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3306
"/                            invertOutside := true.
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3307
"/                            self xoring: [ 
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3308
"/                                union areasOutside:(firstPoint corner:currentPoint) do:[:r |
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3309
"/                                    self fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection) 
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3310
"/                                ]
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3311
"/                            ]
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3312
"/                        ].     
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3313
"/                    ].
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3314
                    invertOutside ifFalse:[    
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3315
                        self redraw: ((firstPoint min: lastCurrentPoint) - 1 extent: (firstPoint - lastCurrentPoint) abs + 2).
5432
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
  3316
                        gc xoring: [ 
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
  3317
                            gc fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection) 
5414
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3318
                        ]
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3319
                    ].
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3320
                ].
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3321
                
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3322
                emphasis == #box ifTrue:[
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3323
                    |origin extent lineWidthY lineWidthX|
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3324
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3325
                    origin := (firstPoint min: lastCurrentPoint) - 1.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3326
                    extent := (firstPoint - lastCurrentPoint) abs + 2.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3327
                    lineWidthY := extent y min: (magnification y + 2).
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3328
                    lineWidthX := extent x min: (magnification x + 2).
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3329
                    self redraw: (origin extent: (extent x@lineWidthY)).
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3330
                    self redraw: ((origin x@(origin y + extent y - lineWidthY)) extent: (extent x@lineWidthY)).
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3331
                    self redraw: ((origin x@(origin y + lineWidthY)) extent: (lineWidthX@(0 max: (extent y - (lineWidthY * 2))))).
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3332
                    self redraw: (((origin x + extent x - lineWidthX)@(origin y + lineWidthY)) extent: (lineWidthX@(extent y - (lineWidthY * 2)))).
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3333
                    (self selectedColor ~= Color noColor)
5432
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
  3334
                        ifTrue: [gc paint: self selectedColor]
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
  3335
                        ifFalse: [gc paint: self viewBackground]. 
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3336
                    origin := (firstPoint min: currentPoint) + margin.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3337
                    extent := currentExtent - gridCorrection.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3338
                    lineWidthY := extent y min: magnification y.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3339
                    lineWidthX := extent x min: magnification x.
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3340
                    (lineWidthY > 0 and: [lineWidthX > 0]) ifTrue:[
5432
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
  3341
                        gc fillRectangle: (origin extent: (extent x@lineWidthY)).
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
  3342
                        gc fillRectangle: ((origin x@(origin y + extent y - lineWidthY)) extent: (extent x@lineWidthY)).
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
  3343
                        gc fillRectangle: ((origin x@(origin y + lineWidthY)) extent: (lineWidthX@(0 max: (extent y - (lineWidthY * 2))))).
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
  3344
                        gc fillRectangle: (((origin x + extent x - lineWidthX)@(origin y + lineWidthY)) extent: (lineWidthX@(extent y - (lineWidthY * 2)))).
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3345
                    ]
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3346
                ].
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3347
                
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3348
                emphasis == #filledBox ifTrue:[
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3349
                    self redraw: ((firstPoint min: lastCurrentPoint) - 1 extent: (firstPoint - lastCurrentPoint) abs + 2).
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3350
                    (self selectedColor ~= Color noColor)
5432
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
  3351
                        ifTrue: [gc paint: self selectedColor]
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
  3352
                        ifFalse: [gc paint: self viewBackground].
6f103b797668 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5418
diff changeset
  3353
                    gc fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection).
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3354
                ].
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3355
            ]. 
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3356
            lastCurrentPoint := currentPoint.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3357
        ].                  
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3358
    ].                  
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3359
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3360
    ^((0@0) max: (firstPoint min: currentPoint)) extent: (firstPoint - currentPoint) abs
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3361
5593
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
  3362
    "Created: / 21-08-1998 / 20:17:07 / cg"
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
  3363
    "Modified: / 10-10-2001 / 14:13:08 / cg"
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
  3364
    "Modified (format): / 04-09-2017 / 18:26:06 / cg"
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3365
!
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3366
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3367
drawCursorAt:aPoint
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3368
    "the mouse was moved to aPoint (in the image).
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3369
     Update the info (showing rgb + other info) in the lower info bar.
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3370
     Also changes the cursor to a stop-cursor, if outside the image"
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3371
     
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3372
    |imgPoint shownCursor|
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3373
4041
2d635ff57406 class definition
Claus Gittinger <cg@exept.de>
parents: 4032
diff changeset
  3374
    readOnly ifTrue:[^ self].
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3375
    image isNil ifTrue: [
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3376
        self updateImageInfo:(self imageInfoString). 
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3377
        self cursor:Cursor stop.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3378
        ^ self
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3379
    ].
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3380
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3381
    imgPoint := aPoint // magnification.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3382
    ((imgPoint x between:0 and:(image width-1)) 
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3383
      and:[imgPoint y between:0 and: (image height-1)]
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3384
    ) ifFalse:[
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3385
        self updateImageInfo:(self imageInfoString). 
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3386
        shownCursor := Cursor stop.
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3387
    ] ifTrue: [
3729
6f6cfc8bb8cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3706
diff changeset
  3388
        self updateImageInfoFor:imgPoint.
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3389
        shownCursor := Cursor crossHair
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3390
    ].
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3391
    self cursor:shownCursor.
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3392
4041
2d635ff57406 class definition
Claus Gittinger <cg@exept.de>
parents: 4032
diff changeset
  3393
    "Modified: / 03-05-2011 / 12:27:52 / cg"
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3394
    "Modified (format): / 16-02-2017 / 17:09:13 / cg"
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3395
!
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3396
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3397
imageInfoString
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3398
    image isNil ifTrue: [^ 'No image loaded.'].
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3399
    
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3400
    ^ String streamContents:[:s |
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3401
        |d|
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3402
        
5585
454a11130910 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5584
diff changeset
  3403
        s print:('%1x%2 | %3bit%4' 
454a11130910 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5584
diff changeset
  3404
            bindWith:image width    
454a11130910 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5584
diff changeset
  3405
            with:image height
454a11130910 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5584
diff changeset
  3406
            with:image depth
454a11130910 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5584
diff changeset
  3407
            with:(image mask notNil ifTrue: ['+mask'] ifFalse:[''])).
454a11130910 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5584
diff changeset
  3408
5588
f780d54d56ad #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5587
diff changeset
  3409
        image depth ~~ image bitsPerSample sum ifTrue:[
f780d54d56ad #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5587
diff changeset
  3410
            s print:' ('.    
6161
3353ad05fdb3 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 6160
diff changeset
  3411
            image bitsPerSample do:[:each | s print:each] separatedBy:[s print:'·'].   
5588
f780d54d56ad #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5587
diff changeset
  3412
            s print:')'.    
f780d54d56ad #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5587
diff changeset
  3413
        ].
f780d54d56ad #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5587
diff changeset
  3414
        
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3415
        d := image depth min:24.
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3416
        ' [%1/%2 colors]' expandPlaceholdersWith:{image nColorsUsed. (2 raisedTo:d)} on:s.
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3417
    ].
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3418
5588
f780d54d56ad #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5587
diff changeset
  3419
    "Modified: / 31-08-2017 / 18:15:40 / cg"
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3420
!
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3421
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3422
showCursorAt: aPoint andInformation: aLabel
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3423
    |shownCursor|
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3424
    
4041
2d635ff57406 class definition
Claus Gittinger <cg@exept.de>
parents: 4032
diff changeset
  3425
    readOnly ifTrue:[^ self].
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3426
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3427
    ((0@0 extent: image extent * magnification) containsPoint: aPoint)
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3428
         ifTrue: [ shownCursor := Cursor crossHair ]
5414
641d2f0d748c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  3429
         ifFalse:[ shownCursor := Cursor stop ].
5413
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3430
    self cursor:shownCursor. 
6211fc3b725a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5405
diff changeset
  3431
    self updateImageInfo: aLabel.
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3432
4041
2d635ff57406 class definition
Claus Gittinger <cg@exept.de>
parents: 4032
diff changeset
  3433
    "Modified: / 03-05-2011 / 12:28:15 / cg"
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3434
!
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3435
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3436
updateActivity: something
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3437
    |msg|
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3438
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3439
    msg := something printString.
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3440
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3441
    activityInfoHolder notNil ifTrue:[
3847
c09d45071125 comment/format in: #updateImageInfo:
Claus Gittinger <cg@exept.de>
parents: 3840
diff changeset
  3442
        activityInfoHolder value:msg.
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3443
    ].
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3444
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3445
    "Modified: / 29.7.1998 / 18:41:47 / cg"
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3446
!
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3447
5583
8bc04664882c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5582
diff changeset
  3448
updateImageInfo:someTextOrObject
5581
63e21f277747 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5579
diff changeset
  3449
    "show someText in the lower info area"
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3450
    
3847
c09d45071125 comment/format in: #updateImageInfo:
Claus Gittinger <cg@exept.de>
parents: 3840
diff changeset
  3451
    |msg|
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3452
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3453
    imageInfoHolder notNil ifTrue:[
5583
8bc04664882c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5582
diff changeset
  3454
        someTextOrObject isString ifTrue:[
8bc04664882c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5582
diff changeset
  3455
            msg := someTextOrObject
8bc04664882c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5582
diff changeset
  3456
        ] ifFalse:[    
8bc04664882c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5582
diff changeset
  3457
            msg := someTextOrObject printString.
8bc04664882c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5582
diff changeset
  3458
        ].
3847
c09d45071125 comment/format in: #updateImageInfo:
Claus Gittinger <cg@exept.de>
parents: 3840
diff changeset
  3459
        msg ~= imageInfoHolder value ifTrue:[
c09d45071125 comment/format in: #updateImageInfo:
Claus Gittinger <cg@exept.de>
parents: 3840
diff changeset
  3460
            imageInfoHolder value:msg.
c09d45071125 comment/format in: #updateImageInfo:
Claus Gittinger <cg@exept.de>
parents: 3840
diff changeset
  3461
        ].
c09d45071125 comment/format in: #updateImageInfo:
Claus Gittinger <cg@exept.de>
parents: 3840
diff changeset
  3462
        ^ self
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3463
    ].
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3464
5583
8bc04664882c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5582
diff changeset
  3465
    "Modified: / 29-08-2017 / 20:35:57 / cg"
3729
6f6cfc8bb8cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3706
diff changeset
  3466
!
6f6cfc8bb8cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3706
diff changeset
  3467
6f6cfc8bb8cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3706
diff changeset
  3468
updateImageInfoFor:aPoint
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3469
    "show info about the pixel at aPoint in the lower info area"
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3470
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3471
    |clr pixel r g b a m|
3729
6f6cfc8bb8cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3706
diff changeset
  3472
6f6cfc8bb8cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3706
diff changeset
  3473
    clr := image colorAt:aPoint.
6f6cfc8bb8cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3706
diff changeset
  3474
    pixel := image pixelAt:aPoint.
6f6cfc8bb8cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3706
diff changeset
  3475
6f6cfc8bb8cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3706
diff changeset
  3476
    r := clr redByte.
6f6cfc8bb8cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3706
diff changeset
  3477
    g := clr greenByte.
6f6cfc8bb8cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3706
diff changeset
  3478
    b := clr blueByte.
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3479
    image hasAlphaChannel ifTrue:[
5493
1840ba5cf10b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5492
diff changeset
  3480
        "/ sigh - must return a TranslucentColor from colorAt:
1840ba5cf10b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5492
diff changeset
  3481
        "/ until that is fixed, compute it here...
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3482
        "/ a := clr alphaByte.
5493
1840ba5cf10b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5492
diff changeset
  3483
        a := (pixel rightShift:(image alphaShiftForPixelValue)) bitAnd:(image alphaMaskForPixelValue).
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3484
    ] ifFalse:[
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3485
        image mask notNil ifTrue:[
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3486
            m := image mask pixelAt:aPoint.
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3487
        ].    
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3488
    ].
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3489
    
3729
6f6cfc8bb8cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3706
diff changeset
  3490
    self updateImageInfo:
5583
8bc04664882c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5582
diff changeset
  3491
        ('    ' asText backgroundColorizeAllWith:clr) 
8bc04664882c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5582
diff changeset
  3492
        ,  '  '  
8bc04664882c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5582
diff changeset
  3493
        , (String streamContents:[:s |
5582
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3494
            |redString greenString blueString greyString
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3495
             photometric bitsPerSample|
5581
63e21f277747 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5579
diff changeset
  3496
            
5582
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3497
            photometric := image photometric.
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3498
            bitsPerSample := image bitsPerSample.
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3499
3729
6f6cfc8bb8cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3706
diff changeset
  3500
            s print:aPoint.
5582
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3501
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3502
            ((photometric == #blackIs0) or:[(photometric == #whiteIs0)]) ifTrue:[
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3503
                s print:' (g:'; print:pixel.
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3504
                greyString := (pixel hexPrintString:2).
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3505
            ] ifFalse:[
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3506
                s print:' (r:'; print:r.
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3507
                s print:' g:'; print:g.
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3508
                s print:' b:'; print:b.
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3509
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3510
                redString := (r hexPrintString:2).
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3511
                greenString := (g hexPrintString:2).
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3512
                blueString := (b hexPrintString:2).
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3513
           ].
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3514
            a notNil ifTrue:[
3729
6f6cfc8bb8cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3706
diff changeset
  3515
                s print:' a:'; print:a.
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3516
            ] ifFalse:[
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3517
                m notNil ifTrue:[
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3518
                    s print:' m:'; print:m.
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3519
                ].    
5581
63e21f277747 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5579
diff changeset
  3520
            ].
63e21f277747 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5579
diff changeset
  3521
            
5582
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3522
            ((photometric == #blackIs0) or:[(photometric == #whiteIs0)]) ifTrue:[
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3523
                (bitsPerSample at:1) == 16 ifTrue:[
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3524
                    greyString := (pixel hexPrintString:4)
5581
63e21f277747 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5579
diff changeset
  3525
                ].
5582
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3526
                s print:(' #%1' bindWith:greyString).
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3527
            ] ifFalse:[
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3528
                ((photometric == #rgb) or:[(photometric == #rgba)]) ifTrue:[
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3529
                    (bitsPerSample at:1) == 16 ifTrue:[
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3530
                        redString := (r hexPrintString:4)
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3531
                    ].
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3532
                    (bitsPerSample at:2) == 16 ifTrue:[
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3533
                        greenString := (g hexPrintString:4)
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3534
                    ].
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3535
                    (bitsPerSample at:2) == 16 ifTrue:[
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3536
                        blueString := (b hexPrintString:4)
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3537
                    ].
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3538
                ]. 
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3539
                s print:(' #%1.%2.%3' bindWith:redString with:greenString with:blueString).
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3540
            ].            
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3541
            a notNil ifTrue:[
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3542
                s print:'.'; print:(a hexPrintString:2)
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3543
            ].    
5582
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3544
d88b01c6608b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3545
            photometric == #palette ifTrue:[
5581
63e21f277747 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5579
diff changeset
  3546
                s print:' pixel index:'; print:pixel.
3729
6f6cfc8bb8cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3706
diff changeset
  3547
            ].
6f6cfc8bb8cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3706
diff changeset
  3548
            s print:')'.
6f6cfc8bb8cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3706
diff changeset
  3549
        ])
5481
3ed986b5812d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5480
diff changeset
  3550
5583
8bc04664882c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5582
diff changeset
  3551
    "Modified: / 29-08-2017 / 20:39:26 / cg"
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3552
! !
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2508
diff changeset
  3553
2818
d255fb7d54fc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  3554
!ImageEditView methodsFor:'initialization & release'!
1327
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1277
diff changeset
  3555
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1277
diff changeset
  3556
destroy
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  3557
    ClipboardImageMagnified := ClipboardImage := nil.
1327
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1277
diff changeset
  3558
    LastMagnification      := magnification.
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1277
diff changeset
  3559
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1277
diff changeset
  3560
    super destroy
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  3561
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  3562
    "Modified: / 08-10-2017 / 08:54:36 / cg"
1327
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1277
diff changeset
  3563
!
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  3564
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  3565
initialize
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  3566
    super initialize.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  3567
4041
2d635ff57406 class definition
Claus Gittinger <cg@exept.de>
parents: 4032
diff changeset
  3568
    readOnly := false.
2d635ff57406 class definition
Claus Gittinger <cg@exept.de>
parents: 4032
diff changeset
  3569
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  3570
    self enableMotionEvents.
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  3571
1374
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  3572
    undoImages        := List new: MaxUndos.
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3573
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  3574
    magnification     := LastMagnification ? (8@8).
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2690
diff changeset
  3575
    modifiedHolder    := false asValue.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  3576
    mouseKeyColorMode := 1.
2908
a759fa87d598 some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  3577
    resourceClass     := resourceSelector := nil.
5499
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  3578
    drawingColorHolders isNil ifTrue:[
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  3579
        drawingColorHolders := Array with:(nil asValue) with:(nil asValue).   "/ left/right mouse colors
8c729d93a77c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5497
diff changeset
  3580
    ].
2009
4f556ff9fec5 pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents: 2007
diff changeset
  3581
    drawingPixelHolders := Array with:(nil asValue) with:(nil asValue).   "/ left/right mouse colors
4111
Claus Gittinger <cg@exept.de>
parents: 4041
diff changeset
  3582
5593
97051e4f73d4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5591
diff changeset
  3583
    drawingAlpha isNil ifTrue:[ drawingAlpha := 100 ].
4111
Claus Gittinger <cg@exept.de>
parents: 4041
diff changeset
  3584
    spraySpot := 8.
Claus Gittinger <cg@exept.de>
parents: 4041
diff changeset
  3585
    penWidth := 1.
5483
87e33f13ffe2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5481
diff changeset
  3586
    floodFillMaxHueError := floodFillMaxLightError := 0.
5484
6b12e0653062 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5483
diff changeset
  3587
    userAllowedToChangeDrawingColor := true.
5483
87e33f13ffe2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5481
diff changeset
  3588
    
2889
69423b4e0cee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2843
diff changeset
  3589
    self editMode:EditModePoint.
4041
2d635ff57406 class definition
Claus Gittinger <cg@exept.de>
parents: 4032
diff changeset
  3590
5594
26e8562cdf99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  3591
    "Modified: / 05-09-2017 / 10:47:11 / cg"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  3592
! !
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  3593
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3594
!ImageEditView methodsFor:'loading & saving'!
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  3595
1994
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3596
askForFileNameToSave:msg
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3597
    "ask for a fileName"
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3598
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3599
    |lastFn fn filters|
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3600
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3601
    filters := FileSelectionBrowser saveImageFileNameFilters.
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3602
    lastFn := self image fileName.
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3603
    lastFn isNil ifTrue:[
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3604
        fn := FileSelectionBrowser
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3605
                request: msg
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3606
                inDirectory: LastSaveDirectory
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3607
                withFileFilters: filters
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3608
    ] ifFalse:[
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3609
        fn := FileSelectionBrowser
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3610
                request: msg
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3611
                fileName: lastFn
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3612
                withFileFilters: filters
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3613
    ].
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3614
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3615
    ^ fn
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3616
!
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3617
724
d6f4b89940ed undo disabling
tz
parents: 704
diff changeset
  3618
loadFromClass
5701
27382b38a961 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5697
diff changeset
  3619
    |brwsr classAndSelector|
27382b38a961 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5697
diff changeset
  3620
27382b38a961 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5697
diff changeset
  3621
    brwsr := ResourceSelectionBrowser
27382b38a961 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5697
diff changeset
  3622
            title: 'Load Image From Class'
1184
58e399d8c312 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
  3623
            onSuperclass: nil
5701
27382b38a961 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5697
diff changeset
  3624
            andClass:(self resourceClass) andSelector:(self resourceSelector)
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3625
            withResourceTypes: #(image fileImage programImage).
5701
27382b38a961 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5697
diff changeset
  3626
    brwsr existingOnly:true.
27382b38a961 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5697
diff changeset
  3627
    classAndSelector := brwsr openAndLetUserChoose.
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3628
    classAndSelector notNil ifTrue:[
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3629
        self loadFromClass:(classAndSelector methodClass) andSelector:(classAndSelector methodSelector) 
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3630
    ].
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  3631
!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  3632
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3633
loadFromClass:aClassOrClassName andSelector: aStringOrSymbol
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3634
    "support for names will vanish - obsolete left over from tz"
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3635
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3636
    imageReaderClass := nil.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3637
    self resourceClass: aClassOrClassName.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3638
    self resourceSelector: aStringOrSymbol.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3639
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3640
    resourceClass isBehavior ifFalse:[^ nil].
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3641
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3642
    (resourceClass respondsTo:resourceSelector) ifTrue:[ 
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3643
        image := resourceClass perform:resourceSelector.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3644
    ].
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3645
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3646
    image isNil ifTrue:[^ nil].
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3647
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3648
    image := image copy.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3649
    self releaseUndos.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3650
    self image:image.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3651
    self clearModified.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3652
    ^ image
2556
fc4dd338dee5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2555
diff changeset
  3653
!
fc4dd338dee5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2555
diff changeset
  3654
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3655
loadFromFile: aFileName
5510
df62793ca7bb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5506
diff changeset
  3656
    ^ self loadFromFile:aFileName readerClass:nil
df62793ca7bb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5506
diff changeset
  3657
df62793ca7bb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5506
diff changeset
  3658
    "Modified: / 07-03-2017 / 17:43:07 / cg"
df62793ca7bb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5506
diff changeset
  3659
!
df62793ca7bb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5506
diff changeset
  3660
df62793ca7bb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5506
diff changeset
  3661
loadFromFile:aFileName readerClass:imageReaderClassOrNil
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3662
    |imageFromFile|
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3663
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3664
    aFileName isNil ifTrue: [^nil].
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3665
5029
5f1d1837cbdf #DOCUMENTATION by mawalch
mawalch
parents: 4999
diff changeset
  3666
    Error handle:[:exception|
5f1d1837cbdf #DOCUMENTATION by mawalch
mawalch
parents: 4999
diff changeset
  3667
        self warn: exception errorString.
4351
858c0249bb5a class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4264
diff changeset
  3668
        ^ nil
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3669
    ] do:[ 
4351
858c0249bb5a class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4264
diff changeset
  3670
        (imageFromFile := Image fromFile: aFileName) isNil ifTrue:[
5510
df62793ca7bb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5506
diff changeset
  3671
            imageFromFile := (imageReaderClassOrNil ? JPEGReader) fromFile:aFileName
4351
858c0249bb5a class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4264
diff changeset
  3672
        ].
858c0249bb5a class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4264
diff changeset
  3673
        imageFromFile notNil ifTrue:[
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3674
            self releaseUndos.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3675
            self image: imageFromFile. 
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3676
            self clearModified.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3677
"/            imageReaderClass := ImageReader allSubclasses
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3678
"/                detect: [:cls| cls isValidImageFile: aFileName asFilename pathName]
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3679
"/                ifNone: [self error: 'Unknown image file format!!']
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3680
        ] ifFalse:[
4965
0f28ee36ec03 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
  3681
            aFileName asFilename isReadable ifTrue:[
0f28ee36ec03 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
  3682
                self error: 'Not an image file (or unrecognized format)'
0f28ee36ec03 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
  3683
            ] ifFalse:[  
0f28ee36ec03 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
  3684
                self error: 'File does not exist or is unreadable'
0f28ee36ec03 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
  3685
            ]
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3686
        ]
2555
43af374dfd5e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
  3687
    ].
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3688
    ^ imageFromFile
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3689
5510
df62793ca7bb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5506
diff changeset
  3690
    "Created: / 07-03-2017 / 17:42:37 / cg"
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3691
!
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3692
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3693
loadFromMessage:classAndSelector
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3694
    "switch to the class and selector specified by classAndSelector."
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3695
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3696
    ^ self loadFromClass:(classAndSelector methodClass) andSelector:(classAndSelector methodSelector)
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3697
!
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3698
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3699
loadfromClass:aClassOrSymbol andSelector: aStringOrSymbol
3643
b38da5f45af6 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3610
diff changeset
  3700
    <resource: #obsolete>
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3701
    self obsoleteMethodWarning.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3702
    ^ self loadFromClass:aClassOrSymbol andSelector: aStringOrSymbol
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  3703
!
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  3704
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  3705
save
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  3706
    self saveImageOrMask: #image.
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  3707
!
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  3708
2239
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3709
save:image imageOrMask:what
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3710
    "save the image or the mask only (if what == #mask)"
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
  3711
2239
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3712
    image isNil ifTrue:[
4249
fc26253d9d4b class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4233
diff changeset
  3713
        Dialog warn:(resources string:'No image to save!!').
2239
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3714
        ^ self.
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3715
    ].
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3716
    self save:image imageOrMask:what as:image fileName.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  3717
!
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
  3718
2239
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3719
save:image imageOrMask:what as:fileNameArg
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  3720
    "save the image or the mask only (if what == #mask)"
628
7f36d8a7735f popup menu starts image editor
tz
parents: 627
diff changeset
  3721
2240
2e9ad39f11c8 checkin from browser
ca
parents: 2239
diff changeset
  3722
    |fileName fileNameString|
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  3723
2239
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3724
    fileName := fileNameArg asFilename.
2783
ca5705f5c258 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2775
diff changeset
  3725
    LastSaveDirectory := fileName directoryName.
2239
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3726
4203
a257aa6878ac class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4149
diff changeset
  3727
    Error handle:[:ex|
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  3728
        |msg|
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  3729
4203
a257aa6878ac class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4149
diff changeset
  3730
        ex creator == Image fileCreationErrorSignal ifTrue:[
1896
0f430b35c451 asText allBold -> allBold
Claus Gittinger <cg@exept.de>
parents: 1888
diff changeset
  3731
            msg := resources string:'Cannot create file: ''%1''' with:fileName asFilename pathName allBold
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  3732
        ] ifFalse:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  3733
            msg := ex errorString.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  3734
        ].
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  3735
        Dialog warn:msg.
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  3736
    ] do:[   
5600
eb6048aada56 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5594
diff changeset
  3737
        Image informationLostQuerySignal handle:[:ex |
eb6048aada56 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5594
diff changeset
  3738
            |question|
eb6048aada56 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5594
diff changeset
  3739
eb6048aada56 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5594
diff changeset
  3740
            question := '\\Save anyway ?'.
eb6048aada56 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5594
diff changeset
  3741
            ex creator == Image noMaskButAlphaSupportedQuerySignal ifTrue:[
eb6048aada56 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5594
diff changeset
  3742
                question := '\\Convert and save with alpha channel ?'.
eb6048aada56 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5594
diff changeset
  3743
            ].
eb6048aada56 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5594
diff changeset
  3744
            (self confirm:(ex errorString , question) withCRs) ifTrue:[
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  3745
                ex proceed.
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  3746
            ]
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  3747
        ] do:[   
4137
1a5fdfd6cd4f withWriteCursorDo
Claus Gittinger <cg@exept.de>
parents: 4129
diff changeset
  3748
            windowGroup withWriteCursorDo:[
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  3749
                |suff fn|
1027
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  3750
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  3751
                image isNil ifTrue:[
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  3752
                    ^ self error: 'No image to save!!'
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  3753
                ].
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  3754
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  3755
                what = #mask ifTrue:[   
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  3756
                    image mask isNil ifTrue: [^self error: 'No image mask to save!!'].
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  3757
                ].
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  3758
6135
87343bbd72b1 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 6084
diff changeset
  3759
                fileName name size == 0 ifTrue: [^self error: 'No file name detected!!'].
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  3760
                suff := fileName suffix asLowercase.
1373
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  3761
                imageReaderClass := nil.
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  3762
                imageReaderClass := MIMETypes imageReaderForSuffix:suff.
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  3763
1373
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  3764
                imageReaderClass isNil ifTrue: [
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  3765
                    imageReaderClass := XPMReader. 
2589
10827ba87692 obsolete method calls cleaned up
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
  3766
                    fileNameString := fileName name , '.xpm'.
2240
2e9ad39f11c8 checkin from browser
ca
parents: 2239
diff changeset
  3767
                    fileName := fileNameString asFilename.
2e9ad39f11c8 checkin from browser
ca
parents: 2239
diff changeset
  3768
                    image fileName:fileNameString.
6084
5ecaeb8b7e5f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6081
diff changeset
  3769
                    Dialog warn:'Don''t know how to write ".%1"-files\\Saving in xpm format as "%2".' withCRs 
5ecaeb8b7e5f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6081
diff changeset
  3770
                           with:suff
5ecaeb8b7e5f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6081
diff changeset
  3771
                           with:fileNameString allBold.
1373
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  3772
                ].
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  3773
                (imageReaderClass canRepresent:image) ifFalse:[
1991
fff8dc641cff *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  3774
                    imageReaderClass == XPMReader ifTrue:[
6084
5ecaeb8b7e5f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6081
diff changeset
  3775
                        Dialog warn:'Saving in ".%1"-format is not supported (or image cannot be represented in this format).\\Please try another format.' withCRs
5ecaeb8b7e5f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6081
diff changeset
  3776
                               with:suff.
1991
fff8dc641cff *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  3777
                        ^ self.
fff8dc641cff *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  3778
                    ].
1373
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  3779
                    imageReaderClass := XPMReader. 
2589
10827ba87692 obsolete method calls cleaned up
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
  3780
                    fileNameString := fileName name , '.xpm'.
2240
2e9ad39f11c8 checkin from browser
ca
parents: 2239
diff changeset
  3781
                    fileName := fileNameString asFilename.
2e9ad39f11c8 checkin from browser
ca
parents: 2239
diff changeset
  3782
                    image fileName:fileNameString.
2690
53bc9dc52ce4 allow cancel when saving in wrong format
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
  3783
                    (Dialog confirm:(('Saving in ''.' , suff , '''-format is not supported (or image cannot be represented in this format).\\Saving in xpm format as ''%1''.') 
53bc9dc52ce4 allow cancel when saving in wrong format
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
  3784
                                withCRs bindWith:fileNameString allBold)) ifFalse:[
53bc9dc52ce4 allow cancel when saving in wrong format
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
  3785
                        ^ self.
53bc9dc52ce4 allow cancel when saving in wrong format
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
  3786
                    ].
1373
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  3787
                ].
2240
2e9ad39f11c8 checkin from browser
ca
parents: 2239
diff changeset
  3788
                Transcript showCR:('saving as:' , fileName pathName).
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  3789
2824
dcff817ccd59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2823
diff changeset
  3790
                what = #image ifTrue: [ 
dcff817ccd59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2823
diff changeset
  3791
                    image saveOn:fileName using: imageReaderClass. self clearModified.
dcff817ccd59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2823
diff changeset
  3792
                    image fileName:fileNameString.
dcff817ccd59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2823
diff changeset
  3793
                ].
dcff817ccd59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2823
diff changeset
  3794
                what = #mask ifTrue: [
dcff817ccd59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2823
diff changeset
  3795
                    image mask saveOn:fileName using: imageReaderClass
dcff817ccd59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2823
diff changeset
  3796
                ].
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  3797
2240
2e9ad39f11c8 checkin from browser
ca
parents: 2239
diff changeset
  3798
                fileName exists ifFalse:[
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  3799
                    Dialog warn:'Oops image save failed.'
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  3800
                ]
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  3801
            ]   
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  3802
        ]
1027
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  3803
    ]
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  3804
5600
eb6048aada56 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5594
diff changeset
  3805
    "Modified: / 13-09-2017 / 09:49:46 / cg"
6084
5ecaeb8b7e5f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6081
diff changeset
  3806
    "Modified: / 10-07-2019 / 18:30:12 / Claus Gittinger"
633
594edef86630 revised version
tz
parents: 632
diff changeset
  3807
!
594edef86630 revised version
tz
parents: 632
diff changeset
  3808
2239
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3809
saveAs
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3810
    self saveImageFileAs
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3811
!
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3812
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3813
saveButtonImageToFileAs
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3814
    |fn|
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3815
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3816
    fn := self askForFileNameToSave:'Save Button Image to File'.
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3817
    self saveButtonImageToFileAs:fn
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3818
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3819
    "Modified: / 30.9.1998 / 23:04:11 / cg"
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3820
!
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3821
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3822
saveButtonImageToFileAs: aFileName
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3823
    "save the image as if in a button in aFileName"
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3824
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3825
    |button grabbedImage|
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3826
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3827
    aFileName isNil ifTrue: [^nil].
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3828
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3829
    image isNil ifTrue:[
4249
fc26253d9d4b class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4233
diff changeset
  3830
        self warn:(resources string:'No image or image mask to save!!').
2239
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3831
        ^ self.
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3832
    ].
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3833
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3834
    button := Button label:image.
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3835
    button openAt:5@5.
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3836
    button waitUntilVisible.
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3837
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3838
    grabbedImage := Image fromView:button.
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3839
    button destroy.
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3840
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3841
    self save:grabbedImage imageOrMask:#image as:aFileName
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3842
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3843
    "/ self saveImageOrMask: #mask
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3844
!
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3845
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3846
saveImageFileAs
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3847
    "ask for a fileName and save the image"
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3848
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3849
    |fn|
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3850
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3851
    fn := self askForFileNameToSave:'Save Image To File'.
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3852
    self saveImageFileAs:fn
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3853
!
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3854
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3855
saveImageFileAs: aFileName
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3856
    "save the image in aFileName"
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3857
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3858
    aFileName isNil ifTrue: [^nil].
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3859
    image notNil ifTrue:[
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3860
        self save:image imageOrMask:#image as:aFileName.
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3861
    ] ifFalse:[
4249
fc26253d9d4b class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4233
diff changeset
  3862
        self warn:(resources string:'No image for saving!!')
2239
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3863
    ]
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3864
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3865
    "Modified: / 30.9.1998 / 23:04:55 / cg"
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3866
!
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3867
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3868
saveImageMaskFileAs
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3869
    "ask for a fileName and save the mask only"
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3870
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3871
    |fn|
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3872
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3873
    fn := self askForFileNameToSave:'Save Image Mask To File'.
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3874
    self saveImageMaskFileAs:fn
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3875
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3876
    "Modified: / 30.9.1998 / 23:04:11 / cg"
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3877
!
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3878
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3879
saveImageMaskFileAs: aFileName
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3880
    "save the mask only in aFileName"
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3881
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3882
    aFileName isNil ifTrue: [^nil].
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3883
    (image notNil and:[image mask notNil]) ifTrue:[
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3884
        self save:image imageOrMask:#mask as:aFileName.
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3885
    ] ifFalse:[
4249
fc26253d9d4b class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4233
diff changeset
  3886
        self warn:(resources string:'No image or image mask to save!!')
2239
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3887
    ]
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3888
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3889
    "Modified: / 30.9.1998 / 23:06:24 / cg"
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3890
!
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3891
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3892
saveImageOrMask:what
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3893
    "save the image or the mask only (if what == #mask)"
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3894
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3895
    self save:image imageOrMask: what
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3896
!
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  3897
633
594edef86630 revised version
tz
parents: 632
diff changeset
  3898
saveMethod
5364
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3899
    "save the image as a resource method.
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3900
     Return true if ok; false if not"
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3901
4149
758a4573b5e4 changed: #saveMethod
Claus Gittinger <cg@exept.de>
parents: 4137
diff changeset
  3902
    (resourceSelector trimBlanks notEmptyOrNil and:[ resourceClass isBehavior ]) ifFalse: [
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3903
        ^ self saveMethodAs.
2914
fdf78bbdbd46 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
  3904
    ].
fdf78bbdbd46 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
  3905
fdf78bbdbd46 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
  3906
    windowGroup withExecuteCursorDo:[
3859
56eadb83df83 changed: #saveMethod
Claus Gittinger <cg@exept.de>
parents: 3847
diff changeset
  3907
        Error handle:[:ex|
56eadb83df83 changed: #saveMethod
Claus Gittinger <cg@exept.de>
parents: 3847
diff changeset
  3908
            (self confirm:(ex errorString,'\\Debug?' withCRs)) ifTrue:[ ex reject ].
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3909
            ^ false                                 
2914
fdf78bbdbd46 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
  3910
        ] do: [   
5286
23ec6e6fd179 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5277
diff changeset
  3911
            |img imageSaved depth bestDepth colorsUsed numColorsUsed category imageStoreStream sel mthd imageKey|
4149
758a4573b5e4 changed: #saveMethod
Claus Gittinger <cg@exept.de>
parents: 4137
diff changeset
  3912
758a4573b5e4 changed: #saveMethod
Claus Gittinger <cg@exept.de>
parents: 4137
diff changeset
  3913
            img := self image.
4714
69df9f744066 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  3914
            depth := bestDepth := img depth.
69df9f744066 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  3915
            colorsUsed := (img usedColorsMax:256).
69df9f744066 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  3916
            colorsUsed notNil ifTrue:[
69df9f744066 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  3917
                numColorsUsed := colorsUsed size.
69df9f744066 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  3918
                #(8 4 2 1) do:[:d |
69df9f744066 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  3919
                    depth > d ifTrue:[
69df9f744066 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  3920
                        numColorsUsed <= (1 << d) ifTrue:[
69df9f744066 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  3921
                            bestDepth := d
69df9f744066 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  3922
                        ]
4149
758a4573b5e4 changed: #saveMethod
Claus Gittinger <cg@exept.de>
parents: 4137
diff changeset
  3923
                    ]
4714
69df9f744066 class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  3924
                ].
4149
758a4573b5e4 changed: #saveMethod
Claus Gittinger <cg@exept.de>
parents: 4137
diff changeset
  3925
            ].
5286
23ec6e6fd179 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5277
diff changeset
  3926
            imageSaved := img.
5656
5e333f0a3b98 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5655
diff changeset
  3927
            (image hasAlphaChannel not and:[ bestDepth < depth ]) ifTrue:[
5286
23ec6e6fd179 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5277
diff changeset
  3928
                |answer|
23ec6e6fd179 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5277
diff changeset
  3929
                
23ec6e6fd179 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5277
diff changeset
  3930
                answer := Dialog 
23ec6e6fd179 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5277
diff changeset
  3931
                    confirmWithCancel:(resources stringWithCRs:'Hint:\\You can save some code space, by converting the image from a depth-%1 to a depth-%2 image first.\(only %3 colors used)\\Convert before saving?'
23ec6e6fd179 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5277
diff changeset
  3932
                                 with:depth with:bestDepth with:numColorsUsed).
23ec6e6fd179 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5277
diff changeset
  3933
                answer isNil ifTrue:[
5579
d1f709b27486 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5531
diff changeset
  3934
                    "/ canceled
4149
758a4573b5e4 changed: #saveMethod
Claus Gittinger <cg@exept.de>
parents: 4137
diff changeset
  3935
                    ^ false
5286
23ec6e6fd179 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5277
diff changeset
  3936
                ].
23ec6e6fd179 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5277
diff changeset
  3937
                answer == true ifTrue:[
23ec6e6fd179 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5277
diff changeset
  3938
                    imageSaved := (Image implementorForDepth:bestDepth) fromImage:imageSaved 
23ec6e6fd179 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5277
diff changeset
  3939
                ].    
4149
758a4573b5e4 changed: #saveMethod
Claus Gittinger <cg@exept.de>
parents: 4137
diff changeset
  3940
            ].
822
cace81f0a86b do not overwrite method categories + toggle between mouse button colors
tz
parents: 796
diff changeset
  3941
4000
21106540ffb5 CodeGeneratorTool->SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 3980
diff changeset
  3942
            SmalltalkCodeGeneratorTool
5286
23ec6e6fd179 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5277
diff changeset
  3943
                createImageSpecMethodFor:imageSaved
1882
fbb4a3a869f1 made image-method generator a class method (for reusability)
martin
parents: 1875
diff changeset
  3944
                comment:(ResourceSpecEditor codeGenerationCommentForClass: ImageEditor) 
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3945
                in:resourceClass class
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3946
                selector:resourceSelector.
822
cace81f0a86b do not overwrite method categories + toggle between mouse button colors
tz
parents: 796
diff changeset
  3947
5364
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3948
            "/ flush cached images in the Icon class (kludge)
1901
b4b286ec221f flush cached icons, when defining a new image-method
Claus Gittinger <cg@exept.de>
parents: 1896
diff changeset
  3949
            Icon flushCachedIcons.
2590
b811d560e00a modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  3950
            self clearModified.
1901
b4b286ec221f flush cached icons, when defining a new image-method
Claus Gittinger <cg@exept.de>
parents: 1896
diff changeset
  3951
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3952
            LastSaveClass := resourceClass.
1882
fbb4a3a869f1 made image-method generator a class method (for reusability)
martin
parents: 1875
diff changeset
  3953
        ]
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3954
    ].
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3955
    ^ true
1027
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  3956
4000
21106540ffb5 CodeGeneratorTool->SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 3980
diff changeset
  3957
    "Modified: / 31-01-2011 / 18:28:06 / cg"
5579
d1f709b27486 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5531
diff changeset
  3958
    "Modified (format): / 24-08-2017 / 15:02:51 / cg"
633
594edef86630 revised version
tz
parents: 632
diff changeset
  3959
!
594edef86630 revised version
tz
parents: 632
diff changeset
  3960
594edef86630 revised version
tz
parents: 632
diff changeset
  3961
saveMethodAs
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3962
    "ask for method/selector; save the image there.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3963
     Return true if saved, false if not"
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3964
5364
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3965
    |className classAndSelector
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3966
     previousClass previousCategory previousSelector
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3967
     previousMethod newMethod ok|
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3968
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3969
    previousSelector := self resourceSelector.
2908
a759fa87d598 some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  3970
    className := self resourceClassName.
a759fa87d598 some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
  3971
    className isEmptyOrNil ifTrue:[
2177
340ce04ccc78 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2172
diff changeset
  3972
        className := LastSaveClass
1994
d2d9228d38ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  3973
    ].
5364
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3974
    (className notEmptyOrNil and:[previousSelector notNil]) ifTrue:[
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3975
        previousClass := Smalltalk classNamed:className.
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3976
        previousClass notNil ifTrue:[
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3977
            previousMethod := previousClass class compiledMethodAt:previousSelector.
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3978
            previousMethod notNil ifTrue:[
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3979
                previousCategory := previousMethod category.
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3980
            ]
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3981
        ]
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3982
    ].
633
594edef86630 revised version
tz
parents: 632
diff changeset
  3983
3840
1ec52651a398 changed: #saveMethodAs
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  3984
    self withWaitCursorDo:[
1ec52651a398 changed: #saveMethodAs
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  3985
        classAndSelector := ResourceSelectionBrowser
1ec52651a398 changed: #saveMethodAs
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  3986
                request: 'Save Image In Class'
1ec52651a398 changed: #saveMethodAs
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  3987
                onSuperclass: #Object
1ec52651a398 changed: #saveMethodAs
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  3988
                andClass: className
1ec52651a398 changed: #saveMethodAs
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  3989
                andSelector: self resourceSelector
1ec52651a398 changed: #saveMethodAs
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  3990
                withResourceTypes: #(image fileImage programImage).
1ec52651a398 changed: #saveMethodAs
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  3991
    ].
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3992
    classAndSelector isNil ifTrue:[^ false].
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3993
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3994
    resourceClass := classAndSelector methodClass.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3995
    resourceSelector := classAndSelector methodSelector.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  3996
5364
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3997
    ok := self saveMethod.
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3998
    ok ifTrue:[
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  3999
        previousCategory notNil ifTrue:[
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  4000
            newMethod := resourceClass class compiledMethodAt:resourceSelector asSymbol.
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  4001
            newMethod notNil ifTrue:[
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  4002
                newMethod category:previousCategory.
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  4003
            ]
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  4004
        ]
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  4005
    ].
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  4006
    ^ ok
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  4007
bd510ef455fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5332
diff changeset
  4008
    "Modified: / 25-11-2016 / 09:17:22 / cg"
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4009
! !
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4010
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4011
!ImageEditView methodsFor:'printing'!
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4012
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4013
print
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4014
    self printWithMagnification:1
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4015
!
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4016
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4017
printMagnified
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4018
    self printWithMagnification:magnification
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4019
!
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4020
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4021
printWithMagnification:magnification
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4022
    |stream|
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4023
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4024
    image isNil ifTrue:[^ self].
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4025
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4026
    Printer supportsPostscript ifFalse:[
4249
fc26253d9d4b class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4233
diff changeset
  4027
        ^ self warn:(resources string:'No postscript printer configured !!')
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4028
    ].
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4029
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4030
    stream := Printer newNative.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4031
    stream isNil ifTrue:[
4249
fc26253d9d4b class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4233
diff changeset
  4032
        ^ self warn:(resources string:'Cannot open printer stream !!')
2915
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4033
    ].
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4034
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4035
    self withWaitCursorDo:[
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4036
        |psgc|
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4037
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4038
        psgc := PSGraphicsContext on:stream.  
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4039
        psgc displayForm: (image magnifiedBy: magnification) x:0 y:0.
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4040
        psgc close
6f4e171a1092 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2914
diff changeset
  4041
    ]
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  4042
! !
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  4043
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  4044
!ImageEditView methodsFor:'queries'!
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
  4045
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  4046
heightOfContents
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  4047
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  4048
    image isNil ifTrue:[^0].
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  4049
    ^(image height * magnification y) rounded
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
  4050
!
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
  4051
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  4052
imageContainsPastePoint: aPoint
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  4053
    ^image notNil 
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  4054
    and: [ ClipboardImage notNil 
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  4055
    and: [ (0@0 corner:(image extent) "- 1" - ClipboardImage extent) 
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  4056
                containsPoint: (((aPoint - margin + 1) / magnification) floor)
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  4057
    ]]
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  4058
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  4059
    "Modified (format): / 08-10-2017 / 08:53:18 / cg"
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  4060
!
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  4061
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  4062
imageContainsPoint: aPoint
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  4063
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  4064
    ^image notNil and:
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  4065
	[((0@0 corner:(image extent) - 1) containsPoint: (((aPoint - margin + 1) / magnification) floor))]
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  4066
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  4067
5752
f2c0cd4368c7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5701
diff changeset
  4068
selfIsNotImageEditor
f2c0cd4368c7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5701
diff changeset
  4069
    ^ false
f2c0cd4368c7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5701
diff changeset
  4070
!
f2c0cd4368c7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5701
diff changeset
  4071
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  4072
widthOfContents
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
  4073
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  4074
    image isNil ifTrue:[^0].
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  4075
    ^(image width * magnification x) rounded
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
  4076
! !
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
  4077
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  4078
!ImageEditView methodsFor:'release'!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  4079
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  4080
releasePasteDrawing
2085
4cf52f994f0a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  4081
    self repairDamage.
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  4082
    (lastPastePoint notNil and: [ClipboardImageMagnified notNil]) 
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2690
diff changeset
  4083
    ifTrue: [ 
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  4084
        self redraw: ((lastPastePoint"-self viewOrigin") extent: (ClipboardImageMagnified extent)). 
2085
4cf52f994f0a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  4085
        "/ self repairDamage.
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  4086
    ].
5618
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  4087
    lastPastePoint := ClipboardImageMagnified := nil
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  4088
fd26b56cfc91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5604
diff changeset
  4089
    "Modified: / 08-10-2017 / 08:55:06 / cg"
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  4090
!
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  4091
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  4092
releaseUndos
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  4093
    undoImages removeAll.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  4094
! !
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  4095
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  4096
!ImageEditView methodsFor:'testing'!
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  4097
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  4098
checkModified
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2690
diff changeset
  4099
    modifiedHolder value ifTrue:[
2634
dc5098a445d4 resources
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
  4100
        ((YesNoBox title:(resources string:'Image was not saved. Exit anyway ?'))
2591
87cab7199c7e Use 'Discard Changes and Exit' instead of 'Forget it...'
Stefan Vogel <sv@exept.de>
parents: 2590
diff changeset
  4101
            noText:(resources string:'Cancel');
2634
dc5098a445d4 resources
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
  4102
            yesText:(resources string:'Exit without Saving');
2591
87cab7199c7e Use 'Discard Changes and Exit' instead of 'Forget it...'
Stefan Vogel <sv@exept.de>
parents: 2590
diff changeset
  4103
            showAtPointer;
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2690
diff changeset
  4104
            accepted
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2690
diff changeset
  4105
        ) ifFalse: [^false].
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2690
diff changeset
  4106
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2690
diff changeset
  4107
        self modified:false.
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  4108
    ].
2591
87cab7199c7e Use 'Discard Changes and Exit' instead of 'Forget it...'
Stefan Vogel <sv@exept.de>
parents: 2590
diff changeset
  4109
    ^ true
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4110
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4111
    "Modified: / 29.7.1998 / 18:55:24 / cg"
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  4112
! !
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  4113
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
  4114
!ImageEditView class methodsFor:'documentation'!
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  4115
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  4116
version
4853
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
  4117
    ^ '$Header$'
3762
1baf6a044dd2 changed: #pasteAt:mode:
Claus Gittinger <cg@exept.de>
parents: 3730
diff changeset
  4118
!
1baf6a044dd2 changed: #pasteAt:mode:
Claus Gittinger <cg@exept.de>
parents: 3730
diff changeset
  4119
1baf6a044dd2 changed: #pasteAt:mode:
Claus Gittinger <cg@exept.de>
parents: 3730
diff changeset
  4120
version_CVS
4853
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
  4121
    ^ '$Header$'
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  4122
! !
2239
d2f65f84f314 saveAsButtonImage added
ca
parents: 2177
diff changeset
  4123
4203
a257aa6878ac class: ImageEditView
Claus Gittinger <cg@exept.de>
parents: 4149
diff changeset
  4124
1245
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
  4125
ImageEditView initialize!