Image Morphs
Tim Olson
tim at jump.net
Fri Jun 29 13:55:58 UTC 2001
>I've been poking around the systems browser, and I've figured out how to
>load a jpeg into an ImageMorph. But, how to I get access to that jpeg,
>pixel by pixel (like to built a histogram of the image, for instance), and
>write it back to disk? Or is the ImageMorph the wrong way to go about
>this?
You can get the form using:
form := Form fromFileNamed: 'my_image_file.jpg'.
This is a 32-bit-per-pixel form, stored as 4 8-bit color components
(alpha, red, green, blue). To get the raw pixel bits:
pixels := form bits.
You can then do a histogram something like:
redHist := Bag new.
greenHist := Bag new.
blueHist := Bag new.
bits do:
[:pel |
redHist add: ((pel bitShift: -16) bitAnd: 255).
greenHist add: ((pel bitShift: -8) bitAnd: 255).
blueHist add: (pel bitAnd: 255)].
-- tim
More information about the Squeak-dev
mailing list
|