开发者

Programmatically Altering Images

I'd like to alter images programmatically. Specifically for the iPhone, but, general answers could help. For example, how could I, programmatically, add filters effects, such as those available in Photoshop.

Clearly it is possible as exemplified by apps such as Fat Booth. What is the starting point for this? Load an image as NSData and l开发者_开发百科earn how PNGs are encoded and go to work with the algorithm? Possible? Easier solutions?

Thanks for the help!


Chapter 21 of iPhone SDK Development has an example of how to display and manipulate a photo that is pretty easy to follow. More complex effects require more complex code, but it's something to start with.


First obtain image in raw format (raw like in raw bytes for every pixel [rgb][rgb]) then manipulate the pixels and convert back from raw format to image.

Here you can find information how to convert uiimage to and from raw pixels data, for example:

Raw to UIImage: Creating UIImage from raw RGBA data

UIimage to Raw: Can I edit the pixels of the UIImage's property CGImage

If you need geometric transformations you can use mapping of coordinates or opengl and use your image as a texture on some mesh, manipulate the mesh (geometrically) and render the scene back to an image.

You don't need to know how the images are encoded into PNGs or JPGs it can be done for you by the system. You just need to know what you want to achieve and then build your own algorithm.

Have fun!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