Possible Duplicate:
Can I achieve a torchlight effect (lighter area around a light source) in a 2D game?

I want to have a picture as a background, say this:


Then I would like to apply a mask, just a circle with blurred edges, so it looks like this:


The idea is to simulate something emitting. Is this a good way of simulating light or should I use another method? And if so how? And I'm not really sure how to apply this method.


marked as duplicate by Nicol Bolas, Josh, bummzack, MichaelHouse, Jesse Dorsey Aug 15 '12 at 20:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • \$\begingroup\$ I think your question is a duplicate of the one I linked. For posterity, I have also edited your question to contain the same content as the SO question you linked to, since I have also flagged the SO question to be closed/deleted as a duplicate of this one (it is more appropriate here). \$\endgroup\$ – Josh Aug 11 '12 at 18:13
  • \$\begingroup\$ well you removed the iPad out of the title so no i got an answer for mac osx not for iOS so yeah thanks.. \$\endgroup\$ – user1586195 Aug 11 '12 at 20:45
  • \$\begingroup\$ @user1586195 You can always edit your post and add "iPad" back in if that's so important to you. Also: The Core Image Framework is available on iOS, so the answer you got applies to iOS as well. \$\endgroup\$ – bummzack Aug 12 '12 at 8:51

You could use the Core Image CISpotLight filter:

CIImage *inputImage = // your image here
CIFilter *spotlight = [CIFilter filterWithName:@"CISpotLight"];
[spotlight setDefaults];
[spotlight setValue:inputImage forKey:@"inputImage"];
CIImage *spotlightImage = [spotlight valueForKey:@"outputImage"];

See the Core Image Programming Guide for more information.


Not the answer you're looking for? Browse other questions tagged or ask your own question.