Inserting a Bitmap Image

Hello People

I need some code using which i can insert a bitmap image (.bmp file) onto the screen. I prefer using Borland C++ but if needed the code can be in Turbo C++ as well. The platform is Windows XP. Oh before i forget - it is a console program.

Please note that i do not use VB.

Thanks for any help !
You'll need to use the Win32 API. (Stick with the modern compiler.)

vegaseat over at DaniWeb offers these two examples:

Plot a Sinewave to the Console
http://www.daniweb.com/code/snippet217.html

Add a Little Graphics to your Console
http://www.daniweb.com/code/snippet173.html

In both cases, take note of how he takes pains to get the console's HWND so he can use its DC to draw on it. You can likewise draw bitmaps to it also using all the usual methods.

Keep in mind that the console doesn't care about anything you clandestinely put on it. Every time the console repaints itself you have to redraw what you drew.

Console applications do not have a window procedure, so you will have to do something like just refresh every second or check some pixel values to see if they changed, etc. You can also disable the scrollbars (and even remove them) by changing the console screen buffer to something that fits entirely within the console window --so the user can't scroll stuff around needlessly. (Just don't forget to restore things before terminating your app.)

Loading bitmaps from file is simple, but not well-documented. Here is an example of how to do it:
http://www.cplusplus.com/forum/windows/3718/page1.html#msg16742

Windows Console Reference
http://msdn.microsoft.com/en-us/library/ms682073(VS.85).aspx

Windows GDI Reference
http://msdn.microsoft.com/en-us/library/ms536795%28VS.85%29.aspx
(Lots of reading)

An alternative solution is to just create a borderless window positioned over the console window and draw your bitmap, etc to it.

Hope this helps and good luck!
Topic archived. No new replies allowed.