The Trunk: Graphics-jdr.84.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Graphics-jdr.84.mcz

commits-2
Andreas Raab uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-jdr.84.mcz

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

Name: Graphics-jdr.84
Author: jdr
Time: 27 October 2009, 6:17:33 am
UUID: d65885ed-8bde-4ede-b96a-5e80c5fdbc15
Ancestors: Graphics-jdr.83

correct reading of gray PNMs

=============== Diff against Graphics-jmv.82 ===============

Item was changed:
  ----- Method: PNMReadWriter>>readGray (in category 'reading') -----
  readGray
+ "gray form, return ColorForm with gray ramp"
+ | form poker |
- "gray form"
- | val form poker |
  maxValue > 255 ifTrue:[self error:'Gray value > 8 bits not supported in Squeak'].
  stream binary.
+ form := ColorForm extent: cols@rows depth: depth.
+ form colors: nil.
- form := Form extent: cols@rows depth: depth.
  poker := BitBlt current bitPokerToForm: form.
  0 to: rows-1 do: [:y |
  0 to: cols-1 do: [:x |
+ |val|
  val := stream next.
  poker pixelAt: x@y put: val.
  ]
  ].
+ "a better way is using a gamma corrected palette"
+ form colors: ((0 to: 255) collect:[:c|
+ c > maxValue
+ ifTrue:[Color white]
+ ifFalse:[Color gray: (c/maxValue) asFloat]]).
+ form colors at: 1 put: (Color black).
  ^form
  !