When it comes to scraping, the first thing we think about is the overlap of the top and bottom two (rectangles), and then the above image.
My idea is: by hand gestures, the place where the finger is going to become transparent, the bottom will be displayed.
So how do you make a picture transparent? This will be done with the pixels of the image.
First, the pixel of the image is an array of type int: int[], this array length is picture high (pixels) * Width (pixels)
For example: A picture of the aspect is 200pixel, 400pixel, then this array is int[80000]
For each element, the official document says Argb32[RGB24] (a refers to the alpha channel control transparency)
The RGB color of level 256 (0-255) can combine approximately 16.78 million colors, i.e. 256x256x256=16777216
That is, each element is: (-1: White)-----(-16777216: Black) 0 or another positive value is a transparent color
Pass
New
We get to be a one-dimensional array that we convert to a two-dimensional array for ease of operation.
for (int0; i < ioriginalheight; i++) //Picture height { for (int0 ; J < Ioriginalwidth; J + +) //Picture width { = originalwb.pixels[i * (ioriginalwidth) + j]; }}
After we touch the gesture, we're going to deal with the pixels.
: Suppose we length=1 (referring to the size of the touch after it)
If we select the red position, I'm going to make the square ( Green position) of the pixel with a distance of 1 on the edge of the red pixel transparent
We can get the start end row and column to the Green range.
Then just change the color of that pixel.
0; // gets the subscript of a neighboring pixel (i * l) + j
Assign a value to the picture at the end
Here is the demo under WP8: Remember: You need to download a picture online
Click to download
PS: But the effect is not very good, due to the use of a square (unfortunately WriteableBitmap does not have some methods under WPF)
If there is a better way, hope to tell me!
Scratch (eraser) function under WP8