5504 |
5504 |
5505 resourceClass := imageEditView resourceClass. |
5505 resourceClass := imageEditView resourceClass. |
5506 resourceClass notNil ifTrue:[ |
5506 resourceClass notNil ifTrue:[ |
5507 resourceSelector := imageEditView resourceSelector. |
5507 resourceSelector := imageEditView resourceSelector. |
5508 resourceSelector notNil ifTrue:[ |
5508 resourceSelector notNil ifTrue:[ |
5509 ^ resourceClass name, ' » ', resourceSelector |
5509 ^ resources |
|
5510 string:(self modified |
|
5511 ifTrue:['Image (modified) from: %1 » %2'] |
|
5512 ifFalse:['Image from: %1 » %2']) |
|
5513 with:resourceClass name |
|
5514 with:resourceSelector |
5510 ]. |
5515 ]. |
5511 ]. |
5516 ]. |
5512 |
5517 |
5513 (img := imageEditView image) notNil ifTrue:[ |
5518 (img := imageEditView image) notNil ifTrue:[ |
5514 img fileName notNil ifTrue:[ |
5519 img fileName notNil ifTrue:[ |
5515 ^ resources string:'Image from: %1.' with:(img fileName asFilename baseName). |
5520 ^ resources |
|
5521 string:(self modified |
|
5522 ifTrue:['Image (modified) from: %1'] |
|
5523 ifFalse:['Image from: %1']) |
|
5524 with:(img fileName asFilename baseName). |
5516 ]. |
5525 ]. |
5517 ]. |
5526 ]. |
5518 ^ resources string:'No class and selector defined.' |
5527 ^ resources string:'No class and selector defined.' |
5519 |
5528 |
5520 "Modified: / 27-08-2017 / 15:02:52 / cg" |
5529 "Modified: / 29-08-2017 / 19:47:25 / cg" |
5521 ! |
5530 ! |
5522 |
5531 |
5523 openDocumentation |
5532 openDocumentation |
5524 "opens the documentation file of the Image Editor" |
5533 "opens the documentation file of the Image Editor" |
5525 |
5534 |
7526 "Created: / 07-07-2006 / 13:22:10 / cg" |
7535 "Created: / 07-07-2006 / 13:22:10 / cg" |
7527 "Modified: / 24-08-2017 / 17:06:00 / cg" |
7536 "Modified: / 24-08-2017 / 17:06:00 / cg" |
7528 ! |
7537 ! |
7529 |
7538 |
7530 ditherToDepth:depth |
7539 ditherToDepth:depth |
7531 |ditherColors useStandardColors nGrey greyColorsAlready moreColors d| |
7540 |ditherColors computeNewColormap nGrey greyColorsAlready moreColors d| |
7532 |
7541 |
7533 useStandardColors := true. |
7542 computeNewColormap := Dialog |
7534 "/ useStandardColors := Dialog confirmWithCancel:'Dither in standard colors or use a new (optimized) colormap ?'. |
7543 confirmWithCancel:'Compute a new (optimized) colormap?\\(or else use a standard colormap)\\Warning: this may take some time...' withCRs |
7535 "/ useStandardColors isNil ifTrue:[^ self]. |
7544 default:false. |
7536 |
7545 computeNewColormap isNil ifTrue:[^ self]. |
7537 useStandardColors ifTrue:[ |
7546 |
|
7547 computeNewColormap ifFalse:[ |
7538 depth = 1 ifTrue:[ |
7548 depth = 1 ifTrue:[ |
7539 ditherColors := Array with:(Color black) with:(Color white). |
7549 ditherColors := Array with:(Color black) with:(Color white). |
7540 ] ifFalse:[ depth = 2 ifTrue:[ |
7550 ] ifFalse:[ depth = 2 ifTrue:[ |
7541 ditherColors := Array |
7551 ditherColors := Array |
7542 with:(Color black) |
7552 with:(Color black) |
7546 ] ifFalse:[ depth = 3 ifTrue:[ |
7556 ] ifFalse:[ depth = 3 ifTrue:[ |
7547 ditherColors := Color colorCubeWithRed:2 green:2 blue:2. |
7557 ditherColors := Color colorCubeWithRed:2 green:2 blue:2. |
7548 ] ifFalse:[ depth = 4 ifTrue:[ |
7558 ] ifFalse:[ depth = 4 ifTrue:[ |
7549 ditherColors := Color vgaColors. |
7559 ditherColors := Color vgaColors. |
7550 ] ifFalse:[ depth = 5 ifTrue:[ |
7560 ] ifFalse:[ depth = 5 ifTrue:[ |
7551 ditherColors := Color colorCubeWithRed:4 green:4 blue:2. |
7561 ditherColors := Color colorCubeWithRed:3 green:4 blue:2. |
7552 ] ifFalse:[ depth = 6 ifTrue:[ |
7562 ] ifFalse:[ depth = 6 ifTrue:[ |
7553 ditherColors := Color colorCubeWithRed:4 green:4 blue:3. |
7563 ditherColors := Color colorCubeWithRed:4 green:4 blue:3. |
7554 ] ifFalse:[ depth <= 8 ifTrue:[ |
7564 ] ifFalse:[ depth = 7 ifTrue:[ |
7555 ditherColors := Color colorCubeWithRed:6 green:6 blue:5. |
7565 ditherColors := Color colorCubeWithRed:5 green:5 blue:4. |
|
7566 ] ifFalse:[ depth == 8 ifTrue:[ |
|
7567 ditherColors := Color standardDitherColorsForDepth8. |
7556 ] ifFalse:[ |
7568 ] ifFalse:[ |
7557 self error:'unsupported depth'. |
7569 self error:'unsupported depth'. |
7558 ]]]]]]]. |
7570 ]]]]]]]]. |
7559 |
7571 |
|
7572 "/ add as many gray colors as possible. |
7560 nGrey := (2 raisedTo:depth) - ditherColors size. |
7573 nGrey := (2 raisedTo:depth) - ditherColors size. |
7561 nGrey > 0 ifTrue:[ |
7574 nGrey > 0 ifTrue:[ |
7562 nGrey := nGrey min:128. |
7575 nGrey := nGrey min:128. |
7563 greyColorsAlready := ditherColors select:[:clr | clr isGreyColor]. |
7576 greyColorsAlready := ditherColors select:[:clr | clr isGreyColor]. |
7564 d := 1 / nGrey. |
7577 d := 1 / nGrey. |
7566 collect:[:i | Color brightness:(d * i)] |
7579 collect:[:i | Color brightness:(d * i)] |
7567 thenReject:[:clr | greyColorsAlready includes:clr ]. |
7580 thenReject:[:clr | greyColorsAlready includes:clr ]. |
7568 |
7581 |
7569 ditherColors := ditherColors , moreColors. |
7582 ditherColors := ditherColors , moreColors. |
7570 ]. |
7583 ]. |
7571 ] ifFalse:[ |
7584 ] ifTrue:[ |
7572 self halt:'unhandled dither color setup'. |
7585 ditherColors := |
|
7586 Color |
|
7587 best:(1 bitShift:depth) |
|
7588 ditherColorsForImage:self image |
7573 ]. |
7589 ]. |
7574 |
7590 |
7575 self withExecuteCursorDo:[ |
7591 self withExecuteCursorDo:[ |
7576 |newImage| |
7592 |newImage| |
7577 |
7593 |
7578 newImage := self image asDitheredImageUsing:ditherColors depth:depth. |
7594 newImage := self image asDitheredImageUsing:ditherColors depth:depth. |
7579 imageEditView newImageWithUndo:newImage. |
7595 imageEditView newImageWithUndo:newImage. |
7580 ]. |
7596 ]. |
7581 |
7597 |
7582 "Created: / 07-07-2006 / 13:20:56 / cg" |
7598 "Created: / 07-07-2006 / 13:20:56 / cg" |
7583 "Modified (format): / 24-08-2017 / 17:53:46 / cg" |
7599 "Modified: / 29-08-2017 / 17:37:51 / cg" |
7584 ! |
7600 ! |
7585 |
7601 |
7586 do3DProjection |
7602 do3DProjection |
7587 |box dx1 dx2 image| |
7603 |box dx1 dx2 image| |
7588 |
7604 |