ImageEditView.st
author Claus Gittinger <cg@exept.de>
Fri, 20 Jun 1997 13:19:07 +0200
changeset 426 2e3dfa527a07
parent 413 3d0910d706c9
child 429 f98e6af57214
permissions -rw-r--r--
added #negative
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
"/    area := Rectangle left:x top:y width:w height:h.      
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   164
"/    oldClip := self clippingRectangleOrNil.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   165
"/    self clippingRectangle:area.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   166
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   167
    (magnification = (1@1)) ifTrue:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   168
        super redrawX:x y:y width:w height:h.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   169
"/        self clippingRectangle:oldClip.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   170
        ^ self
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   171
    ].
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   172
        
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   173
"/    self clear.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   174
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   175
    magnifiedImage notNil ifTrue:[
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   176
        self function:#copy.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   177
        self paint:Black.
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
        magnifiedImage device ~~ device ifTrue:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   180
            "/ 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
   181
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   182
            self 
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   183
                displayRectangleX:margin y:margin 
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   184
                width:magnifiedImage width height:magnifiedImage height.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   185
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   186
            self withWaitCursorDo:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   187
                magnifiedImage := magnifiedImage on:device.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   188
            ]
204
e419b26888e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   189
        ].
e419b26888e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   190
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   191
        self withWaitCursorDo:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   192
            magnifiedImage depth == 1 ifTrue:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   193
                self paint:(magnifiedImage colorFromValue:1)
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   194
                        on:(magnifiedImage colorFromValue:0).
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   195
            ] ifFalse:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   196
                self paint:Black on:White.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   197
            ].
295
6388ebe84be2 fixed display of magnified image with mask.
Claus Gittinger <cg@exept.de>
parents: 294
diff changeset
   198
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   199
            (magnifiedImage depth ~~ 1
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   200
            and:[magnifiedImage mask notNil]) ifTrue:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   201
                self clearRectangleX:x y:y width:w height:h.
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   202
                self displayForm:magnifiedImage x:margin y:margin 
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   203
            ] ifFalse:[
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   204
                self displayOpaqueForm:magnifiedImage x:margin y:margin 
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   205
            ].
295
6388ebe84be2 fixed display of magnified image with mask.
Claus Gittinger <cg@exept.de>
parents: 294
diff changeset
   206
        ].
6388ebe84be2 fixed display of magnified image with mask.
Claus Gittinger <cg@exept.de>
parents: 294
diff changeset
   207
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   208
"/        self clippingRectangle:oldClip.
203
0ef4bbc2524f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   209
        ^ self
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   210
    ].
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   211
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   212
"/    self clear.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   213
    ih := image height.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   214
    iw := image width.
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   215
    dotW := magnification x.
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   216
    dotH := magnification y.
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   217
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   218
    minX := x // dotW.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   219
    minY := y // dotW.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   220
    maxX := (x + w) // dotW + 1.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   221
    maxX > iw ifTrue:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   222
        maxX := iw
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
    maxY := (y + h) // dotH + 1.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   225
    maxY > ih ifTrue:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   226
        maxY := ih
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   227
    ].
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   228
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   229
    lastY := -1.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   230
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   231
    x0 := minX.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   232
    runW := 0.
204
e419b26888e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   233
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   234
    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
   235
        y ~~ lastY ifTrue:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   236
            runW ~~ 0 ifTrue:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   237
                self fillRectangleX:(x0 * dotW + margin)
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   238
                                  y:(lastY * dotH + margin)
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   239
                              width:runW height:dotH.
203
0ef4bbc2524f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   240
                runW := 0.
0ef4bbc2524f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   241
            ].
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   242
            x0 := x.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   243
            lastY := y.
204
e419b26888e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   244
        ].
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   245
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   246
        color ~~ last ifTrue:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   247
            runW ~~ 0 ifTrue:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   248
                self fillRectangleX:(x0 * dotW + margin)
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   249
                                  y:(y * dotH + margin)
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   250
                              width:runW height:dotH.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   251
                runW := 0.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   252
            ].
