ImageEditView.st
author Claus Gittinger <cg@exept.de>
Tue, 24 Jun 1997 10:01:42 +0200
changeset 430 574a94732ece
parent 429 f98e6af57214
child 477 37f12d35c359
permissions -rw-r--r--
checkin from browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     1
"
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1993 by Claus Gittinger
26
ff148983c183 *** empty log message ***
claus
parents: 11
diff changeset
     3
	      All Rights Reserved
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     4
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    11
"
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    12
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    13
ImageView subclass:#ImageEditView
404
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
    14
	instanceVariableNames:'magnification colors magnifiedImage colorPanel pathName enhance
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
    15
		antiAlias'
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    16
	classVariableNames:''
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    17
	poolDictionaries:''
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    18
	category:'Views-Misc'
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    19
!
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    20
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    21
!ImageEditView class methodsFor:'documentation'!
64
claus
parents: 61
diff changeset
    22
claus
parents: 61
diff changeset
    23
copyright
claus
parents: 61
diff changeset
    24
"
claus
parents: 61
diff changeset
    25
 COPYRIGHT (c) 1993 by Claus Gittinger
claus
parents: 61
diff changeset
    26
	      All Rights Reserved
claus
parents: 61
diff changeset
    27
claus
parents: 61
diff changeset
    28
 This software is furnished under a license and may be used
claus
parents: 61
diff changeset
    29
 only in accordance with the terms of that license and with the
claus
parents: 61
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
claus
parents: 61
diff changeset
    31
 be provided or otherwise made available to, or used by, any
claus
parents: 61
diff changeset
    32
 other person.  No title to or ownership of the software is
claus
parents: 61
diff changeset
    33
 hereby transferred.
claus
parents: 61
diff changeset
    34
"
claus
parents: 61
diff changeset
    35
!
claus
parents: 61
diff changeset
    36
claus
parents: 61
diff changeset
    37
documentation
claus
parents: 61
diff changeset
    38
"
claus
parents: 61
diff changeset
    39
    This View will eventually be able to edit bitmap images.
claus
parents: 61
diff changeset
    40
    For now, it is not.
296
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
    41
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
    42
    [author:]
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
    43
        Claus Gittinger
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
    44
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
    45
    [see also:]
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
    46
        Image Form
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    47
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    48
    [start with:]
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    49
        ImageEditView openOn:'bitmaps/gifImages/garfield.gif'
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    50
        ImageEditView openOnImage:(Image fromFile:'bitmaps/gifImages/garfield.gif')
64
claus
parents: 61
diff changeset
    51
"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    52
! !
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    53
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    54
!ImageEditView class methodsFor:'startup'!
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    55
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    56
openOn:aFileName
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    57
    "startup an image editor on an image read from a file"
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    58
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    59
    |editView|
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    60
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    61
    editView := super openOn:aFileName.
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    62
    editView pathName:aFileName asFilename pathName.
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    63
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    64
    ^ editView
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    65
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    66
    "
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    67
     ImageEditView openOn:'bitmaps/gifImages/garfield.gif'
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    68
     ImageEditView openOn:'bitmaps/xpmBitmaps/BOOK.xpm'
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    69
    "
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    70
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    71
    "Modified: 10.4.1997 / 17:31:17 / cg"
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    72
! !
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    73
7
19b36b78ee01 *** empty log message ***
claus
parents: 5
diff changeset
    74
!ImageEditView methodsFor:'accessing'!
19b36b78ee01 *** empty log message ***
claus
parents: 5
diff changeset
    75
19b36b78ee01 *** empty log message ***
claus
parents: 5
diff changeset
    76
image:anImage
295
6388ebe84be2 fixed display of magnified image with mask.
Claus Gittinger <cg@exept.de>
parents: 294
diff changeset
    77
    |oldMag|
6388ebe84be2 fixed display of magnified image with mask.
Claus Gittinger <cg@exept.de>
parents: 294
diff changeset
    78
6388ebe84be2 fixed display of magnified image with mask.
Claus Gittinger <cg@exept.de>
parents: 294
diff changeset
    79
    oldMag := magnification.
7
19b36b78ee01 *** empty log message ***
claus
parents: 5
diff changeset
    80
    magnification := 1@1.
19b36b78ee01 *** empty log message ***
claus
parents: 5
diff changeset
    81
    magnifiedImage := nil.
