9 other person. No title to or ownership of the software is |
9 other person. No title to or ownership of the software is |
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 |
12 |
13 ToolApplicationModel subclass:#ImageEditor |
13 ToolApplicationModel subclass:#ImageEditor |
14 instanceVariableNames:'imageEditView colorMapMode selectedColorIndex postOpenAction' |
14 instanceVariableNames:'imageEditView colorMapMode selectedColorIndex postOpenAction' |
15 classVariableNames:'' |
15 classVariableNames:'' |
16 poolDictionaries:'' |
16 poolDictionaries:'' |
17 category:'Interface-UIPainter' |
17 category:'Interface-UIPainter' |
18 ! |
18 ! |
19 |
19 |
20 !ImageEditor class methodsFor:'documentation'! |
20 !ImageEditor class methodsFor:'documentation'! |
21 |
21 |
22 copyright |
22 copyright |
420 |
425 |
421 #(#FullSpec |
426 #(#FullSpec |
422 #window: |
427 #window: |
423 #(#WindowSpec |
428 #(#WindowSpec |
424 #name: 'Image Editor' |
429 #name: 'Image Editor' |
425 #layout: #(#LayoutFrame 176 0 156 0 675 0 501 0) |
430 #layout: #(#LayoutFrame 216 0 173 0 715 0 518 0) |
426 #label: 'Image Editor' |
431 #label: 'Image Editor' |
427 #min: #(#Point 400 320) |
432 #min: #(#Point 400 320) |
428 #max: #(#Point 1152 900) |
433 #max: #(#Point 1152 900) |
429 #bounds: #(#Rectangle 176 156 676 502) |
434 #bounds: #(#Rectangle 216 173 716 519) |
430 #menu: #menu |
435 #menu: #menu |
431 #usePreferredExtent: false |
436 #usePreferredExtent: false |
432 ) |
437 ) |
433 #component: |
438 #component: |
434 #(#SpecCollection |
439 #(#SpecCollection |
480 #style: #(#FontDescription #helvetica #medium #roman 10) |
485 #style: #(#FontDescription #helvetica #medium #roman 10) |
481 #hasHorizontalScrollBar: true |
486 #hasHorizontalScrollBar: true |
482 #hasVerticalScrollBar: true |
487 #hasVerticalScrollBar: true |
483 #miniScrollerHorizontal: true |
488 #miniScrollerHorizontal: true |
484 #miniScrollerVertical: true |
489 #miniScrollerVertical: true |
485 "/ #level: -1 |
|
486 #dataList: #listOfColors |
490 #dataList: #listOfColors |
487 #has3Dsepartors: true |
491 #has3Dsepartors: true |
488 #has3Dseparators: true |
492 #has3Dseparators: true |
489 #verticalSpacing: 1 |
493 #verticalSpacing: 1 |
490 #columns: |
494 #columns: |
1101 ^(builder componentAt: #imagePreView) subViews first |
1106 ^(builder componentAt: #imagePreView) subViews first |
1102 ! ! |
1107 ! ! |
1103 |
1108 |
1104 !ImageEditor methodsFor:'aspects'! |
1109 !ImageEditor methodsFor:'aspects'! |
1105 |
1110 |
|
1111 activityInfoHolder |
|
1112 ^ self valueOfInfoLabel |
|
1113 |
|
1114 "Modified: / 29.7.1998 / 18:49:03 / cg" |
|
1115 ! |
|
1116 |
1106 colorColumnAdaptor |
1117 colorColumnAdaptor |
1107 ^ self |
1118 ^ self |
1108 |
1119 |
1109 "Created: / 26.7.1998 / 12:17:03 / cg" |
1120 "Created: / 26.7.1998 / 12:17:03 / cg" |
|
1121 ! |
|
1122 |
|
1123 imageInfoHolder |
|
1124 |holder| |
|
1125 (holder := builder bindingAt:#imageInfoHolder) isNil ifTrue:[ |
|
1126 builder aspectAt:#imageInfoHolder put:(holder := '' asValue). |
|
1127 ]. |
|
1128 ^ holder |
|
1129 |
|
1130 "Modified: / 29.7.1998 / 18:32:08 / cg" |
1110 ! |
1131 ! |
1111 |
1132 |
1112 imageIsLoaded |
1133 imageIsLoaded |
1113 "returns whether an image is loaded as value holder" |
1134 "returns whether an image is loaded as value holder" |
1114 |
1135 |
1448 postOpenWith:aBuilder |
1468 postOpenWith:aBuilder |
1449 "after opening, sets the masterApplication of the imageEditView to self; |
1469 "after opening, sets the masterApplication of the imageEditView to self; |
1450 evaluate the postOpenAction" |
1470 evaluate the postOpenAction" |
1451 |
1471 |
1452 imageEditView masterApplication: self. |
1472 imageEditView masterApplication: self. |
|
1473 imageEditView imageInfoHolder:(self imageInfoHolder). |
|
1474 imageEditView activityInfoHolder:(self activityInfoHolder). |
|
1475 |
1453 postOpenAction notNil ifTrue: [postOpenAction value]. |
1476 postOpenAction notNil ifTrue: [postOpenAction value]. |
1454 |
1477 |
1455 super postOpenWith:aBuilder |
1478 super postOpenWith:aBuilder |
1456 |
1479 |
1457 "Modified: / 26.7.1998 / 12:32:55 / cg" |
1480 "Modified: / 29.7.1998 / 18:49:20 / cg" |
1458 ! ! |
1481 ! ! |
1459 |
1482 |
1460 !ImageEditor methodsFor:'user actions - colormap'! |
1483 !ImageEditor methodsFor:'user actions - colormap'! |
1461 |
1484 |
1462 colorMapMode:aMode value: aValue |
1485 colorMapMode:aMode value: aValue |
1463 "calculates a new color map for the image from aMode" |
1486 "calculates a new color map for the image from aMode" |
1464 |
1487 |
1465 |depth numColors newColorMap newImage |
1488 |depth numColors newColorMap newImage |
1466 oldImage image newColors realColorMap oldFileName |
1489 oldImage image newColors realColorMap oldFileName |
1467 usedColors useNearest usageCounts tmpBits tmpMap| |
1490 usedColors useNearest usageCounts tmpBits tmpMap quest| |
1468 |
1491 |
1469 self withExecuteCursorDo:[ |
1492 self withExecuteCursorDo:[ |
1470 oldImage := self image. |
1493 oldImage := self image. |
1471 |
1494 |
1472 newColorMap := self class listOfColorMaps at:aMode. |
1495 newColorMap := self class listOfColorMaps at:aMode. |
1473 depth := (newColorMap size log: 2) asInteger. |
1496 depth := (newColorMap size log: 2) asInteger. |
1474 |
1497 |
1475 useNearest := false. |
1498 useNearest := false. |
1476 (self confirm:'Keep colormap (or use standard)') ifTrue:[ |
1499 depth == 1 ifTrue:[ |
|
1500 quest := 'Keep colormap (or use standard B&W)' |
|
1501 ] ifFalse:[ |
|
1502 quest := 'Keep colormap (or use standard)' |
|
1503 ]. |
|
1504 (self confirm:(resources string:quest)) ifTrue:[ |
1477 "/ keep the colormap |
1505 "/ keep the colormap |
1478 depth > oldImage depth ifTrue:[ |
1506 depth > oldImage depth ifTrue:[ |
1479 "/ easy - simply copy the part |
1507 "/ easy - simply copy the part |
1480 numColors := 1 bitShift:oldImage depth. |
1508 numColors := 1 bitShift:oldImage depth. |
1481 0 to:numColors-1 do:[:pixel | |
1509 0 to:numColors-1 do:[:pixel | |
1512 1 to:(1 bitShift:depth) do:[:idx | |
1540 1 to:(1 bitShift:depth) do:[:idx | |
1513 newColorMap at:idx put:(tmpMap at:idx) |
1541 newColorMap at:idx put:(tmpMap at:idx) |
1514 ]. |
1542 ]. |
1515 |
1543 |
1516 useNearest := Dialog |
1544 useNearest := Dialog |
1517 confirmWithCancel:('Image requires %1 colors.\ColorMap has only space for %2\\Use nearest (or map to black) ?' |
1545 confirmWithCancel:(resources |
1518 bindWith:usedColors size |
1546 string:'Image requires %1 colors.\ColorMap has only space for %2\\Use nearest (or map to first color) ?' |
1519 with:(1 bitShift:depth)) withCRs |
1547 with:usedColors size |
1520 labels:#('cancel' 'black' 'nearest'). |
1548 with:(1 bitShift:depth)) withCRs |
|
1549 labels:(resources array:#('cancel' 'first' 'nearest')). |
1521 useNearest isNil ifTrue:[ |
1550 useNearest isNil ifTrue:[ |
1522 ^ self "/ cancel |
1551 ^ self "/ cancel |
1523 ]. |
1552 ]. |
1524 ] |
1553 ] |
1525 ] |
1554 ] |
1526 ] ifFalse:[ |
1555 ] ifFalse:[ |
1527 "/ standard colormap |
1556 "/ standard colormap |
1528 usedColors := oldImage usedColors. |
1557 usedColors := oldImage usedColors. |
1529 (usedColors conform:[:clr | newColorMap includes:clr]) ifFalse:[ |
1558 (usedColors conform:[:clr | newColorMap includes:clr]) ifFalse:[ |
1530 useNearest := Dialog |
1559 useNearest := Dialog |
1531 confirmWithCancel:('Not all colors are present in the new colormap.\\Map missing ones to nearest (or map to black) ?' |
1560 confirmWithCancel:(resources |
|
1561 string:'Not all colors are present in the new colormap.\\Map missing ones to nearest (or map to first color) ?' |
1532 ) withCRs |
1562 ) withCRs |
1533 labels:#('cancel' 'black' 'nearest'). |
1563 labels:(resources string:#('cancel' 'first' 'nearest')). |
1534 useNearest isNil ifTrue:[ |
1564 useNearest isNil ifTrue:[ |
1535 ^ self "/ cancel |
1565 ^ self "/ cancel |
1536 ]. |
1566 ]. |
1537 ]. |
1567 ]. |
1538 ]. |
1568 ]. |