[squeak-dev] The Inbox: Graphics-jdr.176.mcz
commits at source.squeak.org
commits at source.squeak.org
Fri Jan 21 16:43:22 UTC 2011
A new version of Graphics was added to project The Inbox:
http://source.squeak.org/inbox/Graphics-jdr.176.mcz
==================== Summary ====================
Name: Graphics-jdr.176
Author: jdr
Time: 21 January 2011, 11:42:05.362 am
UUID: bbec4e0a-1c7a-43c3-8719-6091cb3d3549
Ancestors: Graphics-ul.175
The old version don't mantain the transparency of the original
=============== Diff against Graphics-ul.175 ===============
Item was changed:
----- Method: Form>>asGrayScale (in category 'converting') -----
asGrayScale
+ "Assume the receiver is a grayscale image. Return a grayscale ColorForm computed by extracting the brightness levels of the green color component. This technique allows a 32-bit Form to be converted to an 8-bit ColorForm to save space while retaining a full 255 levels of gray. (The usual colormapping technique quantizes to 8, 16, or 32 levels, which loses information.)"
- "Assume the receiver is a grayscale image. Return a grayscale ColorForm computed by extracting the brightness levels of one color component. This technique allows a 32-bit Form to be converted to an 8-bit ColorForm to save space while retaining a full 255 levels of gray. (The usual colormapping technique quantizes to 8, 16, or 32 levels, which loses information.)"
| f32 srcForm result map bb grays |
self depth = 32 ifFalse: [
f32 := Form extent: width at height depth: 32.
self displayOn: f32.
^ f32 asGrayScale].
self unhibernate.
srcForm := Form extent: (width * 4)@height depth: 8.
srcForm bits: bits.
result := ColorForm extent: width at height depth: 8.
map := Bitmap new: 256.
2 to: 256 do: [:i | map at: i put: i - 1].
map at: 1 put: 1. "map zero pixel values to near-black"
bb := (BitBlt current toForm: result)
sourceForm: srcForm;
combinationRule: Form over;
colorMap: map.
0 to: width - 1 do: [:dstX |
bb sourceRect: (((dstX * 4) + 2)@0 extent: 1 at height);
destOrigin: dstX at 0;
copyBits].
+ "final BitBlt to zero-out pixels that were truly transparent in the original"
+ map := Bitmap new: 256.
- "final BitBlt to zero-out pixels that were truely transparent in the original"
- map := Bitmap new: 512.
map at: 1 put: 16rFF.
+ bb := (BitBlt current toForm: result)
+ sourceForm: srcForm;
- (BitBlt current toForm: result)
- sourceForm: self;
- sourceRect: self boundingBox;
- destOrigin: 0 at 0;
combinationRule: Form erase;
+ colorMap: map.
+ 0 to: width - 1 do: [:dstX |
+ bb sourceRect: (((dstX * 4))@0 extent: 1 at height);
+ destOrigin: dstX at 0;
+ copyBits].
- colorMap: map;
- copyBits.
grays := (0 to: 255) collect: [:brightness | Color gray: brightness asFloat / 255.0].
grays at: 1 put: Color transparent.
result colors: grays.
^ result
!
More information about the Squeak-dev
mailing list
|