-
July 22nd, 2011, 06:45 AM
#1
How can i use SetBitmapBits function in C#
Since in VC++, SetBitmapBits function is there, same thing i need to use in C#.without using [DllImport("gdi32.dll")] can i perform SetBitmapBits in C#
-
July 22nd, 2011, 08:10 AM
#2
Re: How can i use SetBitmapBits function in C#
I don't think this is built into any of the Graphics capabilities of .NET. Guess you're stuck with API
Unless I'm wrong
-
July 22nd, 2011, 04:17 PM
#3
Re: How can i use SetBitmapBits function in C#
You can always call LockBits and get a pointer to memory. You could implement your own SetBitmapBits this way and it would be pretty fast (as opposed to using the GDI+ GetPixel/SetPixel API which is slow as a dog.)
-
July 22nd, 2011, 07:49 PM
#4
Re: How can i use SetBitmapBits function in C#
Several options: you can call LockBits(), as BigEd781 said, and then use one of the Copy() method overloads of the Marshal class, to copy the data to a managed byte array (as shown in the example here); next, i think you can mess with pointers in a so-called unsafe block, and work on the data directly; and finally, you can P/Invoke SetBitmapBits(), or better, P/Invoke SetDIBits().
Last edited by TheGreatCthulhu; July 22nd, 2011 at 07:53 PM.
-
July 26th, 2011, 04:02 AM
#5
Re: How can i use SetBitmapBits function in C#
Please let me know the sample code of using SetBitmapBits function in c#
-
July 26th, 2011, 04:13 PM
#6
Re: How can i use SetBitmapBits function in C#
Originally Posted by cmj
Please let me know the sample code of using SetBitmapBits function in c#
Please put in a little effort, try it on your own using the advice you have been given, and then come back with a code sample if it still isn't working for you. We are not your code monkeys.
-
July 23rd, 2011, 01:18 AM
#7
Re: How can i use SetBitmapBits function in C#
I think I may have understood the question.
I thought the OP wants to achieve the same result as SetBitmaps, but without the use of the API / P/Invoke.
Sorry if I did
-
July 23rd, 2011, 10:58 AM
#8
Re: How can i use SetBitmapBits function in C#
Sorry, I just glanced over it, and I didn't even see the last few words...
Well, in that case - go for the either one of the first two options. I only tried the approach based on the Marshal.Copy() method, and it seems that it's generally OK; the pointer based approach should be faster.
Originally Posted by HanneSThEGreaT
I think I may have understood the question. [...] Sorry if I did
But, you did: no need to feel sorry about it.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|