Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Do a Bitmap from a Direct3D Surface.

This topic is 5419 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I have a problem and I wish that you''ll be able to answer me. Im trying to do a Bitmap with a Direct3D Surface. I think im able to retreive it but the there is a little bug: check at this picture: http://www.decatomb.com/screenshots/screenshot.bmp The background of the device is Blue. After, I put a 600x600 black bitmap on the surface, after I put another 300x300 red bitmap on the surface. Theorically, the bitmap that I created previously with the blue background is supposed to be full blue, but as we can see, he is not when I draw it on the surface. Any idea? Is this a device property problem? The code: // Create a PresentParameters object PresentParameters presentParams = new PresentParameters(); // Don''t run full screen presentParams.Windowed = true; // Discard the frames presentParams.SwapEffect = SwapEffect.Discard; presentParams.PresentFlag = Microsoft.DirectX.Direct3D.PresentFlag.LockableBackBuffer; // Instantiate a device Device device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams); while(this.Created) { if (device == null) break; //Clear the backbuffer to a blue color (ARGB = 000000ff) device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0); //Begin the scene device.BeginScene(); // Rendering of scene objects can happen here /////////////////////////////////////////////////////// /////////////////////////////////////////////////////// Bitmap b2 = new Bitmap("test300x300Red.bmp"); Bitmap b3 = new Bitmap("test600x600.bmp"); // Surface s = device.GetRenderTarget(0); Surface s = device.GetBackBuffer(0, 0, Microsoft.DirectX.Direct3D.BackBufferType.Mono); GraphicsStream gstream = s.LockRectangle(LockFlags.None); Bitmap b = new Bitmap(350, 350, 350*/*BYTES_PER_PIXEL*/4, System.Drawing.Imaging.PixelFormat.Format32bppArgb, gstream.InternalData); s.UnlockRectangle(); Graphics g = s.GetGraphics(); g.DrawImage(b3, 0, 0); // Draw the 600x600 black bitmap on the surface g.DrawImage(b2, 0, 0); // Draw the 300x300 red bitmap on the surface g.DrawImage(b, 50, 20); // Draw the blue bitmap created with the surface''s background s.ReleaseGraphics(); /////////////////////////////////////////////////////// /////////////////////////////////////////////////////// //End the scene device.EndScene(); device.Present(); Application.DoEvents(); } Thank alot for your help, Salutations,

Share this post

Link to post
Share on other sites
Guest Anonymous Poster


350 should be the surface width OR the locked area width, not the desired bitmap width.

no surface would have a width of 350 in d3d, since it''s not a power of 2, that''s why ur getting the garbage... because 350 isn''t the real stride of the locked surface area.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!