Click here to Skip to main content
15,897,518 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to get a pop-up window in c#.net and pass values to it from DataList parameters Pin
Elina Blank15-Jun-06 4:01
sitebuilderElina Blank15-Jun-06 4:01 
GeneralRe: How to get a pop-up window in c#.net and pass values to it from DataList parameters Pin
tedhill1315-Jun-06 4:21
tedhill1315-Jun-06 4:21 
AnswerRe: How to get a pop-up window in c#.net and pass values to it from DataList parameters Pin
Elina Blank15-Jun-06 4:25
sitebuilderElina Blank15-Jun-06 4:25 
GeneralRe: How to get a pop-up window in c#.net and pass values to it from DataList parameters Pin
tedhill1315-Jun-06 5:03
tedhill1315-Jun-06 5:03 
GeneralRe: How to get a pop-up window in c#.net and pass values to it from DataList parameters Pin
Elina Blank15-Jun-06 5:12
sitebuilderElina Blank15-Jun-06 5:12 
Questiondrawing on tab control Pin
donkaiser15-Jun-06 3:26
donkaiser15-Jun-06 3:26 
AnswerRe: drawing on tab control Pin
donkaiser15-Jun-06 4:29
donkaiser15-Jun-06 4:29 
QuestionCreating a Bitmap from IntPtr to unmanaged memory: issues [modified] Pin
Jon Hulatt15-Jun-06 3:06
Jon Hulatt15-Jun-06 3:06 
Hi all,

I'm trying to do some managed directshow stuff and i'm a bit stuck on some Bitmap things.

I'm trying to make a Bitmap in a callback where I am presented with an IntPtr to a block of unmanaged memory which contains my pixel data.

I can create the bitmap just fine with one of the Bitmap constructor overloads:-

Bitmap b = new Bitmap(
                720, 
                576, 
                -2160, 
                PixelFormat.Format24bppRgb,
                (IntPtr)(ip.ToInt32() + 1244160 - 2160)
                );


(stride and the IntPtr itself are hacked around a bit because my pixel data scans left-right,bottom-top. but that's not important right now).

When i've done this, I can create and use the bitmap. However, the Bitmap does not copy the data, and as such when I free the memory for the bitmap data (I have to do this - this is unsafe code), the bitmap is corrupt.

Edit: i've also tried the Bitmap.Clone() method- but the new bitmap still references the unmanaged data.

So, i've been looking for a way of copying the pixel data into a managed type so that i can keep a reference to it for as long as I need it, and then let the GC free it. But i'm struggling on how to do this.

I can easily copy the data to a byte[] array (with Marshal.Copy), but then how can I create a bitmap from the byte array?

Or can anyone else see an alternative way of doing this?

thanks

Jon

using System.Beer;


-- modified at 9:18 Thursday 15th June, 2006
AnswerRe: Creating a Bitmap from IntPtr to unmanaged memory: issues Pin
Guffa15-Jun-06 3:27
Guffa15-Jun-06 3:27 
GeneralRe: Creating a Bitmap from IntPtr to unmanaged memory: issues Pin
Florian Storck26-Jun-06 4:50
Florian Storck26-Jun-06 4:50 
QuestionCheckbox Column in DataGridView Pin
paas15-Jun-06 2:30
paas15-Jun-06 2:30 
AnswerRe: Checkbox Column in DataGridView Pin
paas15-Jun-06 3:41
paas15-Jun-06 3:41 
QuestionHow to get Page Title using WebBrowser control Pin
VenkataRamana.Gali15-Jun-06 0:57
VenkataRamana.Gali15-Jun-06 0:57 
AnswerRe: How to get Page Title using WebBrowser control Pin
Alexander Wiseman15-Jun-06 5:36
Alexander Wiseman15-Jun-06 5:36 
QuestionHow to use a variable declared in one from to other form? Pin
praveenqwe15-Jun-06 0:34
praveenqwe15-Jun-06 0:34 
AnswerRe: How to use a variable declared in one from to other form? Pin
albCode15-Jun-06 0:53
albCode15-Jun-06 0:53 
AnswerRe: How to use a variable declared in one from to other form? Pin
NaNg1524115-Jun-06 0:54
NaNg1524115-Jun-06 0:54 
AnswerRe: How to use a variable declared in one from to other form? Pin
rah_sin15-Jun-06 1:00
professionalrah_sin15-Jun-06 1:00 
AnswerRe: How to use a variable declared in one from to other form? Pin
Aijaz Ahmed Niazi15-Jun-06 1:41
Aijaz Ahmed Niazi15-Jun-06 1:41 
QuestionHow to get client ip address Pin
Raghu Deshpande14-Jun-06 23:32
Raghu Deshpande14-Jun-06 23:32 
AnswerRe: How to get client ip address [modified] Pin
albCode14-Jun-06 23:51
albCode14-Jun-06 23:51 
Questionhow to attach more than 10mb file usinh html file field Pin
ayyp14-Jun-06 23:27
ayyp14-Jun-06 23:27 
AnswerRe: how to attach more than 10mb file usinh html file field Pin
Guffa14-Jun-06 23:52
Guffa14-Jun-06 23:52 
GeneralRe: how to attach more than 10mb file usinh html file field Pin
ayyp15-Jun-06 0:04
ayyp15-Jun-06 0:04 
GeneralRe: how to attach more than 10mb file usinh html file field Pin
Guffa15-Jun-06 0:36
Guffa15-Jun-06 0:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.