|
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
|
|
|
|
|
If you create a new blank Bitmap, you can use LockBits to pin the bitmap data and get a pointer to it. Could you use that with Marshal.Copy to copy the unmanaged data into the bitmap?
---
b { font-weight: normal; }
|
|
|
|
|
Guffa wrote: If you create a new blank Bitmap, you can use LockBits to pin the bitmap data and get a pointer to it. Could you use that with Marshal.Copy to copy the unmanaged data into the bitmap?
Ups, seems that my reply notification didn't worked...
Meanwhile it seems to work using an IntPtr for initialising, but as far as I can see, the new instance allocates also memory, which is completetly unnecessary because the bitmap data are already in an unmanaged buffer, where the IntPtr points to. My initial idea was to avoid any copying issues for performance reasons and just define the bitmap format and set the pointer directly to the image data. This seems to be a lot more complicated used the managed environment. I'm not sure if it would work if the IntPtr would point to a managed location.
Any suggestions are welcome.
Bye,
Florian
|
|
|
|
|
I am developing some applications with VS 2005. In a datagridview I have added a checkbox column which, at times, I would like to be able to programatically check or uncheck. Unfortunately, whether I have that column bound to a data source or not I can not seem to programatically check or uncheck the column by changing the value to True or False (TrueValue is set to True, FalseValue is set to False). If I bind the column to a datasource that is False, the column shows as unchecked, and then I can not programatically check it and vice versa. Physically checking or unchecking via mouse clicks works fine. Can anyone tell me what I must do to programatically check or uncheck a bound or unbound checkbox column in a datagridview?
Thank you.
|
|
|
|
|
Update to my question. I figured out that if I move to another column in the grid, after programatically updating the grid, the check-box does change as I expected. For some reason it does not change immediately. Still very peculiar and I'm beginning to think it may be related to an override of ProcessCmdKey that I have in this application.
|
|
|
|
|
Hello all,
In my Winform i am using webBrowser control. in this i am displaying the asp.net page. it is working fine.
but I want to get the Page Title using webBrowser control. How to get this?
any sounds
regards
GV Ramana
regards
GV Ramana
|
|
|
|
|
Hello,
I'm not sure if you're using the new WebBrowser control class in .NET 2.0 or whether you are using AxWebBrowser with .NET earlier than 2.0. I'll give what I think is the solution for both of these:
For the WebBrowser class in .NET 2.0:
WebBrowser myBrowser;
...
HtmlDocument myDocument = myBrowser.Document;
String myTitle = myDocument.Title; This code in .NET 2.0 will get the value contained between the HTML tags <title> and .
AxWebBrowser control in .NET earlier than 2.0
AxSHDocVw.AxWebBrowser myBrowser;
...
HTMLDocument myDoc = myBrowser.Document;
String myTitle = myDoc.title; This code will do the same as the code above, that is, retrieve the value between the HTML tags <title> and .
Hope that helps! Let me know if that does not solve the problem and I will try to help you as best I can.
Sincerely,
Alexander Wiseman
|
|
|
|
|
Hi, Everyone
i am new to c# can anyone help me how to call a variable in Form2 which is been declared in Form1 .
Thankyou.
Regards,
Praveen
|
|
|
|
|
declare public variable in from1
|
|
|
|
|
There are so many threads about it.
please search the forum or the articles in CP, and u can be sure to find aloooooot about it.
|
|
|
|
|
declare variable to access in form1 as public and then
on form2 u can create instance of form1 like
form1 frm1 = new form1();
and can access variable
frm1.variable
or u can pass variable from form1 to form2 by changing constructor of form2
to accept variable like
on form1 whrere u are openning form2
form2 frm2 = new form2(variable);
frm2.show();
and can recieve variable on form2 in form2's constructor like this
class form2(datatype variable)
{
variable2 = variable;
}
rahul
|
|
|
|
|
to call varieable that is declared in form1 u have to declare that veriable as "public static" in form1
eg: public static int myint
and then call this variable in form2
eg form1.myint
from Aijaz ahmed
|
|
|
|
|
Hi All,
I am using HTTPHandler to process certain requests from a client machine. But whenever I try to retrieve the client ipaddress through servervariables I get my server ip address. Because client machine requests are routed through my server. Is there any other way I can get client machine IP Address?
Need help regarding this issue.
Raghu
|
|
|
|
|
string sClientIP =""<br />
sClientIP = Request.UserHostAddress();<br />
Response.Write(sClientIP);
|
|
|
|
|
hi all,i try to attach morethan 10mb files using html file field but it wont allow it.is there any way to do this?
Regards,
ayyp
|
|
|
|
|
The default maximum size for a request is 4 MB. This can be changed using a setting in web.config. I don't remember it's name right now, though.
---
b { font-weight: normal; }
|
|
|
|
|
sorry i didn't get u can u reply clearly........plz........
Regards,
ayyp
|
|
|
|
|
Translation:
da deft max sz for a req is 4 mb dis can b chng uzn a setn in web.config i dont remember its nm right now, dou
---
b { font-weight: normal; }
|
|
|
|
|
Hi
it is possible. u can attach any size.
find 1) machine.config file
open in VS IDE
Search keyword "httpRuntime", u will find at 169 line.
<httpRuntime executionTimeout="120" maxRequestLength="102400" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" enableVersionHeader="true"/>
Here
set maxRequestLength="102400"
|
|
|
|
|
thanks for u r rply
Regards,
ayyp
|
|
|
|
|
hi CP people!!!
how can you call .dll from C++ and use it on a C# program?
i really dont know how to ask this question coz i dont know very much C++ programmin, and i'm just starting to learn C#.
and just a noob question. what does .dll do and how you use it?
hope there's somebody who can help here.
regards.
thanks in advance.
in land of the idiots, the imbecile is the king.
|
|
|
|
|
So now a days CP forums are replacing text books?
Koushik Biswas
|
|
|
|
|
Hi every body ,,well i'm not an advanced developer in c# so that i realy need quick help in " how to display the mac address of a local pc to a textBox in a c# windows application form" ?????
actualy i have found a lot of articals using console application to obtain mac address but i just couldn't make any use out of it so by the way can i use data obtained in a console application to a forms application ?and how would that be?
thanks all of u for helping
Hesham Hafez
|
|
|
|
|
You get an article on the internet which shows you how to display something on the console. And you cannot get it dispplyed on a text box ?
Assign a string variable with the value and set the Text property of the textbox to that value.
Judging from your question, you should not be dealing with Mac Addresses. Try displaying Hello World first.
Koushik Biswas
|
|
|
|
|
tanks any way Koushik Biswas but that didn't help as i told u i'm not familer with c#
Hesham Hafez
|
|
|
|