Hi i am new to this how can i add graphics to my C program lets say i wanted to add a image file how would i do this
Printable View
Hi i am new to this how can i add graphics to my C program lets say i wanted to add a image file how would i do this
Are you just doing it in console? because you can't then.
If not, look in to open GL and direct X
ehhhhhhhhhhh help plz i am using Borland C++ on Windows 98 so what header would i need and what code would i use
i don't understand by open gL i am talking about basic *.bmp file being loaded up in lets say dos program or win32bit program how would i do this
Wrong. You DON'T need OpenGL OR DirectX in order to add a simple 2D picture to your WIN32 program. All you need to do is call the LoadBitmap function to create a new bitmap. Next, use the SelectObject API in conjunction with the GetDC API to select the Bitmap into the DC and call the UpdateWindow function to reflect your changes!
In MFC, there's the CBitmap::LoadBitmap and the CDC::SelectObject functions.
Micobasic
Thank you for putting me on the right path this makes more sense .
if only i had the knowledge
Inforwarrior
" May Man Kind deserve better "
If you want to load the image up into a window, it's best that you understand the basics of creating the window first as well, without using MFC, because otherwise you'll confused yourself.
Also, Borland C++ doesn't come with MFC (I don't think, even though it may support it).
I think John has a good tutorial on the top of the C++ forum that teaches the basics of VC++ - the API way.
By the way, Parksie, do you know the answer to my other question (how do you change focus in a dialog)?
Borland doesn't support MFC because of name mangling.
Microbasic: have you tried this? Here's a quote from the docs:
You have to select the bitmap into a memory dc (created with CreateCompatibleDC) and the BitBlt it to the destination.Quote:
(Bitmaps can be selected for memory device contexts only, and for only one device context at a time.)
Hey, look what I found that I made earlier...
while(GetMessage(&msg, NULL, 0, 0))
your early days, parksie? :D;)
Must have been.
Note to all, replace that with::DCode:while(GetMessage(&msg, NULL, 0, 0) > 0)