ImageEditView.st
changeset 4032 f293d37675b5
parent 4000 21106540ffb5
child 4041 2d635ff57406
equal deleted inserted replaced
4031:4213ffa8fc14 4032:f293d37675b5
  1090             self setModified.
  1090             self setModified.
  1091         ]
  1091         ]
  1092     ]
  1092     ]
  1093 
  1093 
  1094     "Modified: / 10.2.2000 / 23:37:04 / cg"
  1094     "Modified: / 10.2.2000 / 23:37:04 / cg"
       
  1095 !
       
  1096 
       
  1097 flipSubImage:how in:imageBox
       
  1098     "/ now, do it
       
  1099 
       
  1100     |x0 y0 x1 y1 image t|
       
  1101 
       
  1102     x0 := imageBox left.
       
  1103     y0 := imageBox top.
       
  1104     x1 := imageBox right-1.
       
  1105     y1 := imageBox bottom-1.
       
  1106 
       
  1107     image := self image.
       
  1108 
       
  1109     how == #vertical ifTrue:[
       
  1110         0 to:((y1-y0)//2) do:[:dy |
       
  1111             x0 to:x1 do:[:x |
       
  1112                 t := image pixelAtX:x y:(y0+dy).
       
  1113                 image pixelAtX:x y:(y0+dy) put:(image pixelAtX:x y:(y1-dy)).
       
  1114                 image pixelAtX:x y:(y1-dy) put:t.
       
  1115             ].
       
  1116         ]
       
  1117     ] ifFalse:[
       
  1118         0 to:((x1-x0)//2) do:[:dx |
       
  1119             y0 to:y1 do:[:y |
       
  1120                 t := image pixelAtX:(x0+dx) y:y.
       
  1121                 image pixelAtX:(x0+dx) y:y put:(image pixelAtX:(x1-dx) y:y).
       
  1122                 image pixelAtX:(x1-dx) y:y put:t.
       
  1123             ].
       
  1124         ]
       
  1125     ].
       
  1126 
       
  1127     self setModified.
       
  1128 
       
  1129     "Created: / 07-04-2011 / 09:34:23 / cg"
  1095 !
  1130 !
  1096 
  1131 
  1097 magnifyImageTo:newSize
  1132 magnifyImageTo:newSize
  1098     self makeUndo.
  1133     self makeUndo.
  1099     self image: (image magnifiedBy: newSize/image extent).
  1134     self image: (image magnifiedBy: newSize/image extent).
  1460     operation := Dialog 
  1495     operation := Dialog 
  1461            choose:(resources string:'Which Operation:')
  1496            choose:(resources string:'Which Operation:')
  1462            fromList:(resources array:#(
  1497            fromList:(resources array:#(
  1463                        'edit separately'
  1498                        'edit separately'
  1464                        '-'
  1499                        '-'
       
  1500                        'flip vertical'
       
  1501                        'flip horizontal'
       
  1502                        '-'
  1465                        'slightly brightened'
  1503                        'slightly brightened'
  1466                        'slightly darkened'
  1504                        'slightly darkened'
  1467                        'brightened'
  1505                        'brightened'
  1468                        'darkened'
  1506                        'darkened'
  1469                        '-'
  1507                        '-'
  1476                        '-'
  1514                        '-'
  1477                        'change hue'
  1515                        'change hue'
  1478                        'colorize'
  1516                        'colorize'
  1479                      )) 
  1517                      )) 
  1480            values:#(edit nil
  1518            values:#(edit nil
  1481                     slightlyBrightened slightlyDarkened brightened darkened 
  1519                     flipVertical flipHorizontal nil
  1482                     nil makeGrey greyed greyPattern unmaskedGreyPattern
  1520                     slightlyBrightened slightlyDarkened brightened darkened nil 
  1483                     nil reversed nil changeHue colorize) 
  1521                     makeGrey greyed greyPattern unmaskedGreyPattern nil 
       
  1522                     reversed nil 
       
  1523                     changeHue colorize) 
  1484            lines:6
  1524            lines:6
  1485            cancel:nil.
  1525            cancel:nil.
  1486 
  1526 
  1487     self invalidate.
  1527     self invalidate.
  1488     self windowGroup processExposeEvents.
  1528     self windowGroup processExposeEvents.
  1496 
  1536 
  1497     operation == #edit ifTrue:[
  1537     operation == #edit ifTrue:[
  1498         (self image subImageIn:imageBox) edit.
  1538         (self image subImageIn:imageBox) edit.
  1499         ^ false.
  1539         ^ false.
  1500     ].
  1540     ].
       
  1541     operation == #flipVertical ifTrue:[
       
  1542         self flipSubImage:#vertical in:imageBox.
       
  1543         ^ true.
       
  1544     ].
       
  1545     operation == #flipHorizontal ifTrue:[
       
  1546         self flipSubImage:#horizontal in:imageBox.
       
  1547         ^ true.
       
  1548     ].
       
  1549 
  1501     operation == #slightlyBrightened ifTrue:[
  1550     operation == #slightlyBrightened ifTrue:[
  1502         pixelAction := [:x :y :clr | clr slightlyLightened].
  1551         pixelAction := [:x :y :clr | clr slightlyLightened].
  1503     ].
  1552     ].
  1504     operation == #slightlyDarkened ifTrue:[
  1553     operation == #slightlyDarkened ifTrue:[
  1505         pixelAction := [:x :y :clr | clr slightlyDarkened].
  1554         pixelAction := [:x :y :clr | clr slightlyDarkened].
  1592             self image colorAtX:x y:y put:newClr
  1641             self image colorAtX:x y:y put:newClr
  1593         ].
  1642         ].
  1594 
  1643 
  1595     self setModified.
  1644     self setModified.
  1596     ^ true.
  1645     ^ true.
       
  1646 
       
  1647     "Modified: / 07-04-2011 / 09:28:20 / cg"
  1597 !
  1648 !
  1598 
  1649 
  1599 pointAt:aPoint
  1650 pointAt:aPoint
  1600     "draw a single pixel with the currently selected color"
  1651     "draw a single pixel with the currently selected color"
  1601 
  1652 
  2669 ! !
  2720 ! !
  2670 
  2721 
  2671 !ImageEditView class methodsFor:'documentation'!
  2722 !ImageEditView class methodsFor:'documentation'!
  2672 
  2723 
  2673 version
  2724 version
  2674     ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.245 2011-01-31 17:32:01 cg Exp $'
  2725     ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.246 2011-04-07 07:35:08 cg Exp $'
  2675 !
  2726 !
  2676 
  2727 
  2677 version_CVS
  2728 version_CVS
  2678     ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.245 2011-01-31 17:32:01 cg Exp $'
  2729     ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.246 2011-04-07 07:35:08 cg Exp $'
  2679 ! !
  2730 ! !
  2680 
  2731 
  2681 ImageEditView initialize!
  2732 ImageEditView initialize!