295
6388ebe84be2 fixed display of magnified image with mask.
Claus Gittinger <cg@exept.de>
parents: 294
diff changeset
    82
    super image:anImage.
6388ebe84be2 fixed display of magnified image with mask.
Claus Gittinger <cg@exept.de>
parents: 294
diff changeset
    83
    self magnification:oldMag
6388ebe84be2 fixed display of magnified image with mask.
Claus Gittinger <cg@exept.de>
parents: 294
diff changeset
    84
6388ebe84be2 fixed display of magnified image with mask.
Claus Gittinger <cg@exept.de>
parents: 294
diff changeset
    85
    "Modified: 20.2.1997 / 18:29:13 / cg"
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    86
!
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    87
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    88
magnification:aMagnificationPoint
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
    89
    |nPixel savedImage oldBounds newBounds rects|
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    90
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    91
    magnification ~= aMagnificationPoint ifTrue:[
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    92
        "show wait cursor; although magnification is fast, dithering may take a while"
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
    93
        self withWaitCursorDo:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
    94
            magnifiedImage isNil ifTrue:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
    95
                oldBounds := image bounds.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
    96
            ] ifFalse:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
    97
                oldBounds := magnifiedImage bounds
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
    98
            ].
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    99
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   100
            (device visualType == #PseudoColor) ifTrue:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   101
                "release kept colors"
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   102
                colors := IdentitySet new.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   103
            ].
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   104
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   105
            magnification := aMagnificationPoint asPoint.
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   106
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   107
            "use a magnified image, if its size wont be too big"
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   108
            magnifiedImage := nil.
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   109
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   110
            "avoid slow scroll"
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   111
            savedImage := image.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   112
            image := nil.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   113
            self scrollToTopLeft.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   114
            image := savedImage.
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   115
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   116
            magnification ~= (1@1) ifTrue:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   117
                nPixel := image width * image height * magnification x * magnification y.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   118
                nPixel <= (2000 * 2000) ifTrue:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   119
                    Transcript showCR:'magnifying ..'; endEntry.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   120
                    antiAlias ifTrue:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   121
                        magnifiedImage := image hardAntiAliasedMagnifiedBy:magnification
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   122
                    ] ifFalse:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   123
                        magnifiedImage := image magnifiedBy:magnification
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   124
                    ]
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   125
                ].
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   126
            ].
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   127
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   128
            self contentsChanged.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   129
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   130
            magnifiedImage isNil ifTrue:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   131
                newBounds := image bounds.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   132
            ] ifFalse:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   133
                newBounds := magnifiedImage bounds
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   134
            ].
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   135
            (rects := oldBounds areasOutside:newBounds) notNil ifTrue:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   136
                rects do:[:rect |
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   137
                    self clearRectangle:rect+(1@1).
404
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   138
                ]
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   139
            ]
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   140
        ].
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   141
        self invalidate.
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   142
    ]
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   143
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   144
    "Modified: 4.6.1997 / 13:38:16 / cg"
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   145
!
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   146
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   147
pathName:aPathName
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   148
    "set the pathName of the edited image.
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   149
     This is used as a default in the save-dialog"
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   150
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   151
    pathName := aPathName
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   152
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   153
    "Created: 10.4.1997 / 17:31:54 / cg"
7
19b36b78ee01 *** empty log message ***
claus
parents: 5
diff changeset
   154
! !
19b36b78ee01 *** empty log message ***
claus
parents: 5
diff changeset
   155
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   156
!ImageEditView methodsFor:'drawing'!
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   157
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   158
redrawX:x y:y width:w height:h
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   159
    |area ih iw dotW dotH minX maxX minY maxY color last lastY runW x0 oldClip|
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   160
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   161
    image isNil ifTrue:[^ self].
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   162
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   163
    (magnification = (1@1)) ifTrue:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   164
        super redrawX:x y:y width:w height:h.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   165
        ^ self
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   166
    ].
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   167
        
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   168
    magnifiedImage notNil ifTrue:[
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   169
        self function:#copy.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   170
        self paint:Black.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   171
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   172
        magnifiedImage device ~~ device ifTrue:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   173
            "/ this may take some time (allocating colors & dithering
205
96f80d06fe5a oops - care for d1 images colors
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
   174
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   175
            self 
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   176
                displayRectangleX:margin y:margin 
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   177
                width:magnifiedImage width height:magnifiedImage height.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   178
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   179
            self withWaitCursorDo:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   180
                magnifiedImage := magnifiedImage on:device.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   181
            ]
