How to use C # pointer
This article mainly introduces how to use the C# pointer, the article is very detailed, has a certain reference value, interested friends must read it!
When it comes to the pointer operation of .NET, many people do not know very well, or even know that there is such a thing. Because the pointer operation of C# belongs to the unsafe operation, many people are very cautious about the use of unsafe. In fact, the so-called unsafe code is actually not controlled by the managed execution under the control of CLR, which is equivalent to part of the regional autonomy under the leadership of CLR. Of course, CLR does not care about memory allocation and recycling of unsafe code. Needless to say, first experience the performance improvement brought about by the appropriate C # pointer operation. Usually when we use GDI+ to manipulate a slightly larger picture pixel, we will have a feeling that we are on the verge of collapse. Let's switch to the operation with C# pointer.
Bitmapmap=newBitmap (path)
/ / lock the bitmap area of the picture
BitmapDatamapdata=map.LockBits (newRectangle (0re0remap.Widthremap.Height)
ImageLockMode.ReadWrite,PixelFormat.Format24bppRgb)
Unsafe
{
Byte*pixpoint
Intnewpoint
For (inti=0;i