Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to determine a single pixels alpha?



On Sunday, September 30, 2001, at 04:12 PM, Peter Ammon wrote:


Try alpha=*(pixels + [bitmap pixelsWide]*[bitmap samplesPerPixel]*(int)aPoint.y + (int)aPoint.x * [bitmap samplesPerPixel] + 3);

I'm not just picking on Peter here, but how about:

alpha=*(pixels + [bitmap bytesPerRow]*(int)aPoint.y + (int)aPoint.x * [bitmap samplesPerPixel] + 3)

It's not a good idea to assume that bytesPerRow is always equal width*bytesPerPixel. It's also probably not wise to assume that samples==bytes, either, but fixing that is left as an exercise for the reader. ;)

-Ken

Kenneth Dyke, email@hidden (personal), email@hidden (work)
Sr. Mad Scientist, MacOS X OpenGL Group, Apple Computer, Inc.
C++ is to C as Lung Cancer is to Lung


References: 
 >Re: How to determine a single pixels alpha? (From: Peter Ammon <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.