![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | How to put unmanaged CBitmap*->GetBitmapBits() into an BitmapSource-derivedclass Hi all, I know there are some discussions about getting byte[] from BitmapSource and how to put byte[] into an BitmapSource through MemoryStream. I tried a lot of this stuff and I dont't come far. My scenario is living in C++/CLI and I want to put data from a CBitmap* (from CImageList e.g.) into a BitmapSource object like BitmapImage for example. To achieve this I tried the following ways: 1) I tried to use the BitmapImage::Create( ... , System::IntPtr(pBuffer), ... ) method, where buffer is a byte field. If I do this the app is crashing during render-process with InvalidOperationException - "Object must be initialized before operation can be performed" Maybe some parameter is corrupt but Create is done! 2) I tried to use the approach from this newsgroup - posted in the very past. BitmapImage.StreamSource is longing for a stream. I provide a UnmanagedStreamSource initialized with the buffer from CBitmap::GetBitmapBits(..). This working until I call BitmapSource.EndInit(). There I get the following exception: NotSupportedExcpetion "No codec found that can decode the specefic file." Since this is raw bitmap data I cannot understand why there is something to be decoded?! For what is the BitmapImage.SourceStream lokking for? An encoded in memory buffer?! 3) I tried to use System::Windows::Interop::Imaging::CreateBitmapSourceFromHBitmap, too. without success. (If this would work, how does this method realize its task?) I really get frustrated with this Imaging stuff since there are NULL information on the internet or in the newsgroups. Please give me a hint how to perform such a scenario. Come on, I cannot believe that I'm the only one with this task - there have to be some examples approaches on the desks in Redmond?! Thanks You so much. Chris :-) |
My System Specs![]() |
| | #2 (permalink) |
| Guest | RE: How to put unmanaged CBitmap*->GetBitmapBits() into an BitmapSourc .... 15 minutes after the post I got approach 3 to work correctly. There were some problems concerning the the palette parameter. As a result of this I tried to cancel the previous post but without success (as You can see). Anyway do You have a sample for approach 1 or 2 out there? Thank You so much! Chris :-) "MueMeister" wrote: > Hi all, > > I know there are some discussions about getting byte[] from BitmapSource > and how to put byte[] into an BitmapSource through MemoryStream. I tried > a lot of this stuff and I dont't come far. My scenario is living in > C++/CLI and I want to put data from a CBitmap* (from CImageList e.g.) > into a BitmapSource object like BitmapImage for example. To achieve this > I tried the following ways: > > 1) I tried to use the > BitmapImage::Create( ... , System::IntPtr(pBuffer), ... ) method, > where buffer is a byte field. If I do this the app is crashing during > render-process with InvalidOperationException - "Object must be > initialized before operation can be performed" > Maybe some parameter is corrupt but Create is done! > > 2) I tried to use the approach from this newsgroup - posted in the very > past. BitmapImage.StreamSource is longing for a stream. I provide a > UnmanagedStreamSource initialized with the buffer from > CBitmap::GetBitmapBits(..). This working until I call > BitmapSource.EndInit(). There I get the following exception: > NotSupportedExcpetion "No codec found that can decode the specefic > file." Since this is raw bitmap data I cannot understand why there is > something to be decoded?! For what is the BitmapImage.SourceStream > lokking for? An encoded in memory buffer?! > > 3) I tried to use > System::Windows::Interop::Imaging::CreateBitmapSourceFromHBitmap, too. > without success. (If this would work, how does this method realize its > task?) > > I really get frustrated with this Imaging stuff since there are NULL > information on the internet or in the newsgroups. > > Please give me a hint how to perform such a scenario. Come on, I cannot > believe that I'm the only one with this task - there have to be some > examples approaches on the desks in Redmond?! > > Thanks You so much. > Chris :-) > |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem getting exception info from unmanaged C++ | akash | .NET General | 0 | 06-11-2008 02:22 PM |
| Dispose Unmanaged resources | Curious | .NET General | 2 | 03-24-2008 11:01 AM |
| Implementing Unmanaged Interface in C# | Saad | .NET General | 0 | 03-13-2008 01:04 AM |
| Problem creating an BitmapSource from an HBitmap in threaded code | Shaun Bedingfield | .NET General | 0 | 03-05-2008 07:32 AM |
| BitmapSource Disposal/cleanup | King Adrock | Avalon | 2 | 07-25-2006 11:25 AM |