--- a/MacOSXIconReader.st Thu Jul 23 13:25:09 2015 +0200
+++ b/MacOSXIconReader.st Fri Jul 24 13:20:00 2015 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 2013 by Claus Gittinger
All Rights Reserved
@@ -11,6 +13,8 @@
"
"{ Package: 'stx:libview2' }"
+"{ NameSpace: Smalltalk }"
+
ImageReader subclass:#MacOSXIconReader
instanceVariableNames:'image'
classVariableNames:''
@@ -207,7 +211,7 @@
saveAll:aCollectionOfImages onStream:aStream
"save a number of images to aStream."
- |tempFile tempFileStream|
+ |tempStream|
(aCollectionOfImages conform:
[:eachImage |
@@ -218,9 +222,7 @@
^ self fileFormatError:'unsupported image size (must be square and width 16, 32, 128, 512 or 1024)'.
].
- tempFile := AutoDeletedFilename newTemporary.
- tempFileStream := tempFile writeStream.
- tempFileStream binary.
+ tempStream := ReadWriteStream on:(ByteArray new:1024).
aCollectionOfImages do:[:eachImage |
|typeCode s data|
@@ -233,17 +235,17 @@
typeCode := #(16 32 128 256 512 1024)
map: #('ipc4' 'ipc5' 'ic07' 'ic08' 'ic09' 'ic10')
at:eachImage width ifAbsent:[self error].
- tempFileStream nextPutBytes:typeCode.
- tempFileStream nextPutLong:(data size + 4 + 4) MSB:true.
- tempFileStream nextPutAll:data.
+ tempStream
+ nextPutBytes:typeCode;
+ nextPutLong:(data size + 4 + 4) MSB:true;
+ nextPutAll:data.
].
- tempFileStream close.
- aStream binary.
- aStream nextPutBytes:'icns'.
- aStream nextPutLong:(tempFile fileSize + 4 + 4) MSB:true.
- aStream nextPutAll:(tempFile binaryContentsOfEntireFile).
- tempFile delete.
+ aStream
+ binary;
+ nextPutBytes:'icns';
+ nextPutLong:(tempStream position + 4 + 4) MSB:true;
+ nextPutAll:(tempStream contents).
"
self
@@ -913,11 +915,11 @@
!MacOSXIconReader class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/MacOSXIconReader.st,v 1.12 2014-11-26 15:04:42 cg Exp $'
+ ^ '$Header$'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libview2/MacOSXIconReader.st,v 1.12 2014-11-26 15:04:42 cg Exp $'
+ ^ '$Header$'
! !