204
e419b26888e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   182
        ].
e419b26888e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   183
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   184
        self withWaitCursorDo:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   185
            magnifiedImage depth == 1 ifTrue:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   186
                self paint:(magnifiedImage colorFromValue:1)
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   187
                        on:(magnifiedImage colorFromValue:0).
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   188
            ] ifFalse:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   189
                self paint:Black on:White.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   190
            ].
295
6388ebe84be2 fixed display of magnified image with mask.
Claus Gittinger <cg@exept.de>
parents: 294
diff changeset
   191
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   192
            (magnifiedImage depth ~~ 1
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   193
            and:[magnifiedImage mask notNil]) ifTrue:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   194
                self clearRectangleX:x y:y width:w height:h.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   195
                self displayForm:magnifiedImage x:margin y:margin 
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   196
            ] ifFalse:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   197
                self displayOpaqueForm:magnifiedImage x:margin y:margin 
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   198
            ].
430
574a94732ece checkin from browser
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
   199
574a94732ece checkin from browser
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
   200
            "/ right of image ?
574a94732ece checkin from browser
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
   201
            (x + w - 1) > magnifiedImage width ifTrue:[
574a94732ece checkin from browser
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
   202
                self clearRectangleX:(magnifiedImage width)
574a94732ece checkin from browser
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
   203
                                   y:y
574a94732ece checkin from browser
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
   204
                               width:(x + w - 1 - magnifiedImage width)
574a94732ece checkin from browser
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
   205
                              height:h  
574a94732ece checkin from browser
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
   206
            ].
574a94732ece checkin from browser
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
   207
            "/ below of image ?
574a94732ece checkin from browser
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
   208
            (y + h - 1) > magnifiedImage height ifTrue:[
574a94732ece checkin from browser
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
   209
                self clearRectangleX:margin
574a94732ece checkin from browser
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
   210
                                   y:(magnifiedImage height)
574a94732ece checkin from browser
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
   211
                               width:w
574a94732ece checkin from browser
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
   212
                              height:(y + h - 1 - magnifiedImage height)  
574a94732ece checkin from browser
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
   213
            ].
295
6388ebe84be2 fixed display of magnified image with mask.
Claus Gittinger <cg@exept.de>
parents: 294
diff changeset
   214
        ].
6388ebe84be2 fixed display of magnified image with mask.
Claus Gittinger <cg@exept.de>
parents: 294
diff changeset
   215
203
0ef4bbc2524f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   216
        ^ self
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   217
    ].
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   218
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   219
    ih := image height.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   220
    iw := image width.
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   221
    dotW := magnification x.
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   222
    dotH := magnification y.
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   223
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   224
    minX := x // dotW.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   225
    minY := y // dotW.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   226
    maxX := (x + w) // dotW + 1.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   227
    maxX > iw ifTrue:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   228
        maxX := iw
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   229
    ].
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   230
    maxY := (y + h) // dotH + 1.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   231
    maxY > ih ifTrue:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   232
        maxY := ih
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   233
    ].
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   234
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   235
    lastY := -1.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   236
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   237
    x0 := minX.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   238
    runW := 0.
204
e419b26888e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   239
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   240
    image colorsFromX:minX y:minY toX:maxX-1 y:maxY-1 do:[:x :y :color |
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   241
        y ~~ lastY ifTrue:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   242
            runW ~~ 0 ifTrue:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   243
                self fillRectangleX:(x0 * dotW + margin)
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   244
                                  y:(lastY * dotH + margin)
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   245
                              width:runW height:dotH.
203
0ef4bbc2524f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   246
                runW := 0.
0ef4bbc2524f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   247
            ].
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   248
            x0 := x.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   249
            lastY := y.
204
e419b26888e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   250
        ].
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   251
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   252
        color ~~ last ifTrue:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   253
            runW ~~ 0 ifTrue:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   254
                self fillRectangleX:(x0 * dotW + margin)
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   255
                                  y:(y * dotH + margin)
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   256
                              width:runW height:dotH.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   257
                runW := 0.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   258
            ].
