Jump to content
  • Advertisement
Sign in to follow this  
ed209

[.net] Need help with GDI+

This topic is 3744 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

I'm currently working on a chip 8 emulator with GDI+ and have run into a problem. The resolution has to be 64x32 pixels, and so I made a bitmap thats 64x32. The problem is that this creates a tiny bitmap that I can barely see. Is there any way to increase the size of the bitmap will maintaining the same 62x32 resolution?

Share this post


Link to post
Share on other sites
Advertisement
When you blit the surface to your window, use StretchBlt (Or whatever the .NET version is). The data buffer is still 64x32, you're just scaling it up to display it.

Share this post


Link to post
Share on other sites
You could also use a PictureBox with the bitmap assigned to it's Image property. Then just set it's SizeMode to StretchImage. When you want the PictureBox to update after you've drawn to the bitmap just call it's Invalidate method.

Not sure of the performance comparisons between these different methods. If you do use this method use DrawImageUnscaled instead as it's faster than DrawImage. It would be interesting to get out the old System.Diagnostics.Stopwatch and compare the speeds.

Share this post


Link to post
Share on other sites
Quote:
Original post by Headkaze
You could also use a PictureBox with the bitmap assigned to it's Image property. Then just set it's SizeMode to StretchImage. When you want the PictureBox to update after you've drawn to the bitmap just call it's Invalidate method.

Not sure of the performance comparisons between these different methods. If you do use this method use DrawImageUnscaled instead as it's faster than DrawImage. It would be interesting to get out the old System.Diagnostics.Stopwatch and compare the speeds.


thanks.
I will test both methods to see which one is faster.

One more question i had was when I draw a bitmap with the same color over another bitmap, the bitmap darkens. Should I clear the bitmap before everytime it is drawn to the form or is this method too slow?

Share this post


Link to post
Share on other sites
Quote:
Original post by ed209
I will test both methods to see which one is faster.

One more question i had was when I draw a bitmap with the same color over another bitmap, the bitmap darkens. Should I clear the bitmap before everytime it is drawn to the form or is this method too slow?


You can use Graphics.Clear() to clear it. But a better way would be to set the alpha byte when writing the pixels directly.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!