|
This actually wouldn't work. A Bitmap (as do all images) contain header information. This raw data does not. This is a similar situation with digital cameras and digital SLRs that can save RAW image data. They need to have a program that translates the RAW data into an image.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Where I have information about header of BMP images?
Thanks for all help!
Alexsander "Axia" Antunes
|
|
|
|
|
Heath Stewart wrote:
A Bitmap (as do all images) contain header information
Well, what about if he writes them in that stream too?
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
It would be possible to create all the information and serialize that (not .NET serialization, mind you) that to a stream, but it is incredibly error-prone and pain in the butt. For an app I wrote I did something similar that extracts icons and I have to serialize these correctly using the chain of sturctures required. Believe me, you don't want to do that!
As you saw in my other answer, .NET does provide a way to do this. You could always P/Invoke native APIs like CreateDIBitmap to accomplish this as well. These basically take minimal information and create and serialize the structures for your. I was about to answer that way when I found that you can't (easily) get a Bitmap from a handle and noticed the other constructor I've never cared to find before (that basically does the same thing I was going to mention with native APIs).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
The Bitmap class and related classes and structs actually support this. You can use the constructor Bitmap(int, int, int, PixelFormat, IntPtr) to create a bitmap of a known size, source format, and the address of the first element in the data buffer. Basically, it uses similar functionality from GDI like the CreateDIBitmap API (although internally it uses GDI+ APIs).
This is untested, but should give you some idea
byte[] img = new byte[7800];
GCHandle gch = GCHandle.Alloc(img);
Bitmap bmp = new Bitmap(300, 260, 2400, PixelFormat.Format25bppRgb,
gch.AddrOfPinnedObject());
gch.Free(); I don't currently have any raw data to try it out on, but this seems to be the way that is similar to how it's done in good ol' C/C++.
Let me know if it works. My digital camera outputs RAW images and eventually I was going to write a new front end since the one that came with it sucks.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ok, I got the answer.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
In the code below:
Bitmap bmp = new Bitmap(300, 260, 2400, PixelFormat.Format24bppRgb, gch.AddrOfPinnedObject());
What is the third parameter (2400)? In th VS Documentation is the stride parameter, what is this?
Thanks for all,
Alexsander "Axia" Antunes
|
|
|
|
|
It's the number of bites in a single row. Since your image is 300 pixels wide and you're dealing with a byte[] , which should actually be 300 to represent 300 bytes. I was multiplying by 8 to get the number of bits, which is incorrect (not sure what I was thinking).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
My image is 300 of heigth and 260 of width.
How value is for stride? 2080(260 * 8 bits) or 2400 (300 * 8 bits)
Alexsander "Axia" Antunes
|
|
|
|
|
No, like I said - I made a mistake. Just use 260 for the value, and swap 260 and 300 for the first two params since I accidentally reversed your width and height.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
My image is 300 of heigth and 260 of width.
How value is for stride? 2080(260 * 8 bits) or 2400 (300 * 8 bits)
But in 2 cases I have the following error:
Additional information: Identification is not fixed.
Alexsander "Axia" Antunes
|
|
|
|
|
One what like do you get this? Debug your application and find out exactly where the error is happening.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How can I draw on a nonclient area of a form ? I mean the border and the caption. Before I started using C#, I just used WM_NCPAINT message to do the job, but I have no ideas how to do it in C# now ? Can anyone help me ?
Also, how can I get the size of the nonclient area ?
Regards, Desmond
|
|
|
|
|
Maybe I somehow have to import a some procedure form Win32 API, using DLLImport attribute ?
|
|
|
|
|
Override WndProc and continue to use WM_NCPAINT . In your handler, you can get a Graphics from several means, such as Graphics.FromHwnd , passing the HWND (an IntPtr ) that you get along with the Message that you're handling in WndProc .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks, but it's a bit hard for me to understand this. Could you please support me with a basic code example ?
|
|
|
|
|
You do just like you did in C++, only using managed code. If you need examples, try http://www.google.com[^]. There's many examples out there I've seen in the past.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Did so -> problem solved. Thanks. Note that I actually didn't came from C++, but from Borland Delphi (it's not that bad, really).
|
|
|
|
|
Hi guys,
I think it's a simple question: I connect to a MySQL database with OdbcDataAdapter and besides the data I want to get the schema of the database directly from the database, so I use something like this:
public DataSet GetData()
{
DataSet ds = new DataSet(datasetName);
OdbcDataAdapter adapter = new OdbcDataAdapter();
adapter.SelectCommand = GetSelectAllCmd();
adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
adapter.TableMappings.Add("Table", tableName);
adapter.Fill(ds);
if(ds.HasErrors)
ds.RejectChanges();
else
ds.AcceptChanges();
adapter.Dispose();
return ds;
} Everything seems working fine, but the schema isn't transfered correctly. The MaxLength property of the DataColumn member has the value of the longest entry in the database. For example if there is a column called 'name' and the database has an entry like 'John' the MaxLength property is 4. But I specified the 'name' column to allow 100 chars while creating the table (... name VARCHAR(100) NOT NULL, ...).
Furthermore I'm not able to change the MaxLength property. The following has no effect:
ds.Tables[tableName].Columns["name"].MaxLength = 100;
So I'm not able to insert a name to the 'name' column that is longer than 4. I get the error "The value violates the MaxLength limit of this column". Many thanks in advance!!!
Regards, mYkel
P.S.: Sorry I also posted this in SQL/ADO/ADO.NET forum but perhaps it fits better here...
|
|
|
|
|
The schema that you get is relative to the result set. If you want to have a specific schema that matches your tables, I suggest you create a typed DataSet by using either the xsd.exe utility that ships with the .NET Framework SDK to create a typed DataSet class from an XML Schema, or add a new DataSet class in Visual Studio .NET and either re-create your tables (and optionally your keys and relationships), or drag and drop your tables from the Server Explorer after adding a connection object to your database.
Use that typed DataSet in your OdbcDataAdapter calls (like Fill ) and in your queries. If you're using the designer in VS.NET for a DataGrid or some other data-bound control, it gives you nice design-time support for specific table names and columns. If also provides faster access to data when using the typed table and column names because they reference the DataTable and DataColumn objects directly, instead of using a string name that requires several looks ups.
If you don't want to use a typed DataSet , you can also add a columns to your TableMapping property. See the DataTableMapping class and its ColumnMappings property documentation in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I got it working with a typed DataSet ... thanks very much for your help Heath!!! You're the best!
Regards, mYkel
|
|
|
|
|
Hello guys!
I've seen the samples here and I have a few questions:
1 - Is it possible to download the messages with a component and onde they are downloaded I
can't download with outlook?
2 - Can I save the messages in a archive like a pst?
Greetings,
Agus
|
|
|
|
|
|
Hello,
I would like to use the NUnit Framework on GUIs.
Currently I´m using an instance of my form to get all controls. I am then filling some textboxes and push some buttons and 'assert' for errors. But this isn´t working anymore as soon as a modal dialog pops up.
Are there any tools for .NET to do this (like Abbot for JUnit)?
|
|
|
|
|
Simple: How can i use windows API in C#
|
|
|
|