Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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!

Menge
  • *Experts*
Posted

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

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

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

Menge
  • 2 weeks later...
Posted

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?

Menge
Posted
This might be pointing towards what you want http://www.xtremedotnettalk.com/t74789/s.html It creates a Bitmap from an array of graphical data
.Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
Posted (edited)

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:

 

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

Edited by Menge
Menge

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...