[etoys-dev] How can I access the individual pixels in an image

Steve Thomas sthomas1 at gosargon.com
Fri May 25 14:23:53 EDT 2012


[image: Inline image 3]
I tried setting alpha to 50, but it didn't work, see script below.

recolor
| oldForm newForm old new avg |
oldForm := ErnieRubberDuckie getGraphic.
newForm := Form extent: oldForm extent depth: 16.
0
to: oldForm height - 1
do: [:y | 0
to: oldForm width - 1
do: [:x |
old := oldForm colorAt: x @ y.
avg := old red + old green + old blue / 3.
new := Color
r: old red * 0 + avg
g: old green * 0 + avg
b: old blue * 0 + avg
* alpha: 50.*
newForm colorAt: x @ y put: new]].
self setGraphic: newForm



> On Fri, May 25, 2012 at 7:59 AM, Bert Freudenberg <bert at freudenbergs.de>wrote:
>
>> On 25.05.2012, at 12:35, Steve Thomas wrote:
>>
>> How can I loop through each pixel in an image and get their
>> red,green,blue values?
>> I also would like to be able to create a new image using those values
>> (modified, for example set red=red*0.5)
>>
>> I know Karl did a great project Color Reading And Writing<http://www.squeakland.org/showcase/project.jsp?id=7044> which
>> I could use, but would like to introduce some of the kids to squeak.
>>
>>
>>
>>
>> - Bert -
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakland.org/pipermail/etoys-dev/attachments/20120525/606e04d8/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-10.png
Type: image/png
Size: 39661 bytes
Desc: not available
URL: <http://lists.squeakland.org/pipermail/etoys-dev/attachments/20120525/606e04d8/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2012-05-25 at 2.22.06 PM.png
Type: image/png
Size: 34660 bytes
Desc: not available
URL: <http://lists.squeakland.org/pipermail/etoys-dev/attachments/20120525/606e04d8/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-11.png
Type: image/png
Size: 56906 bytes
Desc: not available
URL: <http://lists.squeakland.org/pipermail/etoys-dev/attachments/20120525/606e04d8/attachment-0005.png>


More information about the etoys-dev mailing list