Pointer to an image in memory

I have bit a code where I need a intptr value for a byte array, and I have no idea how to get the pointer to the byte array.

Dim myImage() As Byte = conv.GetImage

image = Drawing.Image.FromHbitmap(<POINTER TO myImage>)

I"m not even sure this will work, but an answer will help. Can anyone help me here

Thanks.




Answer this question

Pointer to an image in memory

  • noel 55

    I might be wrong but .NET is a "safe" language, you do not have direct access to memory. Only C# has the unsafe keyword that let you play with memory.

    Here is a code that show how to copy the byte of an image to a byte array

    http://www.eggheadcafe.com/PrintSearchContent.asp LINKID=799

    Don't forget to copy the array back to the image.



  • shaw79

    What is your Pointer userd for in your program You want to get the pointer to the byte array, but where do you define the arrays At least there is an array defined as Byte[] in your code.

    You can define like this:

    System.Drawing.Bitmap bitmap=new System.Drawing.Bitmap("d:\\test.bmp");
    IntPtr inp
    =
    bitmap.GetHbitmap();
    byte[] imgByte=new byte[1024
    ];
    GetBitmapBits(inp,
    0,out
    imgByte);
    foreach(byte img in
    imgByte)
    {
    Console.WriteLine(img.ToString());
    }

    Console.Read();



  • Pointer to an image in memory