[squeak-dev] The Trunk: GraphicsTests-EG.58.mcz

karl ramberg karlramberg at gmail.com
Sun Jun 12 21:30:19 UTC 2022


See Color colorFromPixelValue: p depth: d  and pixelValueForDepth:

"Transparency:
The pixel value zero is reserved for transparent.
For depths greater than 8, black maps to the darkest possible blue."

This mapping is used so there can be transparent forms when there is no
alpha channel.

Best,
Karl


On Sun, Jun 12, 2022 at 10:41 PM <
christoph.thiede at student.hpi.uni-potsdam.de> wrote:

> Hi Eric,
>
> > Note that in this version, the tests are currently failing because --
> apparently -- drawing Color black to a FormCanvas actually results in a
> slightly different color being put at the corresponding pixels of the Form.
> Therefore the expected values (Color black) are something else.
> >
> > I suspect this is an issue with Form/FormCanvas?
>
> Here is a small bit of additional information on this issue (I don't
> understand the issue myself, but I have already searched for this on the
> list recently for another student's question, so maybe this is helpful for
> anyone): See also GraphicsTests-pre.49.
> It looks as if 32-bit forms in Squeak basically do not support black
> pixels for what ever reason. You could check whether issue persists when
> you choose a lower bit depth.
>
> Sorry, that is the only dim light I can shed on this issue ...
>
> Best,
> Christoph
>
> ---
> *Sent from **Squeak Inbox Talk
> <https://github.com/hpi-swa-lab/squeak-inbox-talk>*
>
> On 2022-05-04T11:08:41+00:00, commits at source.squeak.org wrote:
>
> > Marcel Taeumel uploaded a new version of GraphicsTests to project The
> Trunk:
> > http://source.squeak.org/trunk/GraphicsTests-EG.58.mcz
> >
> > ==================== Summary ====================
> >
> > Name: GraphicsTests-EG.58
> > Author: EG
> > Time: 21 December 2021, 7:06:22.53722 pm
> > UUID: 32f0cb4a-a10f-4263-85da-6d934e567b0d
> > Ancestors: GraphicsTests-mt.57
> >
> > Adding actual tests for GIF reading and writing (and reading back in).
> >
> > Note that in this version, the tests are currently failing because --
> apparently -- drawing Color black to a FormCanvas actually results in a
> slightly different color being put at the corresponding pixels of the Form.
> Therefore the expected values (Color black) are something else.
> >
> > I suspect this is an issue with Form/FormCanvas?
> >
> > =============== Diff against GraphicsTests-mt.57 ===============
> >
> > Item was added:
> > + TestCase subclass: #GIFReadWriterTest
> > +     instanceVariableNames: ''
> > +     classVariableNames: ''
> > +     poolDictionaries: ''
> > +     category: 'GraphicsTests-Files'!
> >
> > Item was added:
> > + ----- Method: GIFReadWriterTest>>animatedColorFrames (in category
> 'tests') -----
> > + animatedColorFrames
> > +     "Responds with a collection of AnimatedImageFrames
> > +     each containing equal-sized rectangles of green, red,
> > +     yellow. and black. When animated, these rectangles move
> > +     into each other's positions, then back"
> > +     | frames topLeft topRight bottomLeft bottomRight revFrames |
> > +     frames := OrderedCollection new.
> > +     topLeft := (0 at 0 extent: 200 at 200).
> > +     topRight := (200 at 0 extent: 400 at 200).
> > +     bottomLeft := (0 at 200 extent: 200 at 400).
> > +     bottomRight := (200 at 200 extent: 400 at 400).
> > +
> > +     0 to: 200 by: 20 do: [ :num |
> > +         | newTopLeft newTopRight newBottomLeft newBottomRight canvas |
> > +         newTopLeft := topLeft translateBy: (num at 0).
> > +         newTopRight := topRight translateBy: (0 at num).
> > +         newBottomLeft := (bottomLeft origin - (0 at num)) corner:
> (bottomLeft extent - (0 at num)).
> > +         newBottomRight := (bottomRight origin - (num at 0)) extent:
> (bottomLeft extent - (0 at 0)).
> > +         canvas := FormCanvas extent: 400 at 400 depth: 32.
> > +         canvas
> > +             fillRectangle: newTopLeft color: Color green;
> > +             fillRectangle: newTopRight color: Color red;
> > +             fillRectangle: newBottomLeft color: Color yellow;
> > +             fillRectangle: newBottomRight color: Color black.
> > +         frames add: (AnimatedImageFrame new
> > +             form: canvas form;
> > +             disposal: #restoreBackground;
> > +             delay: 60) ].
> > +
> > +     revFrames := frames reversed.
> > +     revFrames do: [ :f | frames add: f ].
> > +     ^ frames!
> >
> > Item was added:
> > + ----- Method: GIFReadWriterTest>>testAnimatedColorsOutIn (in category
> 'tests') -----
> > + testAnimatedColorsOutIn
> > +     "Ensure that the colored rectangles in the created
> > +     animated gif are correct at different frames"
> > +     | frames outBytes writer reader inBytes activeFrame |
> > +     frames := self animatedColorFrames.
> > +
> > +     "Write out the GIF bytes to the byte stream"
> > +     outBytes := WriteStream on: (ByteArray new).
> > +     writer := GIFReadWriter on: outBytes.
> > +     frames do: [ :f | writer nextPutFrame: f ].
> > +     writer close.
> > +
> > +     "Read the GIF byte stream back into a GIF"
> > +     inBytes := ReadStream on: (outBytes contents).
> > +     reader := GIFReadWriter on: inBytes.
> > +     reader
> > +         readHeader;
> > +         readBody.
> > +
> > +     self assert: reader isAnimated equals: true.
> > +     activeFrame := reader frames at: 1.
> > +     self assert: (activeFrame form colorAt: 100 at 100) equals: Color
> green.
> > +     self assert: (activeFrame form colorAt: 300 at 100) equals: Color
> red.
> > +     self assert: (activeFrame form colorAt: 100 at 300) equals: Color
> yellow.
> > +     self assert: (activeFrame form colorAt: 300 at 300) equals: Color
> black.
> > +     activeFrame := reader frames at: 11.
> > +     self assert: (activeFrame form colorAt: 100 at 100) equals: Color
> yellow.
> > +     self assert: (activeFrame form colorAt: 300 at 100) equals: Color
> green.
> > +     self assert: (activeFrame form colorAt: 100 at 300) equals: Color
> black.
> > +     self assert: (activeFrame form colorAt: 300 at 300) equals: Color
> red.
> > +     !
> >
> > Item was added:
> > + ----- Method: GIFReadWriterTest>>testColorsFileOutIn (in category
> 'tests') -----
> > + testColorsFileOutIn
> > +     "Ensure that the colors that are written match up
> > +     to the colors that are read in again"
> > +     | canvas form outBytes inBytes writer reader |
> > +     canvas := FormCanvas extent: 400 at 400.
> > +     canvas
> > +         fillRectangle: (0 at 0 extent: 200 at 200) color: Color green;
> > +         fillRectangle: (200 at 0 extent: 400 at 200) color: Color red;
> > +         fillRectangle: (0 at 200 extent: 200 at 400) color: Color
> yellow;
> > +         fillRectangle: (200 at 200 extent: 400 at 400) color: Color
> black.
> > +     form := canvas form.
> > +     outBytes := FileStream fileNamed: 'testColorsFileOutIn.gif'.
> > +     writer := GIFReadWriter on: outBytes.
> > +     writer
> > +         nextPutImage: form;
> > +         close.
> > +     inBytes := 'testColorsFileOutIn.gif' asDirectoryEntry readStream
> binary.
> > +     reader := GIFReadWriter on: inBytes.
> > +     reader
> > +         readHeader;
> > +         readBody.
> > +     inBytes close.
> > +     'testColorsFileOutIn.gif' asDirectoryEntry delete.
> > +     self assert: reader isAnimated equals: false.
> > +     self assert: (reader form colorAt: 50 at 50) equals: Color green.
> > +     self assert: (reader form colorAt: 250 at 50) equals: Color red.
> > +     self assert: (reader form colorAt: 50 at 250) equals: Color yellow.
> > +     self assert: (reader form colorAt: 250 at 250) equals: Color
> black.!
> >
> > Item was added:
> > + ----- Method: GIFReadWriterTest>>testColorsOutIn (in category 'tests')
> -----
> > + testColorsOutIn
> > +     "Ensure that the colors that are written match up
> > +     to the colors that are read in again"
> > +     | canvas form outBytes inBytes writer reader |
> > +     canvas := FormCanvas extent: 400 at 400.
> > +     canvas
> > +         fillRectangle: (0 at 0 extent: 200 at 200) color: Color green;
> > +         fillRectangle: (200 at 0 extent: 400 at 200) color: Color red;
> > +         fillRectangle: (0 at 200 extent: 200 at 400) color: Color
> yellow;
> > +         fillRectangle: (200 at 200 extent: 400 at 400) color: Color
> black.
> > +     form := canvas form.
> > +     outBytes := WriteStream on: (ByteArray new).
> > +     writer := GIFReadWriter on: outBytes.
> > +     writer
> > +         nextPutImage: form;
> > +         close.
> > +     outBytes := outBytes contents.
> > +     inBytes := ReadStream on: outBytes.
> > +     reader := GIFReadWriter on: inBytes.
> > +     reader
> > +         readHeader;
> > +         readBody.
> > +     self assert: reader isAnimated equals: false.
> > +     self assert: (reader form colorAt: 50 at 50) equals: Color green.
> > +     self assert: (reader form colorAt: 250 at 50) equals: Color red.
> > +     self assert: (reader form colorAt: 50 at 250) equals: Color yellow.
> > +     self assert: (reader form colorAt: 250 at 250) equals: Color
> black.!
> >
> >
> ["21f76fee-ee89-4520-af8d-14db0e6e812f.jfif"]
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220612/9f8e95b1/attachment.html>


More information about the Squeak-dev mailing list