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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.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 02-07-2012, 03:47 PM   #1 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 42
justin-UK is on a distinguished road
Default GLImageProcessing sample code and Transparency

I am using the Apple GLImageProcessing sample code to change the Hue of an image. This one...
https://developer.apple.com/library/...ion/Intro.html

The image in question is a png with transparency. I must confess I don't fully understand what the OpenGL processing is doing but it seems to be redrawing the image after applying the image processing to it. The result is a loss of the transparency. What was transparent is now white.

Can anyone suggest a way to retain the transparency, or is there a way to mask the redrawn view so that views beneath it can be seen? I have tried applying a mask, and one method is using the graphics 'context' but there is incompatibility and it didn't work.

Thanks for any help. I know I'm out of my depth! but if I could just solve this one thing I can get back in my comfort zone!
justin-UK is offline   Reply With Quote
Old 02-07-2012, 09:11 PM   #2 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by justin-UK View Post
I am using the Apple GLImageProcessing sample code to change the Hue of an image. This one...
https://developer.apple.com/library/...ion/Intro.html

The image in question is a png with transparency. I must confess I don't fully understand what the OpenGL processing is doing but it seems to be redrawing the image after applying the image processing to it. The result is a loss of the transparency. What was transparent is now white.

Can anyone suggest a way to retain the transparency, or is there a way to mask the redrawn view so that views beneath it can be seen? I have tried applying a mask, and one method is using the graphics 'context' but there is incompatibility and it didn't work.

Thanks for any help. I know I'm out of my depth! but if I could just solve this one thing I can get back in my comfort zone!
It sounds to me like the sample app is not using an alpha channel at all. It would probably need to be adjusted to set up the image as RGBA rather than RGB.

Rather than using that very old sample app, I would suggest looking at Apple's new Core Image Filters. They are quite easy to use (although they do require iOS 5. I did some testing with them a while back, and the images I used were partly transparent, so I know for a fact Core Image (CI) filters preserve transparency.

There's a filter, CIHueAdjust, that should let you adjust the hue of an image.

It looks like there is a sample app, "PocketCoreImage" in the Xcode docs that is a working example of using CI filters.

CI is blazingly fast since it uses the GPU. Make sure your image size is 4096 in both dimensions, however. If it is bigger than that CI will have to switch to software rendering, which will be dramatically slower.

It's also very easy to set up. You create a CI filter by name, set a few parameters, and hand it a CIImage. You get back a CIImage, which you then have to convert back to a UIImage. That part is a little tricky however.

UIImage has a method imageWithCIImage that's supposed to let you convert a CIImage to a UIImage, but it's broken in the current version of iOS 5.

Instead, you have to use code like this, courtesy of Erica Sadun, from her excellent new book "The iOS 5 Developer's Cookbook":

Code:
  CGImageRef adjustedCGImage = [[CIContext contextWithOptions:nil] 
    createCGImage: adjustedCIImage 
    fromRect:inputCIImage.extent];
  adjustedUIImage = [UIImage imageWithCGImage: adjustedCGImage];
  CFRelease(adjustedCGImage);
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Reply

Bookmarks

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: 399
14 members and 385 guests
7twenty7, chiataytuday, cristofercolmbos, fiftysixty, gmarro, iOS.Lover, KennyChong, kilobytedump, Leslie80, Matrix23, raymng, ryantcb, stanny, xerohuang
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,669
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, dedeys78
Powered by vBadvanced CMPS v3.1.0

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