473,403 Members | 2,323 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 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 13864
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dennis Myrén | last post by:
Hi. I use System.Drawing.Bitmap to copy bitmap pixel data. I use LockBits to retrieve a BitmapData which in turn provides me with the Scan0 property which i then use to loop the pixel data using...
3
by: Tom | last post by:
I think I'm still a little rough on the principle and understanding of Marshal by value and Marshal by reference after reading various materials. my understanding of Marshal by value is that the...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
5
by: Minfu Lu | last post by:
Is there anybody knows how to copy a form (actually the image of a form) to clipboard? Jason
1
by: tsteinke | last post by:
I am in the process of creating a System.Drawing.Bitmap from a block of memory containing a DIB Bitmap. I can think of about a half dozen ways to do this. For perfomance reasons I don't want to be...
1
by: Goran | last post by:
Hi all! I need to pass managed String from to C-style APIs. I see I can use Marshal::StringToXXX functions. Is this the best we have? I understand this will allocate a new string and create copy...
4
by: Rainer Queck | last post by:
Hi NG, is there a way to copy a buffer pointed to by a IntPtr directly into a two dimensional byte-array? I tried this, what obviously doesn't work: byte image = new byte; IntPtr p =...
2
by: O.B. | last post by:
When using Marshal to copy data from a byte array to the structure below, only the first byte of the "other" array is getting copied from the original byte array. What do I need to specify to get...
0
by: yogiam | last post by:
I have a server listening for connections. Client connects and both start streaming webcam images. This works fine as long as there is only one client connected(running as a Thread). When another...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.