204
e419b26888e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   253
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   254
            "/ keep colors - otherwise they might get collected & changed
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   255
            colors notNil ifTrue:[colors add:color].
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   256
            self paint:color.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   257
            last := color.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   258
            runW := 0.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   259
            x0 := x.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   260
        ].
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   261
        runW := runW + dotW
191
87e4b26cd344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   262
    ].
87e4b26cd344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   263
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   264
    runW ~~ 0 ifTrue:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   265
        self fillRectangleX:(x0 * dotW + margin)
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   266
                          y:(lastY * dotH + margin)
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   267
                      width:runW height:dotH.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   268
        runW := 0.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   269
    ].
191
87e4b26cd344 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   270
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   271
"/    self clippingRectangle:oldClip
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   272
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   273
    "Modified: 4.6.1997 / 13:45:53 / cg"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   274
! !
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   275
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   276
!ImageEditView methodsFor:'event handling'!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   277
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   278
buttonMotion:state x:x y:y
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   279
    self showColorAtX:x y:y.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   280
!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   281
167
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   282
buttonMultiPress:button x:x y:y
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   283
    button == 1 ifTrue:[
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   284
        |clr|
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   285
        clr := self getColorAtX:x y:y.
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   286
        clr inspect.
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   287
    ].
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   288
    super buttonMultiPress:button x:x y:y
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   289
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   290
    "Created: 8.5.1996 / 00:18:06 / stefan"
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
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   293
buttonPress:button x:x y:y
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   294
    button == 1 ifTrue:[
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   295
	self showColorAtX:x y:y.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   296
	^ self
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   297
    ].
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   298
    super buttonPress:button x:x y:y
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   299
!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   300
167
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   301
getColorAtX:x y:y
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   302
    |pi|
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   303
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   304
    pi := (x @ y) - margin.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   305
    pi := pi // magnification.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   306
    ((0@0 corner:image extent) containsPoint:pi) ifTrue:[
167
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   307
        ^ image at:pi.
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   308
    ].
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   309
    ^ nil
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   310
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   311
    "Created: 8.5.1996 / 00:15:55 / stefan"
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
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   314
showColorAtX:x y:y
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   315
    |clr|
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
    clr := self getColorAtX:x y:y.
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   318
    clr notNil ifTrue:[
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   319
        colorPanel notNil ifTrue:[
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   320
            colorPanel setColor:clr.
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   321
        ] ifFalse:[
184
13a2f3677c68 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 167
diff changeset
   322
            Transcript showCR:clr displayString
167
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   323
        ]
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   324
    ]
167
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   325
0d6d90115420 Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents: 161
diff changeset
   326
    "Modified: 8.5.1996 / 00:20:45 / stefan"
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   327
! !
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   328
406
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   329
!ImageEditView methodsFor:'image conversion'!
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   330
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   331
convertToColor24
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   332
    (Depth24Image fromImage:image) inspect
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   333
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   334
    "Modified: 3.6.1997 / 18:34:34 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   335
!
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   336
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   337
convertToColor4
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   338
    (Depth4Image fromImage:image) inspect
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
    "Modified: 3.6.1997 / 18:34:45 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   341
!
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   342
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   343
convertToColor8
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   344
    (Depth8Image fromImage:image) inspect
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
    "Created: 3.6.1997 / 18:34:08 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   347
    "Modified: 3.6.1997 / 18:34:51 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   348
!
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
convertToGray2
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   351
    (image asFloydSteinbergDitheredGrayImageDepth:2) inspect
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
    "Created: 3.6.1997 / 18:34:02 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   354
    "Modified: 3.6.1997 / 18:39:23 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   355
!
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
convertToGray4
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   358
    (image asFloydSteinbergDitheredGrayImageDepth:4) inspect
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
    "Created: 3.6.1997 / 18:34:04 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   361
    "Modified: 3.6.1997 / 18:39:20 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   362
!
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
convertToGray8
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   365
    (image asFloydSteinbergDitheredGrayImageDepth:8) inspect
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
    "Created: 3.6.1997 / 18:34:05 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   368
    "Modified: 3.6.1997 / 18:39:16 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   369
