[squeak-dev] The Inbox: Graphics-kfr.539.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Jan 24 15:15:07 UTC 2023


A new version of Graphics was added to project The Inbox:
http://source.squeak.org/inbox/Graphics-kfr.539.mcz

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

Name: Graphics-kfr.539
Author: kfr
Time: 24 January 2023, 4:14:44.191095 pm
UUID: 86bd041b-d614-8b4c-b0c7-e578ca75507d
Ancestors: Graphics-mt.538

Faster preview of gif in FileList. Just decode the first frame in the stream

=============== Diff against Graphics-mt.538 ===============

Item was changed:
  ----- Method: GIFReadWriter>>nextImage (in category 'accessing') -----
  nextImage
  	"This method ensures older compatibility with ImageReadWriter.
  	We respond with the Form corresponding to the *first image* on
  	the receiver's read byte stream"
  	self
  		readHeader;
+ 		readFirstFrame.
- 		readBody.
  	^ self form.!

Item was added:
+ ----- Method: GIFReadWriter>>readFirstFrame (in category 'private - decoding') -----
+ readFirstFrame
+ 	"Read the GIF blocks. Modified to return a frame."
+ 	| block frame |
+ 	frame := nil.
+ 	frames := OrderedCollection new.
+ 	[ block = ImageSeparator  ] whileFalse: [ 
+ 		block := self next.
+ 		
+ 		"If we have reached the terminator byte, return."
+ 		block = Terminator ifTrue: [ ^ frame ].
+ 		block = ImageSeparator 
+ 			ifTrue: [ 
+ 				frame ifNil: [ frame := AnimatedImageFrame new ].
+ 				frame form: (self readBitDataOnFrame: frame). "Adjusting message for testing"
+ 				frame offset: offset. "Set from instance var, which is set in readBitData"
+ 				frame form offset: offset. "Set the offset on the underlying Form as well"
+ 				
+ 				frames add: frame.
+ 				self processColorsFor: frame.
+ 				frame := nil.
+ 				]
+ 			ifFalse: 
+ 				[ "If it's not actual image data, perhaps
+ 					it's an Extension of some kind (there can be several)"
+ 					block = Extension 
+ 						ifTrue: [ 
+ 							frame ifNil: [ frame := AnimatedImageFrame new ].
+ 							self readExtensionBlock: block withFrame: frame ]
+ 						ifFalse: [ ^ self error: 'Unknown Bytes!!' ] ] 
+ 		].
+ 	^ frames.!



More information about the Squeak-dev mailing list