Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-02-2009, 10:44 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 109
Default Test if Pixel is Transparent

Hi all,
I am trying to write an application in which I will have several png images I load in. They are all essentially masks, but based on user input, I want to change the color of them. I determined that the easiest way would probably be to test if the pixel was transparent, and if it was ignore it, but if the pixel was opaque, change the color of it.

The only problem is that I have know idea of how to do this. Thanks in advance!
brian515 is offline   Reply With Quote
Old 04-03-2009, 06:34 AM   #2 (permalink)
Dr. Touch Cocoa Helpdesk
iPhone Dev SDK Supporter
 
Join Date: Sep 2008
Location: Vienna, Austria
Posts: 537
Send a message via AIM to Oliver Drobnik Send a message via MSN to Oliver Drobnik Send a message via Skype™ to Oliver Drobnik
Default

Quote:
Originally Posted by brian515 View Post
Hi all,
I am trying to write an application in which I will have several png images I load in. They are all essentially masks, but based on user input, I want to change the color of them. I determined that the easiest way would probably be to test if the pixel was transparent, and if it was ignore it, but if the pixel was opaque, change the color of it.

The only problem is that I have know idea of how to do this. Thanks in advance!

There is a way to use a BitmapContext to get a data array in which the image pixels are laid out uncompressed and depending on the chosen color value layout as e.g. RGBA RGBA RGBA etc. Look into the Core Graphics Programming Guide next to bitmaps.

In theory you can calculate the appropriate address in this memory chunk and then check the alpha value there.

I did not find a direct method to get the RGBA values of a pixel.

Yesterday with the help of 2 people I managed to create a bitmap directly in memory. Your need would probably just be the reverse. If nobody can help you then I might create a UIImage addendum to give me direct drawing and pixel checking because this is a major nuissance in SDK that such methods are missing.
__________________
regards

Oliver Drobnik
Cocoanetics - Our DNA is programmed in Objective-C.

Linguan – makes localizing strings file fun!

Cocoanetics Parts Store – easy to use yet professionally looking components that you can use to spruce up your own apps. Augmented Reality, Calendar Control, Pin Lock or Purchase Button are only some examples. You get full source code, no static library crap, and lifetime support. Check it out today!
Oliver Drobnik is offline   Reply With Quote
Old 04-03-2009, 09:56 AM   #3 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 109
Default

Hi Oliver.

Is it hard to convert images to bitmap? And once I have images as bitmap, is it hard to get the pixel value? Because if it is hard to get the image to bitmap, I can just save them all as bitmap from Photoshop and bypass that whole step. Thanks!
brian515 is offline   Reply With Quote
Old 04-03-2009, 10:00 AM   #4 (permalink)
Dr. Touch Cocoa Helpdesk
iPhone Dev SDK Supporter
 
Join Date: Sep 2008
Location: Vienna, Austria
Posts: 537
Send a message via AIM to Oliver Drobnik Send a message via MSN to Oliver Drobnik Send a message via Skype™ to Oliver Drobnik
Default

Quote:
Originally Posted by brian515 View Post
Hi Oliver.

Is it hard to convert images to bitmap? And once I have images as bitmap, is it hard to get the pixel value? Because if it is hard to get the image to bitmap, I can just save them all as bitmap from Photoshop and bypass that whole step. Thanks!
No that's both the same effiort. The SDK uncompresses both for you.
__________________
regards

Oliver Drobnik
Cocoanetics - Our DNA is programmed in Objective-C.

Linguan – makes localizing strings file fun!

Cocoanetics Parts Store – easy to use yet professionally looking components that you can use to spruce up your own apps. Augmented Reality, Calendar Control, Pin Lock or Purchase Button are only some examples. You get full source code, no static library crap, and lifetime support. Check it out today!
Oliver Drobnik is offline   Reply With Quote
Old 04-03-2009, 10:04 AM   #5 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 109
Default

Quote:
Originally Posted by Oliver Drobnik View Post
No that's both the same effiort. The SDK uncompresses both for you.
Thanks! I will look into the core graphics documentation.
brian515 is offline   Reply With Quote
Reply

Bookmarks

Tags
color, opaque, pixel, test, transparent

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 256
17 members and 239 guests
2WeeksToGo, @sandris, AdamL, ADY, BrianSlick, Dani77, Dattee, GHuebner, headkaze, mer10, prchn4christ, smithdale87, Thompson22, timle8n1, Touchmint, vigu360
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,747
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:52 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0