204
e419b26888e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   259
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   260
            "/ keep colors - otherwise they might get collected & changed
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   261
            colors notNil ifTrue:[colors add:color].
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   262
            self paint:color.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   263
            last := color.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   264
            runW := 0.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   265
            x0 := x.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   266
        ].
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   267
        runW := runW + dotW
191
87e4b26cd344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   268
    ].
87e4b26cd344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   269
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   270
    runW ~~ 0 ifTrue:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   271
        self fillRectangleX:(x0 * dotW + margin)
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   272
                          y:(lastY * dotH + margin)
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   273
                      width:runW height:dotH.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   274
        runW := 0.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   275
    ].
191
87e4b26cd344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   276
430
574a94732ece checkin from browser
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
   277
    "Modified: 23.6.1997 / 21:24:40 / cg"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   278
! !
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   279
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   280
!ImageEditView methodsFor:'event handling'!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   281
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   282
buttonMotion:state x:x y:y
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   283
    self showColorAtX:x y:y.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   284
!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   285
167
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   286
buttonMultiPress:button x:x y:y
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   287
    button == 1 ifTrue:[
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   288
        |clr|
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   289
        clr := self getColorAtX:x y:y.
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   290
        clr inspect.
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   291
    ].
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   292
    super buttonMultiPress:button x:x y:y
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   293
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   294
    "Created: 8.5.1996 / 00:18:06 / stefan"
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   295
!
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   296
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   297
buttonPress:button x:x y:y
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   298
    button == 1 ifTrue:[
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   299
	self showColorAtX:x y:y.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   300
	^ self
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   301
    ].
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   302
    super buttonPress:button x:x y:y
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   303
!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   304
167
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   305
getColorAtX:x y:y
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   306
    |pi|
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   307
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   308
    pi := (x @ y) - margin.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   309
    pi := pi // magnification.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   310
    ((0@0 corner:image extent) containsPoint:pi) ifTrue:[
167
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   311
        ^ image at:pi.
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   312
    ].
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   313
    ^ nil
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   314
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   315
    "Created: 8.5.1996 / 00:15:55 / stefan"
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   316
!
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   317
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   318
showColorAtX:x y:y
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   319
    |clr|
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   320
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   321
    clr := self getColorAtX:x y:y.
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   322
    clr notNil ifTrue:[
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   323
        colorPanel notNil ifTrue:[
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   324
            colorPanel setColor:clr.
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   325
        ] ifFalse:[
184
13a2f3677c68 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 167
diff changeset
   326
            Transcript showCR:clr displayString
167
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   327
        ]
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   328
    ]
167
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   329
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   330
    "Modified: 8.5.1996 / 00:20:45 / stefan"
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   331
! !
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   332
406
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   333
!ImageEditView methodsFor:'image conversion'!
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   334
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   335
convertToColor24
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   336
    (Depth24Image fromImage:image) inspect
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   337
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   338
    "Modified: 3.6.1997 / 18:34:34 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   339
!
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   340
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   341
convertToColor4
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   342
    (Depth4Image fromImage:image) inspect
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   343
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   344
    "Modified: 3.6.1997 / 18:34:45 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   345
!
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   346
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   347
convertToColor8
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   348
    (Depth8Image fromImage:image) inspect
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   349
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   350
    "Created: 3.6.1997 / 18:34:08 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   351
    "Modified: 3.6.1997 / 18:34:51 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   352
!
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   353
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   354
convertToGray2
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   355
    (image asFloydSteinbergDitheredGrayImageDepth:2) inspect
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   356
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   357
    "Created: 3.6.1997 / 18:34:02 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   358
    "Modified: 3.6.1997 / 18:39:23 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   359
!
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   360
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   361
convertToGray4
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   362
    (image asFloydSteinbergDitheredGrayImageDepth:4) inspect
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   363
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   364
    "Created: 3.6.1997 / 18:34:04 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   365
    "Modified: 3.6.1997 / 18:39:20 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   366
!
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   367
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   368
convertToGray8
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   369
    (image asFloydSteinbergDitheredGrayImageDepth:8) inspect
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   370
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   371
    "Created: 3.6.1997 / 18:34:05 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   372
    "Modified: 3.6.1997 / 18:39:16 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   373
