187 'ColorMap functions.' |
187 'ColorMap functions.' |
188 |
188 |
189 #colorMap1 |
189 #colorMap1 |
190 'Convert to depth-1 image.' |
190 'Convert to depth-1 image.' |
191 |
191 |
|
192 #colorMap1M |
|
193 'Convert to depth-1 image plus mask.' |
|
194 |
192 #colorMap2 |
195 #colorMap2 |
193 'Convert to depth-2 image.' |
196 'Convert to depth-2 image.' |
194 |
197 |
|
198 #colorMap2M |
|
199 'Convert to depth-2 image plus mask.' |
|
200 |
195 #colorMap4 |
201 #colorMap4 |
196 'Convert to depth-4 image.' |
202 'Convert to depth-4 image.' |
197 |
203 |
|
204 #colorMap4M |
|
205 'Convert to depth-4 image plus mask.' |
|
206 |
198 #colorMap8 |
207 #colorMap8 |
199 'Convert to depth-8 image.' |
208 'Convert to depth-8 image.' |
200 |
209 |
201 #colorMap1M |
|
202 'Convert to depth-1 image plus mask.' |
|
203 |
|
204 #colorMap2M |
|
205 'Convert to depth-2 image plus mask.' |
|
206 |
|
207 #colorMap4M |
|
208 'Convert to depth-4 image plus mask.' |
|
209 |
|
210 #colorMap8M |
210 #colorMap8M |
211 'Convert to depth-8 image plus mask.' |
211 'Convert to depth-8 image plus mask.' |
212 |
212 |
|
213 #colorMapTable |
|
214 'Shows a list of used colors of the image.' |
|
215 |
213 #compressColormap |
216 #compressColormap |
214 'Remove unneeded entries from the colorMap.' |
217 'Remove unneeded entries from the colorMap.' |
215 |
218 |
216 #colorMapTable |
219 #crobAll |
217 'Shows a list of used colors of the image.' |
220 'Find and remove all borders.' |
|
221 |
|
222 #crobBottom |
|
223 'Find and remove bottom border.' |
|
224 |
|
225 #crobLeft |
|
226 'Find and remove left border.' |
|
227 |
|
228 #crobManual |
|
229 'Specify border(s) to remove.' |
|
230 |
|
231 #crobRight |
|
232 'Find and remove right border.' |
|
233 |
|
234 #crobTop |
|
235 'Find and remove top border.' |
218 |
236 |
219 #drawModeBox |
237 #drawModeBox |
220 'Switches to box-drawing mode.' |
238 'Switches to box-drawing mode.' |
221 |
239 |
222 #drawModeCopy |
240 #drawModeCopy |
434 #minorKey: #windowSpecForCommitWithoutChannels |
449 #minorKey: #windowSpecForCommitWithoutChannels |
435 ) |
450 ) |
436 ) |
451 ) |
437 ) |
452 ) |
438 ) |
453 ) |
|
454 ! |
|
455 |
|
456 grobDialogSpec |
|
457 "This resource specification was automatically generated |
|
458 by the UIPainter of ST/X." |
|
459 |
|
460 "Do not manually edit this!! If it is corrupted, |
|
461 the UIPainter may not be able to read the specification." |
|
462 |
|
463 " |
|
464 UIPainter new openOnClass:ImageEditor andSelector:#grobDialogSpec |
|
465 ImageEditor new openInterface:#grobDialogSpec |
|
466 " |
|
467 |
|
468 <resource: #canvas> |
|
469 |
|
470 ^ |
|
471 |
|
472 #(#FullSpec |
|
473 #window: |
|
474 #(#WindowSpec |
|
475 #name: 'Crob Borders' |
|
476 #layout: #(#LayoutFrame 22 0 233 0 266 0 415 0) |
|
477 #label: 'Crob Borders' |
|
478 #min: #(#Point 10 10) |
|
479 #max: #(#Point 800 478) |
|
480 #bounds: #(#Rectangle 22 233 267 416) |
|
481 #usePreferredExtent: false |
|
482 ) |
|
483 #component: |
|
484 #(#SpecCollection |
|
485 #collection: |
|
486 #( |
|
487 #(#LabelSpec |
|
488 #name: 'Label1' |
|
489 #layout: #(#LayoutFrame 14 0 21 0 90 0 43 0) |
|
490 #label: 'Left:' |
|
491 #translateLabel: true |
|
492 #adjust: #right |
|
493 ) |
|
494 #(#InputFieldSpec |
|
495 #name: 'EntryField1' |
|
496 #layout: #(#LayoutFrame 95 0 21 0 132 0 43 0) |
|
497 #model: #left |
|
498 #type: #number |
|
499 ) |
|
500 #(#LabelSpec |
|
501 #name: 'Label2' |
|
502 #layout: #(#LayoutFrame 14 0 51 0 90 0 73 0) |
|
503 #label: 'Right:' |
|
504 #translateLabel: true |
|
505 #adjust: #right |
|
506 ) |
|
507 #(#InputFieldSpec |
|
508 #name: 'EntryField2' |
|
509 #layout: #(#LayoutFrame 95 0 51 0 132 0 73 0) |
|
510 #model: #right |
|
511 #type: #number |
|
512 ) |
|
513 #(#LabelSpec |
|
514 #name: 'Label3' |
|
515 #layout: #(#LayoutFrame 14 0 81 0 90 0 103 0) |
|
516 #label: 'Top:' |
|
517 #translateLabel: true |
|
518 #adjust: #right |
|
519 ) |
|
520 #(#InputFieldSpec |
|
521 #name: 'EntryField3' |
|
522 #layout: #(#LayoutFrame 95 0 81 0 132 0 103 0) |
|
523 #model: #top |
|
524 #type: #number |
|
525 ) |
|
526 #(#LabelSpec |
|
527 #name: 'Label4' |
|
528 #layout: #(#LayoutFrame 14 0 111 0 90 0 133 0) |
|
529 #label: 'Bottom:' |
|
530 #translateLabel: true |
|
531 #adjust: #right |
|
532 ) |
|
533 #(#InputFieldSpec |
|
534 #name: 'EntryField4' |
|
535 #layout: #(#LayoutFrame 95 0 111 0 132 0 133 0) |
|
536 #model: #bottom |
|
537 #type: #number |
|
538 ) |
|
539 #(#HorizontalPanelViewSpec |
|
540 #name: 'HorizontalPanel1' |
|
541 #layout: #(#LayoutFrame 0 0.0 -30 1 0 1.0 0 1) |
|
542 #component: |
|
543 #(#SpecCollection |
|
544 #collection: |
|
545 #( |
|
546 #(#ActionButtonSpec |
|
547 #name: 'Button1' |
|
548 #label: 'Cancel' |
|
549 #translateLabel: true |
|
550 #model: #cancel |
|
551 #extent: #(#Point 118 22) |
|
552 ) |
|
553 #(#ActionButtonSpec |
|
554 #name: 'Button2' |
|
555 #label: 'OK' |
|
556 #translateLabel: true |
|
557 #model: #accept |
|
558 #extent: #(#Point 118 22) |
|
559 ) |
|
560 ) |
|
561 ) |
|
562 #horizontalLayout: #fitSpace |
|
563 #verticalLayout: #center |
|
564 #horizontalSpace: 3 |
|
565 #verticalSpace: 3 |
|
566 ) |
|
567 ) |
|
568 ) |
|
569 ) |
|
570 |
|
571 "Modified: / 7.9.1998 / 18:29:34 / cg" |
439 ! |
572 ! |
440 |
573 |
441 windowSpec |
574 windowSpec |
442 "This resource specification was automatically generated |
575 "This resource specification was automatically generated |
443 by the UIPainter of ST/X." |
576 by the UIPainter of ST/X." |
836 #label: 'Rotate...' |
969 #label: 'Rotate...' |
837 #translateLabel: true |
970 #translateLabel: true |
838 #value: #doRotateImage |
971 #value: #doRotateImage |
839 #activeHelpKey: #editRotate |
972 #activeHelpKey: #editRotate |
840 ) |
973 ) |
|
974 #(#MenuItem |
|
975 #label: '-' |
|
976 ) |
|
977 #(#MenuItem |
|
978 #label: 'Crob' |
|
979 #translateLabel: true |
|
980 #submenu: |
|
981 #(#Menu |
|
982 |
|
983 #( |
|
984 #(#MenuItem |
|
985 #label: 'All' |
|
986 #translateLabel: true |
|
987 #value: #doCrobAll |
|
988 #activeHelpKey: #crobAll |
|
989 ) |
|
990 #(#MenuItem |
|
991 #label: '-' |
|
992 ) |
|
993 #(#MenuItem |
|
994 #label: 'Left' |
|
995 #translateLabel: true |
|
996 #value: #doCrobLeft |
|
997 #activeHelpKey: #crobLeft |
|
998 ) |
|
999 #(#MenuItem |
|
1000 #label: 'Right' |
|
1001 #translateLabel: true |
|
1002 #value: #doCrobRight |
|
1003 #activeHelpKey: #crobRight |
|
1004 ) |
|
1005 #(#MenuItem |
|
1006 #label: 'Top' |
|
1007 #translateLabel: true |
|
1008 #value: #doCrobTop |
|
1009 #activeHelpKey: #crobTop |
|
1010 ) |
|
1011 #(#MenuItem |
|
1012 #label: 'Bottom' |
|
1013 #translateLabel: true |
|
1014 #value: #doCrobBottom |
|
1015 #activeHelpKey: #crobBottom |
|
1016 ) |
|
1017 #(#MenuItem |
|
1018 #label: '-' |
|
1019 ) |
|
1020 #(#MenuItem |
|
1021 #label: 'Manual...' |
|
1022 #translateLabel: true |
|
1023 #value: #doCrobManual |
|
1024 #activeHelpKey: #crobManual |
|
1025 ) |
|
1026 ) nil |
|
1027 nil |
|
1028 ) |
|
1029 ) |
841 ) nil |
1030 ) nil |
842 nil |
1031 nil |
843 ) |
1032 ) |
844 ) |
1033 ) |
845 #(#MenuItem |
1034 #(#MenuItem |
1706 0 to:numColors-1 do:[:pixel | |
1897 0 to:numColors-1 do:[:pixel | |
1707 newColorMap at:(pixel+1) put:(oldImage colorFromValue:pixel) |
1898 newColorMap at:(pixel+1) put:(oldImage colorFromValue:pixel) |
1708 ]. |
1899 ]. |
1709 ] ifFalse:[ |
1900 ] ifFalse:[ |
1710 "/ see if all used color fit the new colormap |
1901 "/ see if all used color fit the new colormap |
1711 usedColors := oldImage usedColors asArray. |
1902 usedColors := oldImage usedColorsMax:(1 bitShift:depth). |
1712 usedColors size <= (1 bitShift:depth) ifTrue:[ |
1903 (usedColors notNil and:[usedColors size <= (1 bitShift:depth)]) ifTrue:[ |
1713 "/ yea - just install them |
1904 "/ yea - just install them |
1714 usedColors keysAndValuesDo:[:idx :clr | |
1905 usedColors asArray keysAndValuesDo:[:idx :clr | |
1715 newColorMap at:idx put:clr |
1906 newColorMap at:idx put:clr |
1716 ] |
1907 ] |
1717 ] ifFalse:[ |
1908 ] ifFalse:[ |
1718 "/ copy over those that are most often used. |
1909 "/ copy over those that are most often used. |
1719 oldImage depth ~~ 8 ifTrue:[ |
1910 oldImage depth < 8 ifTrue:[ |
1720 tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height). |
1911 tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height). |
1721 oldImage bits |
1912 oldImage bits |
1722 expandPixels:(oldImage depth) |
1913 expandPixels:(oldImage depth) |
1723 width:oldImage width |
1914 width:oldImage width |
1724 height:oldImage height |
1915 height:oldImage height |
1725 into:tmpBits |
1916 into:tmpBits |
1726 mapping:nil. |
1917 mapping:nil. |
1727 ] ifFalse:[ |
1918 ] ifFalse:[ |
1728 tmpBits := oldImage bits |
1919 oldImage depth == 8 ifTrue:[ |
|
1920 tmpBits := oldImage bits |
|
1921 ] ifFalse:[ |
|
1922 self warn:'Too many colors in image.'. |
|
1923 ^ self |
|
1924 ] |
1729 ]. |
1925 ]. |
1730 usageCounts := tmpBits usageCounts. |
1926 usageCounts := tmpBits usageCounts. |
1731 tmpMap := Array new:usageCounts size. |
1927 tmpMap := Array new:usageCounts size. |
1732 oldImage colorMap asArray keysAndValuesDo:[:i :clr | |
1928 oldImage colorMap asArray keysAndValuesDo:[:i :clr | |
1733 tmpMap at:i put:clr |
1929 tmpMap at:i put:clr |
1958 "change grid magnification" |
2154 "change grid magnification" |
1959 |
2155 |
1960 imageEditView changeGridMagnification |
2156 imageEditView changeGridMagnification |
1961 ! |
2157 ! |
1962 |
2158 |
|
2159 doCrobAll |
|
2160 "find all borders and cut them off" |
|
2161 |
|
2162 imageEditView crobLeft:true right:true top:true bottom:true. |
|
2163 self updateInfoLabel |
|
2164 |
|
2165 "Modified: / 7.9.1998 / 14:26:23 / cg" |
|
2166 "Created: / 7.9.1998 / 16:33:43 / cg" |
|
2167 ! |
|
2168 |
|
2169 doCrobBottom |
|
2170 "find a bottom border and cut it off" |
|
2171 |
|
2172 imageEditView crobLeft:false right:false top:false bottom:true. |
|
2173 self updateInfoLabel |
|
2174 |
|
2175 "Created: / 7.9.1998 / 13:00:20 / cg" |
|
2176 "Modified: / 7.9.1998 / 14:26:23 / cg" |
|
2177 ! |
|
2178 |
|
2179 doCrobLeft |
|
2180 "find a left border and cut it off" |
|
2181 |
|
2182 imageEditView crobLeft:true right:false top:false bottom:false. |
|
2183 self updateInfoLabel |
|
2184 |
|
2185 "Created: / 7.9.1998 / 13:00:14 / cg" |
|
2186 "Modified: / 7.9.1998 / 14:26:34 / cg" |
|
2187 ! |
|
2188 |
|
2189 doCrobManual |
|
2190 "let user specify borders and cut them off" |
|
2191 |
|
2192 |bindings left top right bottom| |
|
2193 |
|
2194 bindings := IdentityDictionary new. |
|
2195 bindings at:#left put:(left := 0 asValue). |
|
2196 bindings at:#right put:(right := 0 asValue). |
|
2197 bindings at:#top put:(top := 0 asValue). |
|
2198 bindings at:#bottom put:(bottom := 0 asValue). |
|
2199 (self openDialogInterface:#grobDialogSpec withBindings:bindings) |
|
2200 ifTrue:[ |
|
2201 left := left value. |
|
2202 right := right value. |
|
2203 top := top value. |
|
2204 bottom := bottom value. |
|
2205 imageEditView |
|
2206 makeSubImageX:left y:top |
|
2207 width:(imageEditView image width - left - right) |
|
2208 height:(imageEditView image height - top - bottom). |
|
2209 self updateInfoLabel |
|
2210 ]. |
|
2211 |
|
2212 "Created: / 7.9.1998 / 18:16:07 / cg" |
|
2213 "Modified: / 7.9.1998 / 18:20:42 / cg" |
|
2214 ! |
|
2215 |
|
2216 doCrobRight |
|
2217 "find a right border and cut it off" |
|
2218 |
|
2219 imageEditView crobLeft:false right:true top:false bottom:false. |
|
2220 self updateInfoLabel |
|
2221 |
|
2222 "Created: / 7.9.1998 / 13:00:14 / cg" |
|
2223 "Modified: / 7.9.1998 / 14:26:44 / cg" |
|
2224 ! |
|
2225 |
|
2226 doCrobTop |
|
2227 "find a top border and cut it off" |
|
2228 |
|
2229 imageEditView crobLeft:false right:false top:true bottom:false. |
|
2230 self updateInfoLabel |
|
2231 |
|
2232 "Created: / 7.9.1998 / 13:00:19 / cg" |
|
2233 "Modified: / 7.9.1998 / 14:26:52 / cg" |
|
2234 ! |
|
2235 |
1963 doFlipHorizontal |
2236 doFlipHorizontal |
1964 "flips horizontally current image" |
2237 "flips horizontally current image" |
1965 |
2238 |
1966 imageEditView flipHorizontal |
2239 imageEditView flipHorizontal |
1967 ! |
2240 ! |