[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

How to convert IntPtr to a byte pointer

Yawen Chan

10/11/2002 5:54:00 AM

I want to perform some unsafe operations in C# using pointers. From the C#
BitmapData object, I can get an IntPtr which points to the first entry of
the bitmap data memory in the system. How can I convert that IntPtr into a
byte*,?




3 Answers

Bob Powell

10/11/2002 8:28:00 AM

0

BitmapData.Scan0 provides a ToPointer() method.

The result of this operation can be cast to the type of pointer you require
such as byte, short, int...

Bob.


--
xRay tools Professional Windows Forms componenets at amazing prices.
http://www.bobpowell.net/xray...
Buy the tool and get source code in VB or C#

Buy my book, C# and the .NET framework...
http://www.amazon.com/exec/obidos/ASIN/067232153X/b...

See my book recommendations...
http://www.bobpowell.net/recommend...

Check out the GDI+ FAQ
http://www.bobpowell.net/gdipl...

"Yawen Chan" <y3chan@engmail.uwaterloo.ca> wrote in message
news:uz1D#mNcCHA.1324@tkmsftngp08...
> I want to perform some unsafe operations in C# using pointers. From the
C#
> BitmapData object, I can get an IntPtr which points to the first entry of
> the bitmap data memory in the system. How can I convert that IntPtr into
a
> byte*,?
>
>
>
>


Rick Zhuang

10/11/2002 8:42:00 AM

0

Hi Yawen,

You can get a void* by using the ToPointer() method of IntPtr, and then
explicitly convert it to a byte*.

Hope this helps.

Cheers,

Rick Zhuang


"Yawen Chan" <y3chan@engmail.uwaterloo.ca> wrote in message
news:uz1D#mNcCHA.1324@tkmsftngp08...
> I want to perform some unsafe operations in C# using pointers. From the
C#
> BitmapData object, I can get an IntPtr which points to the first entry of
> the bitmap data memory in the system. How can I convert that IntPtr into
a
> byte*,?
>
>
>
>


Yawen Chan

10/11/2002 9:41:00 AM

0

Thanks Bob and Rick. It's working fine now with your help =)


"Rick Zhuang" <rickngm@hotmail.com> wrote in message
news:OOWnhEPcCHA.2616@tkmsftngp09...
> Hi Yawen,
>
> You can get a void* by using the ToPointer() method of IntPtr, and then
> explicitly convert it to a byte*.
>
> Hope this helps.
>
> Cheers,
>
> Rick Zhuang
>
>
> "Yawen Chan" <y3chan@engmail.uwaterloo.ca> wrote in message
> news:uz1D#mNcCHA.1324@tkmsftngp08...
> > I want to perform some unsafe operations in C# using pointers. From the
> C#
> > BitmapData object, I can get an IntPtr which points to the first entry
of
> > the bitmap data memory in the system. How can I convert that IntPtr
into
> a
> > byte*,?
> >
> >
> >
> >
>
>