'From Squeak3.1alpha of 5 February 2001 [latest update: #4022] on 17 May 2001 at 4:10:25 pm'! "Change Set: fixNextWords Date: 17 May 2001 Author: Bob Arning Fix PositionableStream>>nextWordsInto: to correctly read non word-aligned input. Also included is a test method WordArray class>>bobsTest to monitor future changes in this area. This change was necessitated by the new support for different-endian bit objects in BitBlt."! !PositionableStream methodsFor: 'accessing' stamp: 'RAA 5/17/2001 10:56'! nextWordsInto: aBitmap | blt pos source | "Fill the word based buffer from my collection. Stored on stream as Big Endian. Optimized for speed. Read in BigEndian, then restoreEndianness." collection class isBytes ifFalse: [ ^ self next: aBitmap size into: aBitmap startingAt: 1. ]. "1 to: aBitmap size do: [:index | aBitmap at: index put: (self nextNumber: 4)]." (self position \\ 4 = 0 and: [collection basicSize \\ 4 = 0]) ifTrue: [ source _ collection. pos _ self position. self skip: aBitmap size * aBitmap bytesPerElement "1, 2, or 4" ] ifFalse: [ source _ self next: aBitmap size * aBitmap bytesPerElement. "forced to copy it into a buffer" pos _ 0 ]. blt _ (BitBlt current toForm: (Form new hackBits: aBitmap)) sourceForm: (Form new hackBits: source). blt combinationRule: Form over. "store" blt sourceX: 0; sourceY: pos // 4; height: aBitmap basicSize; width: 4. blt destX: 0; destY: 0. blt copyBits. aBitmap restoreEndianness. "May be WordArray, ColorArray, etc" ^ aBitmap ! ! !WordArray class methodsFor: 'as yet unclassified' stamp: 'RAA 5/17/2001 16:07'! bobsTest | wa s1 s2 wa2 answer rawData | " WordArray bobsTest " answer _ OrderedCollection new. wa _ WordArray with: 16r01020304 with: 16r05060708. {false. true} do: [ :pad | 0 to: 3 do: [ :skip | s1 _ RWBinaryOrTextStream on: ByteArray new. s1 next: skip put: 0. "start at varying positions" wa writeOn: s1. pad ifTrue: [s1 next: 4-skip put: 0]. "force length to be multiple of 4" rawData _ s1 contents. s2 _ RWBinaryOrTextStream with: rawData. s2 reset. s2 skip: skip. "get to beginning of object" wa2 _ WordArray newFromStream: s2. answer add: { rawData size. skip. wa2 = wa. wa2 asArray collect: [ :each | each radix: 16] } ]. ]. ^answer explore! !