Render to Bitmap?

Menge

Centurion
Joined
Jul 3, 2003
Messages
108
Location
Recife - PE - Brazil
i need to render a scene and get that rendered scene to a bitmap image keeping the alpha channels. how can i do this? anyone got any ideas other than the GetFrontBuffer Method which is extremely slow?

i need to get a Bitmap object specifically.

please help!
 
You can use GetDC for any surface (if I remember right). Then you can use the API to easily blt the contents to a Bitmap object. Haven't tried it, but it seems easy (in theory). :)

-Nerseus
 
just remember... that's not viable.

to do that, then i'll just take a screenshot....

i want the rendered scene... correctly..... with all the alpha channels too..

i want directx to do it... not windows api which sucks
 
Nerseus,

i've taken a look at the GetDC method... and it does not work on A8R8G8B8 surfaces. i really need the alpha channel. i've talked to a friend of mine who did something similar in C++, and he used the LockRect method.

i've used it and have successfully loaded into a GraphicsObject the image. my problem now is transferring it to a bitmap. i tried going through the bitmap and using the SetPixel method. but it's just Painfully slow to:

1) read 4 bytes from the GraphicsStream for every pixel
2) set the pixel on the bitmap.

is there any other way to copy the memory data from the GraphicsStream to a Bitmap?
 
hrm

AndreRyan, that looks somewhat different from what i've seen around. i've taken a look at it, and it doesn't work for me either. it's faster.... twice as fast, i mean... but... just not quite it...

i managed to do this:

Code:
Microsoft.DirectX.Direct3D.GraphicsStream Image=front.LockRectangle(LockFlags.None);
Bitmap b=new Bitmap(this.Width, this.Height, this.Width*4, System.Drawing.Imaging.PixelFormat.Format32bppArgb, Image.InternalData);
the first part is blazing fast. but the bitmap creation one is slow takes about 1 second per frame on my 900Mhz...

do any of you guys know how to create a blank bitmap and then simply make it use the GraphicsStream.InternalData as its scan0?
they are the same type (the code above works) and all needed was to make the bitmap read from there. not copy as this seems to be going... but just read.

this is frustrating :P
 
Last edited:
Back
Top