!
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   374
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   375
convertToMono
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   376
    (image asFloydSteinbergDitheredGrayImageDepth:1) inspect
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   377
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   378
    "Created: 3.6.1997 / 18:33:42 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   379
    "Modified: 3.6.1997 / 18:39:26 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   380
! !
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   381
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   382
!ImageEditView methodsFor:'image processing'!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   383
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   384
blurr
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   385
    self performImageOperation:#blurr withArguments:nil
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   386
!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   387
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   388
flipHorizontal
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   389
    self performImageOperation:#flipHorizontal withArguments:nil
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   390
!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   391
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   392
flipVertical
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   393
    self performImageOperation:#flipVertical withArguments:nil
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   394
!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   395
426
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   396
negative
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   397
    self performImageOperation:#negative withArguments:nil
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   398
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   399
    "Modified: 20.6.1997 / 13:14:45 / cg"
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   400
!
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   401
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   402
performImageOperation:operation withArguments:args
429
f98e6af57214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   403
    |oldMag newImage|
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   404
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   405
    windowGroup withCursor:Cursor wait do:[
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   406
        oldMag := magnification.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   407
        magnifiedImage := nil.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   408
        magnification := 1@1.
429
f98e6af57214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   409
        newImage := image perform:operation withArguments:args.
f98e6af57214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   410
        newImage isNil ifTrue:[
f98e6af57214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   411
            self information:'conversion failed - revert to original'.
f98e6af57214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   412
            ^ self
f98e6af57214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   413
        ].
f98e6af57214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   414
        image := newImage.
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   415
        self clear.
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   416
        (oldMag isNil or:[oldMag = magnification]) ifTrue:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   417
            self invalidate
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   418
        ] ifFalse:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   419
            self magnification:oldMag.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   420
        ]
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   421
    ]
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   422
429
f98e6af57214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   423
    "Modified: 23.6.1997 / 09:49:26 / cg"
322
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   424
!
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   425
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   426
rotateCCW
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   427
    self performImageOperation:#rotated: withArguments:#(270)
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   428
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   429
    "Created: 17.3.1997 / 11:56:42 / cg"
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   430
!
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   431
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   432
rotateCW
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   433
    self performImageOperation:#rotated: withArguments:#(90)
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   434
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   435
    "Created: 17.3.1997 / 11:56:36 / cg"
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   436
! !
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   437
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   438
!ImageEditView methodsFor:'initialization'!
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   439
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   440
initialize
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   441
    super initialize.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   442
    magnification := 1@1.
404
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   443
    antiAlias := false.
296
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
   444
    colors := nil.
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
   445
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
   446
    self menuHolder:self; menuPerformer:self; menuMessage:#imageMenu.
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
   447
404
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   448
    "Modified: 2.6.1997 / 15:49:00 / cg"
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   449
! !
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   450
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   451
!ImageEditView methodsFor:'menu'!
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   452
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   453
imageMenu
406
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   454
    |m convertMenu labels selectors|
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   455
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   456
    image mask notNil ifTrue:[
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   457
        labels := #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   458
                        'save as ...'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   459
                        'save mask as ...'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   460
                       ).
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   461
        selectors := #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   462
                        saveAs
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   463
                        saveMaskAs
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   464
                      ).
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   465
        magnifiedImage notNil ifTrue:[
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   466
            labels := labels , #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   467
                        '-'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   468
                        'save magnified as ...'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   469
                        'save magnified mask as ...'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   470
                       ).
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   471
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   472
            selectors := selectors , #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   473
                        nil
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   474
                        saveMagnifiedAs
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   475
                        saveMagnifiedMaskAs
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   476
                      ).
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   477
        ]
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   478
    ] ifFalse:[
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   479
        labels := #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   480
                        'save as ...'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   481
                       ).
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   482
        selectors := #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   483
                        saveAs
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   484
                      ).
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   485
        magnifiedImage notNil ifTrue:[
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   486
            labels := labels , #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   487
                        '-'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   488
                        'save magnified as ...'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   489
                       ).
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   490
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   491
            selectors := selectors , #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   492
                        nil
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   493
                        saveMagnifiedAs
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   494
                      ).
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   495
        ]
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   496
    ].
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   497
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   498
    labels := labels , #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   499
                            '-'
362
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   500
                            'print'
405
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   501
                            'print magnified'
362
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   502
                            '-'
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   503
                            'magnification'