!
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
convertToMono
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   372
    (image asFloydSteinbergDitheredGrayImageDepth:1) inspect
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
    "Created: 3.6.1997 / 18:33:42 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   375
    "Modified: 3.6.1997 / 18:39:26 / cg"
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   376
! !
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   377
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   378
!ImageEditView methodsFor:'image processing'!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   379
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   380
blurr
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   381
    self performImageOperation:#blurr withArguments:nil
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   382
!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   383
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   384
flipHorizontal
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   385
    self performImageOperation:#flipHorizontal 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
flipVertical
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   389
    self performImageOperation:#flipVertical 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
426
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   392
negative
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   393
    self performImageOperation:#negative withArguments:nil
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   394
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   395
    "Modified: 20.6.1997 / 13:14:45 / cg"
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   396
!
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   397
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   398
performImageOperation:operation withArguments:args
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   399
    |oldMag|
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   400
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   401
    windowGroup withCursor:Cursor wait do:[
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   402
        oldMag := magnification.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   403
        magnifiedImage := nil.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   404
        magnification := 1@1.
322
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   405
        image := image perform:operation withArguments:args.
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   406
        self clear.
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   407
        (oldMag isNil or:[oldMag = magnification]) ifTrue:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   408
            self invalidate
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   409
        ] ifFalse:[
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   410
            self magnification:oldMag.
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   411
        ]
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   412
    ]
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   413
413
3d0910d706c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   414
    "Modified: 4.6.1997 / 13:40:37 / cg"
322
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   415
!
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   416
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   417
rotateCCW
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   418
    self performImageOperation:#rotated: withArguments:#(270)
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   419
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   420
    "Created: 17.3.1997 / 11:56:42 / cg"
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   421
!
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   422
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   423
rotateCW
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   424
    self performImageOperation:#rotated: withArguments:#(90)
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
    "Created: 17.3.1997 / 11:56:36 / cg"
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   427
! !
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   428
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   429
!ImageEditView methodsFor:'initialization'!
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   430
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   431
initialize
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   432
    super initialize.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   433
    magnification := 1@1.
404
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   434
    antiAlias := false.
296
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
   435
    colors := nil.
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
   436
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
   437
    self menuHolder:self; menuPerformer:self; menuMessage:#imageMenu.
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
   438
404
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   439
    "Modified: 2.6.1997 / 15:49:00 / cg"
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   440
! !
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   441
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   442
!ImageEditView methodsFor:'menu'!
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   443
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   444
imageMenu
406
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   445
    |m convertMenu labels selectors|
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   446
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   447
    image mask notNil ifTrue:[
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   448
        labels := #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   449
                        'save as ...'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   450
                        'save mask as ...'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   451
                       ).
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   452
        selectors := #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   453
                        saveAs
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   454
                        saveMaskAs
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   455
                      ).
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   456
        magnifiedImage notNil ifTrue:[
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   457
            labels := labels , #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   458
                        '-'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   459
                        'save magnified as ...'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   460
                        'save magnified mask as ...'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   461
                       ).
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   462
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   463
            selectors := selectors , #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   464
                        nil
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   465
                        saveMagnifiedAs
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   466
                        saveMagnifiedMaskAs
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
        ]
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   469
    ] ifFalse:[
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   470
        labels := #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   471
                        'save as ...'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   472
                       ).
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   473
        selectors := #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   474
                        saveAs
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   475
                      ).
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   476
        magnifiedImage notNil ifTrue:[
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   477
            labels := labels , #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   478
                        '-'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   479
                        'save magnified as ...'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   480
                       ).
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 := selectors , #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   483
                        nil
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   484
                        saveMagnifiedAs
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   485
                      ).
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   486
        ]
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
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   489
    labels := labels , #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   490
                            '-'
362
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   491
                            'print'
405
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   492
                            'print magnified'
362
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   493
                            '-'
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   494
                            'magnification'
404
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   495
                            'magnify & antiAlias'
26
ff148983c183 *** empty log message ***
claus
parents: 11
diff changeset
   496
"/                            'colors'
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   497
                            'effects'
