749 |
749 |
750 doSaveImageAs:anImage title:aTitle |
750 doSaveImageAs:anImage title:aTitle |
751 "save contents into a file |
751 "save contents into a file |
752 - ask user for filename using a fileSelectionBox." |
752 - ask user for filename using a fileSelectionBox." |
753 |
753 |
754 |fileName defaultName rdr i txt suffix| |
754 |fileName imgFileName defaultName rdr i txt suffix| |
755 |
755 |
756 defaultName := pathName ? ''. |
756 defaultName := pathName ? ''. |
757 |
757 |
758 pathName isNil ifTrue:[ |
758 pathName isNil ifTrue:[ |
759 suffix := 'tiff' |
759 suffix := 'tiff'. |
|
760 (imgFileName := image fileName) notNil ifTrue:[ |
|
761 suffix := imgFileName asFilename suffix. |
|
762 defaultName := imgFileName asFilename baseName |
|
763 ] |
760 ] ifFalse:[ |
764 ] ifFalse:[ |
761 suffix := pathName asFilename suffix. |
765 suffix := pathName asFilename suffix. |
762 "/ a supported suffix ? |
766 "/ a supported suffix ? |
763 ((rdr := Image imageReaderClassForSuffix:suffix) isNil |
767 ((rdr := Image imageReaderClassForSuffix:suffix) isNil |
764 or:[(rdr canRepresent:anImage) not]) ifTrue:[ |
768 or:[(rdr canRepresent:anImage) not]) ifTrue:[ |
765 suffix := 'tiff'. |
769 suffix := 'tiff'. |
766 defaultName := (pathName asFilename withSuffix:suffix) pathName |
770 defaultName := (pathName asFilename withSuffix:suffix) pathName |
767 ]. |
771 ]. |
768 ]. |
772 ]. |
769 |
773 |
770 fileName := Dialog |
774 Image cannotRepresentImageSignal handle:[:ex | |
771 requestFileName:(resources string:aTitle) |
775 self warn:('cannot represent this image in that format.\\(%1)' bindWith:ex errorString) withCRs. |
772 default:defaultName |
776 fileName := nil. |
773 ok:(resources string:'save') |
777 ex restart |
774 abort:(resources string:'abort') |
778 ] do:[ |
775 pattern:('*.' , suffix). |
779 fileName := Dialog |
776 |
780 requestFileName:(resources string:aTitle) |
777 fileName notNil ifTrue:[ |
781 default:defaultName |
778 anImage saveOn:fileName. |
782 ok:(resources string:'save') |
779 pathName := fileName. |
783 abort:(resources string:'abort') |
780 ]. |
784 pattern:('*.' , suffix). |
781 |
785 |
782 "Created: 20.2.1997 / 18:52:08 / cg" |
786 fileName notNil ifTrue:[ |
783 "Modified: 10.4.1997 / 17:49:58 / cg" |
787 anImage saveOn:fileName. |
|
788 ]. |
|
789 ]. |
|
790 pathName := fileName. |
|
791 |
|
792 "Created: / 20.2.1997 / 18:52:08 / cg" |
|
793 "Modified: / 3.11.1997 / 15:02:27 / cg" |
784 ! |
794 ! |
785 |
795 |
786 saveAs |
796 saveAs |
787 "save contents into a file |
797 "save contents into a file |
788 - ask user for filename using a fileSelectionBox." |
798 - ask user for filename using a fileSelectionBox." |