404
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   504
                            'magnify & antiAlias'
26
ff148983c183 *** empty log message ***
claus
parents: 11
diff changeset
   505
"/                            'colors'
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   506
                            'effects'
406
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   507
                            'convert to'
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   508
                        ).
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   509
    selectors := selectors , #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   510
                        nil
362
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   511
                        doPrint
405
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   512
                        doPrintMagnified
362
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   513
                        nil
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   514
                        changeMagnification
404
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   515
                        changeMagnificationAndAntiAlias
26
ff148983c183 *** empty log message ***
claus
parents: 11
diff changeset
   516
"/                        showColors
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   517
                        effects
406
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   518
                        convert
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   519
                        ).
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   520
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   521
    m := PopUpMenu
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   522
               labels:(resources array:labels)
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   523
            selectors:selectors
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   524
             receiver:self
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   525
                  for:self.
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   526
405
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   527
    magnification = 1 ifTrue:[
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   528
        m disable:#doPrintMagnified
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   529
    ].
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   530
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   531
    m subMenuAt:#effects put:(
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   532
        PopUpMenu labels:(resources array:#(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   533
                            'flip - vertical'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   534
                            'flip - horizontal'
322
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   535
                            '-'
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   536
                            'rotate - clockwise'
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   537
                            'rotate - counter clockwise'
426
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   538
                            '-'
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   539
                            'negative'
11
793044d4bc90 *** empty log message ***
claus
parents: 9
diff changeset
   540
"
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   541
                            'blurr'
11
793044d4bc90 *** empty log message ***
claus
parents: 9
diff changeset
   542
"
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   543
                           ))
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   544
               selectors:#(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   545
                            flipVertical
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   546
                            flipHorizontal
322
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   547
                            nil
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   548
                            rotateCW
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   549
                            rotateCCW
426
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   550
                            nil
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   551
                            negative
11
793044d4bc90 *** empty log message ***
claus
parents: 9
diff changeset
   552
"
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   553
                            blurr
11
793044d4bc90 *** empty log message ***
claus
parents: 9
diff changeset
   554
"
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   555
                           )
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   556
                receiver:self
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   557
                     for:self
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   558
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   559
    ).
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   560
406
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   561
    m subMenuAt:#convert put:(
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   562
        convertMenu :=
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   563
        PopUpMenu labels:(resources array:#(
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   564
                            'monochrome (dither)'
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   565
                            '-'
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   566
                            'gray 2-plane (dither)'
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   567
                            'gray 4-plane (dither) '
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   568
                            'gray 8-plane '
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   569
                            '-'
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   570
"/                            'color 4-plane (dither)'
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   571
"/                            'color 8-plane (dither)'
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   572
                            'color 24-plane'
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   573
                           ))
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   574
               selectors:#(
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   575
                            convertToMono
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   576
                            nil
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   577
                            convertToGray2
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   578
                            convertToGray4
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   579
                            convertToGray8
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   580
                            nil
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   581
"/                            convertToColor4
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   582
"/                            convertToColor8
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   583
                            convertToColor24
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   584
                           )
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   585
                receiver:self
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   586
                     for:self
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   587
    ).
426
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   588
406
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   589
    image depth == 1 ifTrue:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   590
        convertMenu disable:#convertToMono
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   591
    ].
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   592
    image depth == 2 ifTrue:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   593
        (image photometric ~~ #palette
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   594
        and:[image photometric ~~ #rgb]) ifTrue:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   595
            convertMenu disable:#convertToGray2
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   596
        ]
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   597
    ].
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   598
    image depth == 4 ifTrue:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   599
        (image photometric ~~ #palette
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   600
        and:[image photometric ~~ #rgb]) ifTrue:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   601
            convertMenu disable:#convertToGray4
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   602
        ] ifFalse:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   603
            convertMenu disable:#convertToColor4
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   604
        ]
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   605
    ].
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   606
    image depth == 8 ifTrue:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   607
        (image photometric ~~ #palette
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   608
        and:[image photometric ~~ #rgb]) ifTrue:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   609
            convertMenu disable:#convertToGray8
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   610
        ] ifFalse:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   611
            convertMenu disable:#convertToColor8
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   612
        ]
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   613
    ].
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   614
    image depth == 24 ifTrue:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   615
        image photometric == #rgb ifTrue:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   616
            convertMenu disable:#convertToColor24
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   617
        ]
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   618
    ].
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   619
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   620
    ^ m
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   621
26
ff148983c183 *** empty log message ***
claus
parents: 11
diff changeset
   622
    "
