From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:29:22 pm (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <methods> Kernel.ObjectMemory class <category>system backup/exit</category>
compressImageFile: inputName to: outputName resultsTo: aBlock "Compress the file named by inputFilename to a file named outputFilename in the fortmat expected by the engine for compressed images. Evaluate aBlock with four arguments, the size of the input image, the size of the output image, the compression time and the decompression time (in milliseconds), respectively." | inputFilename outputFilename input output compressedOutput compTime decompTime | inputFilename := inputName asFilename. outputFilename := outputName asFilename. input := inputFilename readStream. input binary. [| header headerSize fileFormatOffset fileFormatNormal fileFormatZLibCompressed | fileFormatOffset := 44. headerSize := 512. fileFormatNormal := 0. fileFormatZLibCompressed := 1. header := input next: headerSize. (header at: fileFormatOffset) ~= fileFormatNormal ifTrue: [self error: (#ImageFileNotUncompressed << #dialogs >> 'image file <1s> is not uncompressed' expandMacrosWith: inputFilename asString)]. header at: fileFormatOffset put: fileFormatZLibCompressed. output := outputFilename writeStream. output binary. output nextPutAll: header. compressedOutput := OS.ZLib.GZipWriteStream bestCompressionOn: output. Cursor write showWhile: [compTime := Time millisecondsToRun: [[input atEnd] whileFalse: [compressedOutput nextPutBufferFrom: input]]]] ensure: [input close. compressedOutput close]. Cursor read showWhile: [output := outputFilename readStream binary. decompTime := Time millisecondsToRun: [output skip: 512. (OS.ZLib.GZipReadStream on: output) skip: outputFilename fileSize - 512; close]]. ^aBlock valueWithArguments: (Array with: inputFilename fileSize with: outputFilename size with: compTime with: decompTime)
</methods> <methods> Tools.VisualLauncher <category>actions</category>
fileCompressImage <menuItem: #(#CompressImageFile #dialogs 'Compress image file') nameKey: nil menu: #(#menuBar #file) position: 12.5> | dialog inputName outputName | (dialog := SimpleDialog initializedFor: builder window) setInitialGap; addMessage: #InputImageFileName << #dialogs >> 'Compress which image file?' centered: true; addGap: 4; addTextLine: (inputName := ValueHolder with: 'visual'); addMessage: #OutputImageFileName << #dialogs >> 'Output file name?' centered: true; addGap: 4; addTextLine: (outputName := ValueHolder with: 'visualgz'); addDivider; addOK: [true]; openDialog. dialog cancel value ifTrue: [^false]. ObjectMemory compressImageFile: ((inputName value indexOfSubCollection: '.im' startingAt: 1) = 0 ifTrue: [inputName value, '.im'] ifFalse: [inputName value]) to: ((outputName value indexOfSubCollection: '.im' startingAt: 1) = 0 ifTrue: [outputName value, '.im'] ifFalse: [outputName value]) resultsTo: [:inFileSize :outFileSize :compTime :decompTime| Transcript cr; nextPutAll: 'Image compressed to '; print: (outFileSize * 10000 / inFileSize) rounded / 100.0; nextPutAll: '% of original ('; print: inFileSize->outFileSize; nextPut: $); cr; nextPutAll: 'Deompression + read time '; print: decompTime // 10 / 100.0; nextPutAll: ' seconds (compressed in '; print: compTime // 10 / 100.0; nextPutAll: ' seconds)'; flush]
</methods> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>VisualLauncher</name> <environment>Tools</environment> <super>UI.ApplicationModel</super> <private>false</private> none menuBar toolBar textCollector toolDock <imports></imports> <category>Tools-Misc</category> <attributes> <package>Tools-Misc</package> </attributes> </class>