Repost: Create a Bitmap from a Device and pass that bitmap to C#
  Home FAQ Contact Sign in
microsoft.public.win32.programmer.directx.graphics only
 
Advanced search
POPULAR GROUPS

more...

 Up
Repost: Create a Bitmap from a Device and pass that bitmap to C#         

Group: microsoft.public.win32.programmer.directx.graphics · Group Profile
Author: Allan Michaels
Date: Dec 6, 2007 11:52

Hello all,

[Sorry for the repost. My IT dept. let my MSDN sub. lapse, and I posted
before my managed newsgroups email address was re-registered with my sub.]

The main app is in C#.
The DirectX code is in C++ (ported from Managed DirectX).

I've written all the code so that C++ creates the device, vertices, and
indexes then renders perfectly.
I need to get a bitmap from the device and return the bitmap (or a pointer
to the bitmap) back to the C# code.

This is to replace the following Managed DirectX code:

backbuffer = m_oDevice.GetBackBuffer(0, 0, BackBufferType.Mono);
GraphicsStream gs =
SurfaceLoader.SaveToStream(ImageFileFormat.Bmp,backbuffer);
Bitmap bmpTemp = new Bitmap(gs,false);

I've worked with D3DXSaveSurfaceToFileInMemory(...) to return a handle to a
bitmap.
I returned that pointer to the C# function and used it in

Image img = Image.FromHbitmap(...);

But that threw an exception.

Understanding that this is a bitmap *file* in memory, I indexed past the
FILEHEADER and returned that pointer to C# and used FromHBitmap().
But that threw an exception.
I indexed past the INFOHEADER and returned that pointer to C# and used
FromHBitmap().
But that threw an exception.

How do I get and return a bitmap type that is useful in C#/.NET????

Thank you in advance for your kind help.

--
Allan Michaels
Ann Arbor, MI
3 Comments
diggit! del.icio.us! reddit!

RELATED THREADS
SubjectArticles qty Group
Bug#443373: linux-image-2.6.18-4-ixp4xx: kernel null paging request, crash from bitmapped md devices10 linux.debian.bugs.dist ·