ff148983c183 *** empty log message ***
claus
parents: 11
diff changeset
   623
     ImageEditView openOn:'bitmaps/SBrowser.xbm'
ff148983c183 *** empty log message ***
claus
parents: 11
diff changeset
   624
     ImageEditView openOn:'bitmaps/garfield.gif'
ff148983c183 *** empty log message ***
claus
parents: 11
diff changeset
   625
    "
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   626
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   627
    "Created: 20.2.1997 / 18:47:17 / cg"
426
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   628
    "Modified: 20.6.1997 / 13:18:52 / cg"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   629
! !
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   630
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   631
!ImageEditView methodsFor:'menu actions'!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   632
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   633
changeMagnification
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   634
    |b|
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   635
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   636
    b := EnterBox new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   637
    b title:'magnification (magX @ magY)'.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   638
    b okText:'apply'.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   639
    b abortText:'abort'.
404
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   640
    b action:[:string | 
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   641
                        antiAlias ifTrue:[
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   642
                            magnification := nil.
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   643
                        ].
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   644
                        antiAlias := false.
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   645
                        self magnification:(Object readFromString:string)].
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   646
    b initialText:(magnification printString).
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   647
    b showAtPointer
404
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   648
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   649
    "Modified: 2.6.1997 / 15:49:47 / cg"
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   650
!
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   651
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   652
changeMagnificationAndAntiAlias
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   653
    |b|
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   654
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   655
    b := EnterBox new.
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   656
    b title:'magnification (magX @ magY)'.
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   657
    b okText:'apply'.
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   658
    b abortText:'abort'.
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   659
    b action:[:string | 
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   660
                        antiAlias ifFalse:[
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   661
                            magnification := nil.
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   662
                        ].
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   663
                        antiAlias := true.
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   664
                        self magnification:(Object readFromString:string)].
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   665
    b initialText:(magnification printString).
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   666
    b showAtPointer
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   667
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   668
    "Modified: 2.6.1997 / 15:49:58 / cg"
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   669
    "Created: 2.6.1997 / 15:51:01 / cg"
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   670
!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   671
362
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   672
doPrint
405
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   673
    self doPrint:image
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   674
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   675
    "Modified: 2.6.1997 / 18:32:11 / cg"
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   676
!
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   677
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   678
doPrint:anImage
362
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   679
    |stream psgc|
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   680
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   681
    Printer supportsPostscript ifFalse:[
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   682
        self warn:'need a postscript printer'.
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   683
        ^ self
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   684
    ].
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   685
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   686
    stream := Printer newNative.
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   687
    stream isNil ifTrue:[
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   688
        self warn:'cannot open printer stream'.
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   689
        ^ nil
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   690
    ].
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   691
398
7b7255a4db0d show a wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
   692
    self withWaitCursorDo:[
7b7255a4db0d show a wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
   693
        psgc := PSGraphicsContext on:stream. "/  extent:(1.0 @ 1.0).
405
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   694
        psgc displayForm:anImage x:0 y:0.
398
7b7255a4db0d show a wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
   695
        psgc close.
7b7255a4db0d show a wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
   696
    ]
362
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   697
398
7b7255a4db0d show a wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
   698
    "Modified: 28.5.1997 / 10:54:11 / cg"
405
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   699
    "Created: 2.6.1997 / 18:32:03 / cg"
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   700
!
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   701
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   702
doPrintMagnified
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   703
    self doPrint:(magnifiedImage ? image)
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   704
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   705
    "Modified: 2.6.1997 / 18:31:54 / cg"
362
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   706
!
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   707
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   708
doSaveImageAs:anImage title:aTitle
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   709
    "save contents into a file 
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   710
     - ask user for filename using a fileSelectionBox."
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   711
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   712
    |fileName defaultName rdr i txt suffix|
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   713
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   714
    defaultName := pathName ? ''.
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   715
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   716
    pathName isNil ifTrue:[
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   717
        suffix := 'tiff'
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   718
    ] ifFalse:[
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   719
        suffix := pathName asFilename suffix.
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   720
        "/ a supported suffix ?
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   721
        ((rdr := Image imageReaderClassForSuffix:suffix) isNil 
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   722
        or:[(rdr canRepresent:anImage) not]) ifTrue:[
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   723
            suffix := 'tiff'.
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   724
            defaultName := (pathName asFilename withSuffix:suffix) pathName
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   725
        ].
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   726
    ].
