Render to Bitmap?

Menge

Well-known member
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. Havent tried it, but it seems easy (in theory). :)

-Nerseus
 
just remember... thats not viable.

to do that, then ill 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,

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

ive 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 its 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 ive seen around. ive taken a look at it, and it doesnt work for me either. its 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 by a moderator:

Similar threads

T
Replies
0
Views
567
This_display_name_is_already_in_use_They_all_are
T
T
Replies
0
Views
294
This_display_name_is_already_in_use_They_all_are
T
Back
Top