--- a/Image.st Wed May 11 09:38:32 2016 +0200
+++ b/Image.st Thu May 12 09:17:05 2016 +0200
@@ -3628,18 +3628,20 @@
instances or by image readers. Calling for a change of an
existing image may confuse later pixel interpretation."
- "/ the following is a trick to get shared Immutable instances, at least for the
- "/ most common cases. Prevents writers to do what is described above.
- "/ Just an experiment...
- aCollection = #( 8 8 8 ) ifTrue:[
- bitsPerSample := #( 8 8 8 )
- ] ifFalse:[
- aCollection = #( 8 ) ifTrue:[
- bitsPerSample := #( 8 )
- ] ifFalse:[
- bitsPerSample := aCollection
- ].
- ].
+ "/ the following is a trick to get both shared and immutable instances,
+ "/ at least for the most common cases.
+ "/ Prevents writers to do what is described above.
+ "/ Do not remove, as you might not understand it!!
+ bitsPerSample :=
+ #(
+ #[ 8 8 8 ]
+ #[ 4 4 4 ]
+ #[ 8 ]
+ #[ 4 ]
+ #[ 2 ]
+ #[ 1 ]
+ ) detect:[:bps | bps sameContentsAs:aCollection] ifNone:[aCollection asByteArray].
+
samplesPerPixel isNil ifTrue:[
samplesPerPixel := bitsPerSample size.
].