251
a6e8eb4d7922 save the magnified image.
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   727
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   728
    fileName := Dialog
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   729
                    requestFileName:(resources string:aTitle)
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   730
                    default:defaultName
251
a6e8eb4d7922 save the magnified image.
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   731
                    ok:(resources string:'save')
a6e8eb4d7922 save the magnified image.
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   732
                    abort:(resources string:'abort')
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   733
                    pattern:('*.' , suffix).
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   734
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   735
    fileName notNil ifTrue:[
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   736
        anImage saveOn:fileName.
294
479afb39879a remember last save-name; use as default for saveBox
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
   737
        pathName := fileName.
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   738
    ].
251
a6e8eb4d7922 save the magnified image.
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   739
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   740
    "Created: 20.2.1997 / 18:52:08 / cg"
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   741
    "Modified: 10.4.1997 / 17:49:58 / cg"
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   742
!
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   743
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   744
saveAs
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   745
    "save contents into a file 
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   746
     - ask user for filename using a fileSelectionBox."
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   747
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   748
    self doSaveImageAs:image title:'save image in:'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   749
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   750
    "Modified: 20.2.1997 / 18:52:37 / cg"
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   751
!
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   752
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   753
saveMagnifiedAs
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   754
    "save contents into a file 
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   755
     - ask user for filename using a fileSelectionBox."
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   756
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   757
    self doSaveImageAs:magnifiedImage title:'save magnified image in:'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   758
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   759
    "Created: 20.2.1997 / 18:52:53 / cg"
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   760
!
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   761
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   762
saveMagnifiedMaskAs
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   763
    "save contents into a file 
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   764
     - ask user for filename using a fileSelectionBox."
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   765
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   766
    self doSaveImageAs:(magnifiedImage mask) title:'save magnified mask in:'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   767
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   768
    "Created: 20.2.1997 / 18:53:31 / cg"
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   769
    "Modified: 20.2.1997 / 18:56:48 / cg"
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   770
!
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   771
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   772
saveMaskAs
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   773
    "save contents into a file 
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   774
     - ask user for filename using a fileSelectionBox."
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   775
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   776
    self doSaveImageAs:(image mask) title:'save mask in:'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   777
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   778
    "Created: 20.2.1997 / 18:51:06 / cg"
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   779
    "Modified: 20.2.1997 / 18:56:54 / cg"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   780
!
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   781
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   782
showColors
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   783
    colorPanel isNil ifTrue:[
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   784
        colorPanel := ColorPanel new
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   785
    ].
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   786
    colorPanel shown ifFalse:[
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   787
        colorPanel open
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   788
    ]
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   789
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   790
    "Modified: 10.4.1997 / 17:22:35 / cg"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   791
! !
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   792
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   793
!ImageEditView methodsFor:'queries'!
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   794
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   795
heightOfContents
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   796
    "return the images height"
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   797
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   798
    image isNil ifTrue:[^ 0].
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   799
    ^ (image height * magnification y) rounded
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   800
!
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   801
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   802
widthOfContents
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   803
    "return the images width"
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   804
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   805
    image isNil ifTrue:[^ 0].
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   806
    ^ (image width * magnification x) rounded
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   807
! !
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   808
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   809
!ImageEditView methodsFor:'release'!
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   810
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   811
destroy
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   812
    colors := nil.
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   813
    magnifiedImage := nil.
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   814
    colorPanel notNil ifTrue:[
26
ff148983c183 *** empty log message ***
claus
parents: 11
diff changeset
   815
	colorPanel destroy.
ff148983c183 *** empty log message ***
claus
parents: 11
diff changeset
   816
	colorPanel := nil.
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   817
    ].
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   818
    super destroy.
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   819
! !
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   820
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   821
!ImageEditView class methodsFor:'documentation'!
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   822
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   823
version
430
574a94732ece checkin from browser
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
   824
    ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.44 1997-06-24 08:01:42 cg Exp $'
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   825
! !