links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Pixel access starts at zero
Last updated at 4:47 am UTC on 11 March 2017
Print the following
 (Form fromUser) colorAt: 0@0

Example of results

 Color white
  (Color r: 0.796 g: 0.796 b: 0.796)

Note that pixel access starts at 0@0

Form method
 colorAt: aPoint
	"Return the color in the pixel at the given point.  "

	^ Color 
		colorFromPixelValue: (self pixelValueAt: aPoint)
		depth: self depth

January 04, 2004 Boris Gaertner relied to the following questionf from Martin Kuball

Question: I'm trying to do some image processing in Squeak. I load an image into a Form and than use a BitBlt peeker to examine pixel values. After some hacking I > noticed that the indexing is not 1-based as in other Smalltalk methods. Is > this on purpose or a bug?

Answer: > This is not a bug. In a Form, pixel coordinates run from
 0 to: form width - 1    
in the horizontal and from
 0 to: form height - 1   
in the vertical.

This is Smalltalk tradition, but it is not mentioned very often. In the blue book, we read on page 383 (reprint of May 1983):

"A display object represents an image that has a width, a height, an assumed origin at 0 @ 0, and an offset ..."

See also:
Recipe: Access a JPEG file pixel by pixel