[squeak-dev] The Trunk: Graphics-ul.223.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Sep 4 14:24:47 UTC 2013


Levente Uzonyi uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-ul.223.mcz

==================== Summary ====================

Name: Graphics-ul.223
Author: ul
Time: 4 September 2013, 4:12:05.636 pm
UUID: 3f84beb0-6682-4702-a518-f345121cd59e
Ancestors: Graphics-tpr.222

- grow the write buffer if need in JPEGReadWriter2>>nextPutImage:quality:progressiveJPEG:, to ensure that the image will be written

=============== Diff against Graphics-tpr.222 ===============

Item was changed:
  ----- Method: JPEGReadWriter2>>nextPutImage:quality:progressiveJPEG: (in category 'public access') -----
  nextPutImage: aForm quality: quality progressiveJPEG: progressiveFlag
  	"Encode the given Form on my stream with the given settings. Quality goes from 0 (low) to 100 (high), where -1 means default. If progressiveFlag is true, encode as a progressive JPEG."
  
  	| sourceForm jpegCompressStruct jpegErrorMgr2Struct buffer byteCount |
  	aForm unhibernate.
  	"odd width images of depth 16 give problems; avoid them."
  	sourceForm := (aForm depth = 32) | (aForm width even & (aForm depth = 16))
  		ifTrue: [aForm]
  		ifFalse: [aForm asFormOfDepth: 32].
  	jpegCompressStruct := ByteArray new: self primJPEGCompressStructSize.
  	jpegErrorMgr2Struct := ByteArray new: self primJPEGErrorMgr2StructSize.
  	buffer := ByteArray new: sourceForm width * sourceForm height + 1024.
+ 	"Try to write the image. Retry with a larger buffer if needed."
+ 	[
+ 		byteCount := self primJPEGWriteImage: jpegCompressStruct 
+ 			onByteArray: buffer
+ 			form: sourceForm
+ 			quality: quality
+ 			progressiveJPEG: progressiveFlag
+ 			errorMgr: jpegErrorMgr2Struct.
+ 		byteCount = 0 and: [ buffer size < (sourceForm width * sourceForm height * 3 + 1024) ] ]
+ 			whileTrue: [ buffer := ByteArray new: buffer size * 2 ].
+ 	byteCount = 0 ifTrue: [ self error: 'buffer too small for compressed data' ].
- 	byteCount := self primJPEGWriteImage: jpegCompressStruct 
- 		onByteArray: buffer
- 		form: sourceForm
- 		quality: quality
- 		progressiveJPEG: progressiveFlag
- 		errorMgr: jpegErrorMgr2Struct.
- 	byteCount = 0 ifTrue: [self error: 'buffer too small for compressed data'].
  	stream next: byteCount putAll: buffer startingAt: 1.
  	self close.
  !



More information about the Squeak-dev mailing list