406
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   498
                            'convert to'
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   499
                        ).
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   500
    selectors := selectors , #(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   501
                        nil
362
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   502
                        doPrint
405
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   503
                        doPrintMagnified
362
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   504
                        nil
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   505
                        changeMagnification
404
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   506
                        changeMagnificationAndAntiAlias
26
ff148983c183 *** empty log message ***
claus
parents: 11
diff changeset
   507
"/                        showColors
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   508
                        effects
406
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   509
                        convert
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   510
                        ).
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   511
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   512
    m := PopUpMenu
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   513
               labels:(resources array:labels)
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   514
            selectors:selectors
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   515
             receiver:self
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   516
                  for:self.
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   517
405
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   518
    magnification = 1 ifTrue:[
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   519
        m disable:#doPrintMagnified
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   520
    ].
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   521
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   522
    m subMenuAt:#effects put:(
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   523
        PopUpMenu labels:(resources array:#(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   524
                            'flip - vertical'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   525
                            'flip - horizontal'
322
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   526
                            '-'
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   527
                            'rotate - clockwise'
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   528
                            'rotate - counter clockwise'
426
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   529
                            '-'
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   530
                            'negative'
11
793044d4bc90 *** empty log message ***
claus
parents: 9
diff changeset
   531
"
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   532
                            'blurr'
11
793044d4bc90 *** empty log message ***
claus
parents: 9
diff changeset
   533
"
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   534
                           ))
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   535
               selectors:#(
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   536
                            flipVertical
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   537
                            flipHorizontal
322
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   538
                            nil
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   539
                            rotateCW
5b3b7c1dbcfc added rotate-effects.
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   540
                            rotateCCW
426
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   541
                            nil
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   542
                            negative
11
793044d4bc90 *** empty log message ***
claus
parents: 9
diff changeset
   543
"
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   544
                            blurr
11
793044d4bc90 *** empty log message ***
claus
parents: 9
diff changeset
   545
"
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   546
                           )
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   547
                receiver:self
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   548
                     for:self
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   549
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   550
    ).
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   551
406
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   552
    m subMenuAt:#convert put:(
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   553
        convertMenu :=
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   554
        PopUpMenu labels:(resources array:#(
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   555
                            'monochrome (dither)'
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   556
                            '-'
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   557
                            'gray 2-plane (dither)'
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   558
                            'gray 4-plane (dither) '
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   559
                            'gray 8-plane '
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   560
                            '-'
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   561
"/                            'color 4-plane (dither)'
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   562
"/                            'color 8-plane (dither)'
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   563
                            'color 24-plane'
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   564
                           ))
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   565
               selectors:#(
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   566
                            convertToMono
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   567
                            nil
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   568
                            convertToGray2
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   569
                            convertToGray4
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   570
                            convertToGray8
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   571
                            nil
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   572
"/                            convertToColor4
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   573
"/                            convertToColor8
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   574
                            convertToColor24
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   575
                           )
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   576
                receiver:self
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   577
                     for:self
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   578
    ).
426
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   579
406
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   580
    image depth == 1 ifTrue:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   581
        convertMenu disable:#convertToMono
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   582
    ].
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   583
    image depth == 2 ifTrue:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   584
        (image photometric ~~ #palette
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   585
        and:[image photometric ~~ #rgb]) ifTrue:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   586
            convertMenu disable:#convertToGray2
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   587
        ]
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   588
    ].
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   589
    image depth == 4 ifTrue:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   590
        (image photometric ~~ #palette
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   591
        and:[image photometric ~~ #rgb]) ifTrue:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   592
            convertMenu disable:#convertToGray4
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   593
        ] ifFalse:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   594
            convertMenu disable:#convertToColor4
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   595
        ]
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
    image depth == 8 ifTrue:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   598
        (image photometric ~~ #palette
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   599
        and:[image photometric ~~ #rgb]) ifTrue:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   600
            convertMenu disable:#convertToGray8
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   601
        ] ifFalse:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   602
            convertMenu disable:#convertToColor8
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   603
        ]
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
    image depth == 24 ifTrue:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   606
        image photometric == #rgb ifTrue:[
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   607
            convertMenu disable:#convertToColor24
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   608
        ]
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   609
    ].
