471,318 Members | 2,172 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,318 software developers and data experts.

Marshal.Copy and copying a Bitmap

Hello,

Where could aI find a sample code which would show how to use
Marshal.Copy to copy a "graphics image" to pixel based image?

There is a MS (really) quick supportpage for that
http://support.microsoft.com/kb/814675/en-us
but it is too approximate for anything.

Cheers!

Jan 16 '06 #1
3 13253
Jerry,

That document refers to using the Scan0 property on the BitmapData
instance returned to you from the call to LockBits.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jerry Q" <jq****@yahoo.com> wrote in message
news:dq**********@nyytiset.pp.htv.fi...
Hello,

Where could aI find a sample code which would show how to use
Marshal.Copy to copy a "graphics image" to pixel based image?

There is a MS (really) quick supportpage for that
http://support.microsoft.com/kb/814675/en-us
but it is too approximate for anything.

Cheers!

Jan 16 '06 #2
Yes it does, but there are also lot's of code in Internet that uses those
Classes and objects in manyways. Methods of those classes have also
very complex parameters and many kind of conversions must be made.

It would be more painless to have proper example from Microsoft becuse
their GDI+ classes haven't any kind of support for this operation.

Cheers!

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:e7**************@TK2MSFTNGP10.phx.gbl...
Jerry,

That document refers to using the Scan0 property on the BitmapData
instance returned to you from the call to LockBits.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jerry Q" <jq****@yahoo.com> wrote in message
news:dq**********@nyytiset.pp.htv.fi...
Hello,

Where could aI find a sample code which would show how to use
Marshal.Copy to copy a "graphics image" to pixel based image?

There is a MS (really) quick supportpage for that
http://support.microsoft.com/kb/814675/en-us
but it is too approximate for anything.

Cheers!


Jan 16 '06 #3
Here is an example to fill in, you can also copy out.

Public Shared Sub FillBitmap(ByVal bmp As Bitmap, ByVal imgArray As Byte())
Dim h As Integer = bmp.Height

Dim bmpDat As Imaging.BitmapData
Dim stride As Integer

Try
bmpDat = bmp.LockBits(New Rectangle(0, 0, bmp.Width,
bmp.Height), _
Imaging.ImageLockMode.WriteOnly, bmp.PixelFormat)

stride = bmpDat.Stride

Marshal.Copy(imgArray, 0, bmpDat.Scan0, stride * h)

Catch ex As Exception
Finally
bmp.UnlockBits(bmpDat)
End Try

End Sub

"Jerry Q" wrote:
Yes it does, but there are also lot's of code in Internet that uses those
Classes and objects in manyways. Methods of those classes have also
very complex parameters and many kind of conversions must be made.

It would be more painless to have proper example from Microsoft becuse
their GDI+ classes haven't any kind of support for this operation.

Cheers!

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:e7**************@TK2MSFTNGP10.phx.gbl...
Jerry,

That document refers to using the Scan0 property on the BitmapData
instance returned to you from the call to LockBits.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jerry Q" <jq****@yahoo.com> wrote in message
news:dq**********@nyytiset.pp.htv.fi...
Hello,

Where could aI find a sample code which would show how to use
Marshal.Copy to copy a "graphics image" to pixel based image?

There is a MS (really) quick supportpage for that
http://support.microsoft.com/kb/814675/en-us
but it is too approximate for anything.

Cheers!



Jan 16 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Dennis Myrén | last post: by
3 posts views Thread by Tom | last post: by
7 posts views Thread by lgbjr | last post: by
5 posts views Thread by Minfu Lu | last post: by
1 post views Thread by tsteinke | last post: by
1 post views Thread by Goran | last post: by
4 posts views Thread by Rainer Queck | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.