★Share: Set the image filter effect!★

Source: Internet
Author: User
Tags image filter

Http://www.cocoachina.com/bbs/read.php? Tid = 69525

 

★Share: Set the image filter effect!★The Image Apply a filter to make the image black and white, and the background color yellow or something. Thank you first. Forum Evangel brother in Ali, I am in his Share In addition, after reading the document, you can add comments to the place where the comments are added. Let me first talk about the principle:
Use the core graphic API Analysis Add the four-channel rgba bitmap Memory And then there is an array in the memory. Every four elements in the array is the rgba value of a pixel in the image (0-255). You only need to change the RGB value, write it back to the new student achievement. A simple change of RGB is very easy to change. changing to a black-and-white image is to add the RGB values of each pixel to calculate the average value, and then write it back. For example, r = B = G = 100, which is gray. You only need to write a for loop and change the RGB values of each pixel to their average values. Then the photo turns black and white. If the image changes to a nostalgic image, the background color is yellow, that is, the ratio of RG is increased, and B remains unchanged, because the Red-Green match is yellow.

Here you can use the colormatrix concept in Android to better understand colormatrix.CodeIt is important to change the RGB value of each pixel to a new value.ArtPersonnel involved! The constant in colormatrix. h used in the example is the coefficient of the newly generated rgba, the array Writing Method in colormatrix. h and the new rgba generatedAlgorithmThis is done by referring to the colormatrix of Android. To understand this, you must first read the colormatrix of Android! Ha!
As follows:

Colormatrix for AndroidArticleAs follows:
Http://www.cnblogs.com/leon19870907/articles/1978065.html

ProgramAs follows:
Imageprocessingdemo.zip (1400 K) Downloads: 930
We just found a memory leak. Please go to imageprocessingviewcontroller. in M, the front of the effectchangeonbg method is added with handler * Pool = [[NSAID utoreleasepool alloc] init]; and the last [self defined mselecw.mainthread: @ selector (endeffectchange) withobject: yes]; add [pool drain] before.

you can ignore me. Let's make progress together. Ha!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.