Bitmap as a pointer [closed]
Hi i have a Bitmap which is showing in a file in a form
;
Bitmap btm = new Bitmap("F:\\Image.bmp");
i have a method in a class which take this btm
and do some process and return back what i need is to pass this btm
to this function in the class as a memory pointer and return its address
im not sure that will this process is able to do it C#
as other C
based languages C/C++
if you are looking for a memory pointer to the pixel data then use Bitmap.LockBits() in an unsafe block. it returns a BitmapData object that contains info about the bitmap and the address.
take a look at this msdn article for more info.
EDIT: Would just like to note that if you would like to change pixel data then you could use the SetPixel method so you don't have to 'go unsafe'. But if you are looking at manipulating many pixels at a time then modifying them in memory does give better performance.
Hope that helps.
Cheers!
You can use delegates in C# in place of function pointers.
These links may help you understand the concept:
are there function pointers in c#?
Function pointers in C#
精彩评论