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!