b7a8c848a000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
   610
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   611
    ^ m
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   612
26
ff148983c183 *** empty log message ***
claus
parents: 11
diff changeset
   613
    "
ff148983c183 *** empty log message ***
claus
parents: 11
diff changeset
   614
     ImageEditView openOn:'bitmaps/SBrowser.xbm'
ff148983c183 *** empty log message ***
claus
parents: 11
diff changeset
   615
     ImageEditView openOn:'bitmaps/garfield.gif'
ff148983c183 *** empty log message ***
claus
parents: 11
diff changeset
   616
    "
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   617
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   618
    "Created: 20.2.1997 / 18:47:17 / cg"
426
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   619
    "Modified: 20.6.1997 / 13:18:52 / cg"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   620
! !
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   621
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   622
!ImageEditView methodsFor:'menu actions'!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   623
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   624
changeMagnification
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   625
    |b|
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   626
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   627
    b := EnterBox new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   628
    b title:'magnification (magX @ magY)'.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   629
    b okText:'apply'.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   630
    b abortText:'abort'.
404
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   631
    b action:[:string | 
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   632
                        antiAlias ifTrue:[
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   633
                            magnification := nil.
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   634
                        ].
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   635
                        antiAlias := false.
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   636
                        self magnification:(Object readFromString:string)].
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   637
    b initialText:(magnification printString).
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   638
    b showAtPointer
404
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   639
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   640
    "Modified: 2.6.1997 / 15:49:47 / cg"
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   641
!
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   642
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   643
changeMagnificationAndAntiAlias
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   644
    |b|
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   645
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   646
    b := EnterBox new.
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   647
    b title:'magnification (magX @ magY)'.
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   648
    b okText:'apply'.
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   649
    b abortText:'abort'.
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   650
    b action:[:string | 
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   651
                        antiAlias ifFalse:[
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   652
                            magnification := nil.
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   653
                        ].
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   654
                        antiAlias := true.
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   655
                        self magnification:(Object readFromString:string)].
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   656
    b initialText:(magnification printString).
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   657
    b showAtPointer
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   658
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   659
    "Modified: 2.6.1997 / 15:49:58 / cg"
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   660
    "Created: 2.6.1997 / 15:51:01 / cg"
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   661
!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   662
362
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   663
doPrint
405
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   664
    self doPrint:image
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   665
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   666
    "Modified: 2.6.1997 / 18:32:11 / cg"
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   667
!
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   668
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   669
doPrint:anImage
362
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   670
    |stream psgc|
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   671
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   672
    Printer supportsPostscript ifFalse:[
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   673
        self warn:'need a postscript printer'.
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   674
        ^ self
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   675
    ].
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   676
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   677
    stream := Printer newNative.
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   678
    stream isNil ifTrue:[
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   679
        self warn:'cannot open printer stream'.
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   680
        ^ nil
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   681
    ].
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   682
398
7b7255a4db0d show a wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
   683
    self withWaitCursorDo:[
7b7255a4db0d show a wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
   684
        psgc := PSGraphicsContext on:stream. "/  extent:(1.0 @ 1.0).
405
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   685
        psgc displayForm:anImage x:0 y:0.
398
7b7255a4db0d show a wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
   686
        psgc close.
7b7255a4db0d show a wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
   687
    ]
362
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   688
398
7b7255a4db0d show a wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
   689
    "Modified: 28.5.1997 / 10:54:11 / cg"
405
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   690
    "Created: 2.6.1997 / 18:32:03 / cg"
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   691
!
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   692
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   693
doPrintMagnified
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   694
    self doPrint:(magnifiedImage ? image)
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   695
b87623ce20bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   696
    "Modified: 2.6.1997 / 18:31:54 / cg"
