![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | 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) |
| | 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 | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Problem getting exception info from unmanaged C++ | .NET General | |||
| Dispose Unmanaged resources | .NET General | |||
| Implementing Unmanaged Interface in C# | .NET General | |||
| Problem creating an BitmapSource from an HBitmap in threaded code | .NET General | |||