[squeak-dev] The Trunk: Graphics-nice.539.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Feb 27 15:07:35 UTC 2023


Nicolas Cellier uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-nice.539.mcz

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

Name: Graphics-nice.539
Author: nice
Time: 27 February 2023, 4:07:26.40556 pm
UUID: 5cf207ee-4818-a040-8f22-7f5dff8773d2
Ancestors: Graphics-mt.538

Fix loading of interlaced PNG images with color and alpha

Form over was used in https://source.squeak.org/trunk/Graphics-nice.292.diff so as to correctly handle (cheap) transparency in RGB images.
Unfortunately, this cannot work with interlaced images, because we overwrite parts of the image that were already downloaded in previous chunks.

Concerning interlaced RGBA images, the bug was different and dating from origins (at least from 2004). The rule Form paintAlpha does not use the alpha channel of the image, but rather a constant alpha channel.

We replace these erroneous BitBlt rules with Form blendAlphaScaled.

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

Item was changed:
  ----- Method: PNGReadWriter>>copyPixelsRGB:at:by: (in category 'pixel copies') -----
  copyPixelsRGB: y at: startX by: incX
  	"Handle interlaced RGB color mode (colorType = 2)"
  
  	| i pixel tempForm tempBits xx loopsToDo |
  
  	tempForm := Form extent: width at 1 depth: 32.
  	tempBits := tempForm bits.
  	pixel := LargePositiveInteger new: 4.
  	pixel at: 4 put: 16rFF.
  	loopsToDo := width - startX + incX - 1 // incX.
  	bitsPerChannel = 8
  		ifTrue:
  			[i := (startX // incX * 3) + 1.
  			xx := startX+1.
  			1 to: loopsToDo do:
  				[ :j |
  				pixel
  					at: 3 put: (thisScanline at: i);
  					at: 2 put: (thisScanline at: i+1);
  					at: 1 put: (thisScanline at: i+2).
  				tempBits at: xx put: pixel normalize.
  				i := i + 3.
  				xx := xx + incX].
  			transparentPixelValue
  				ifNotNil: [startX to: width-1 by: incX do: [ :x |
  					(tempBits at: x+1) = transparentPixelValue
  						ifTrue: [	tempBits at: x+1 put: 0]]]]
  		ifFalse:
  			[i := (startX // incX * 6) + 1.
  			xx := startX+1.
  			1 to: loopsToDo do:
  				[ :j |
  				(transparentPixelValue == nil or: [(1 to: 6) anySatisfy: [:k | (transparentPixelValue digitAt: k) ~= (thisScanline at: i + 6 - k)]])
  					ifTrue:
  						[pixel
  							at: 3 put: (thisScanline at: i);
  							at: 2 put: (thisScanline at: i+2);
  							at: 1 put: (thisScanline at: i+4).
  						tempBits at: xx put: pixel normalize.]
  					ifFalse:
  						[tempBits at: xx put: 0].
  				i := i + 6.
  				xx := xx + incX]].
+ 	tempForm displayOn: form at: 0 at y rule: Form blendAlphaUnscaled
- 	tempForm displayOn: form at: 0 at y rule: Form over.
  
  !

Item was changed:
  ----- Method: PNGReadWriter>>copyPixelsRGBA:at:by: (in category 'pixel copies') -----
  copyPixelsRGBA: y at: startX by: incX
  	"Handle interlaced RGBA color modes (colorType = 6)"
  
  	| i pixel tempForm tempBits |
  
  	tempForm := Form extent: width at 1 depth: 32.
  	tempBits := tempForm bits.
  	pixel := LargePositiveInteger new: 4.
  	bitsPerChannel = 8 ifTrue: [
  		i := (startX // incX << 2) + 1.
  		startX to: width-1 by: incX do: [ :x |
  			pixel at: 4 put: (thisScanline at: i+3);
  				at: 3 put: (thisScanline at: i);
  				at: 2 put: (thisScanline at: i+1);
  				at: 1 put: (thisScanline at: i+2).
  			tempBits at: x+1 put: pixel normalize.
  			i := i + 4.
  		]
  	] ifFalse: [
  		i := (startX // incX << 3) +1.
  		startX to: width-1 by: incX do: [ :x |
  			pixel at: 4 put: (thisScanline at: i+6);
  				at: 3 put: (thisScanline at: i);
  				at: 2 put: (thisScanline at: i+2);
  				at: 1 put: (thisScanline at: i+4).
  			tempBits at: x+1 put: pixel normalize.
  			i := i + 8.
  		].
  	].
+ 	tempForm displayOn: form at: 0 at y rule: Form blendAlphaScaled.
- 	tempForm displayOn: form at: 0 at y rule: Form paintAlpha.
  
  !



More information about the Squeak-dev mailing list