362
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   697
!
c8d268d3f431 added 'print' item to menu
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   698
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   699
doSaveImageAs:anImage title:aTitle
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   700
    "save contents into a file 
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   701
     - ask user for filename using a fileSelectionBox."
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   702
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   703
    |fileName defaultName rdr i txt suffix|
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   704
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   705
    defaultName := pathName ? ''.
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   706
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   707
    pathName isNil ifTrue:[
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   708
        suffix := 'tiff'
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   709
    ] ifFalse:[
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   710
        suffix := pathName asFilename suffix.
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   711
        "/ a supported suffix ?
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   712
        ((rdr := Image imageReaderClassForSuffix:suffix) isNil 
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   713
        or:[(rdr canRepresent:anImage) not]) ifTrue:[
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   714
            suffix := 'tiff'.
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   715
            defaultName := (pathName asFilename withSuffix:suffix) pathName
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   716
        ].
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   717
    ].
251
a6e8eb4d7922 save the magnified image.
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   718
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   719
    fileName := Dialog
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   720
                    requestFileName:(resources string:aTitle)
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   721
                    default:defaultName
251
a6e8eb4d7922 save the magnified image.
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   722
                    ok:(resources string:'save')
a6e8eb4d7922 save the magnified image.
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   723
                    abort:(resources string:'abort')
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   724
                    pattern:('*.' , suffix).
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   725
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   726
    fileName notNil ifTrue:[
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   727
        anImage saveOn:fileName.
294
479afb39879a remember last save-name; use as default for saveBox
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
   728
        pathName := fileName.
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   729
    ].
251
a6e8eb4d7922 save the magnified image.
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   730
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   731
    "Created: 20.2.1997 / 18:52:08 / cg"
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   732
    "Modified: 10.4.1997 / 17:49:58 / cg"
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   733
!
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   734
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   735
saveAs
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   736
    "save contents into a file 
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   737
     - ask user for filename using a fileSelectionBox."
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   738
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   739
    self doSaveImageAs:image title:'save image in:'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   740
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   741
    "Modified: 20.2.1997 / 18:52:37 / cg"
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
saveMagnifiedAs
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:magnifiedImage title:'save magnified 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
    "Created: 20.2.1997 / 18:52:53 / 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
saveMagnifiedMaskAs
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 mask) title:'save magnified mask 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:53:31 / cg"
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   760
    "Modified: 20.2.1997 / 18:56:48 / cg"
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
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   763
saveMaskAs
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   764
    "save contents into a file 
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   765
     - ask user for filename using a fileSelectionBox."
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   766
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   767
    self doSaveImageAs:(image mask) title:'save mask in:'
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   768
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   769
    "Created: 20.2.1997 / 18:51:06 / cg"
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   770
    "Modified: 20.2.1997 / 18:56:54 / cg"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   771
!
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   772
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   773
showColors
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   774
    colorPanel isNil ifTrue:[
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   775
        colorPanel := ColorPanel new
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   776
    ].
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   777
    colorPanel shown ifFalse:[
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   778
        colorPanel open
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   779
    ]
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   780
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   781
    "Modified: 10.4.1997 / 17:22:35 / cg"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   782
! !
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   783
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   784
!ImageEditView methodsFor:'queries'!
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   785
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   786
heightOfContents
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   787
    "return the images height"
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   788
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   789
    image isNil ifTrue:[^ 0].
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   790
    ^ (image height * magnification y) rounded
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   791
!
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   792
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   793
widthOfContents
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   794
    "return the images width"
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   795
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   796
    image isNil ifTrue:[^ 0].
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   797
    ^ (image width * magnification x) rounded
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   798
! !
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
   799
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   800
!ImageEditView methodsFor:'release'!
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   801
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   802
destroy
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   803
    colors := nil.
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   804
    magnifiedImage := nil.
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   805
    colorPanel notNil ifTrue:[
26
ff148983c183 *** empty log message ***
claus
parents: 11
diff changeset
   806
	colorPanel destroy.
ff148983c183 *** empty log message ***
claus
parents: 11
diff changeset
   807
	colorPanel := nil.
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   808
    ].
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   809
    super destroy.
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   810
! !
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   811
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   812
!ImageEditView class methodsFor:'documentation'!
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   813
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   814
version
426
2e3dfa527a07 added #negative
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   815
    ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.42 1997-06-20 11:19:07 cg Exp $'
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   816
! !