Advertisement

insert_img();

Started by June 16, 2000 06:18 PM
5 comments, last by Tiso 24 years, 6 months ago
Can I just plop an image into the middle of a C program? I mean just literlly stick it there around all the text? I''m just curious, I haven''t touched any graphics yet, so, just wondering. ............ Guardian Angel Interactive
I''m not sure what your talking about, i''ll assume that you want to put an image (an actual visual thing) inside of your C code, compile, and get the image in your program. In this case this is impossible, only code (plain text) is allowed through the compiler and the computer wouldn''t know what to do with the image.

However, there are things called compiled sprite, these are images where the image data has been turned into code (i think) and are displayed in the program, this is hardly ever done anymore. There is also the method of appending images to the program''s exe file.

Since you say you haven''t done any graphics stuff before, this is the most common and probably the best way to display an image:

Load the image from the file
Place the image in video memory
Display the image

You''ll need to read a few tutorials on how to do this, and have to start use Direct X to do this under Windows.

+AA_970+
Advertisement
Thanks!

You wouldn''t happen to know where I can find a tutorial or get the source code on how to do this? I''m not anywhere near graphics, but all I wanted to do was have a picture pop up when you typed something like: "Look"

A good tutorial or some source code is all I really need, if you can, thanks! If you can''t, thanks anyway!

............
Guardian Angel Interactive
The method on how to do this depends on what platform your using.

If your using windows, you can get a tutorial on direct x and specifically direct draw, i think there's one right here on gamedev. Then you can either look up the specifications for the file format of the image at www.wotsit.org and write a loader for it, get someone else's code for a loader for the file, or use a function found in DDutil.cpp called DDLoadBitmap, but this can only load bitmaps(bmp files). Once you learn direct x you'll know all about putting stuff in video memory and displaying it. Since your new to graphics i recommend you use the DDLoadBitmap function at first, because the other methods of loading an image involve you learning more advanced things like plotting pixels.

Another thing you could do is use windows GDI functions to load a image. You should only use this if you do not need high performance grapics since it is very slow compared to direct draw. But i've never done this before, and i've never seen a tutorial on it, maybe it's in a windows programming book somewhere.

Here's a tutorial to on direct draw:
http://www.gamedev.net/reference/articles/article608.asp

Also look at the help in the direct x SDK which you'll have to download, since that tutorial is kinda outdated.

Good Luck



+AA_970+

Edited by - +AA_970+ on June 17, 2000 1:12:03 PM
Okay, I think the DDutil.cpp sounds like the best thing for me. I want to wotsit.org and I''m looking around now. What am I supposed to be looking for anyway? Bitmap stuff, graphics what? I''m searching for bitmap stuff right now, and I haven''t found anything yet. Any further help is appreciated.

I do hav Direct X, but I don''t really want to get into yet, right now, all I want to do is display an image in the middle of a bunch of text, thats it.


............
Guardian Angel Interactive
Well sorry to tell you this but the DDutil.cpp functions will only work with direct x. You say all want to do is display an image in the middle of a bunch of text, I forgot to mention that if you are doing a console application (something that comes up in the MS-DOS like screen) this is impossible. You''ll have to either learn windows programming or get a dos compiler and make a MS-DOS program that allows you to switch into a graphics mode.

Also i think i confused you (sorry), wotsit.org is for looking up specification for file formats in case you want to write a loader for a specific file format.

Since you don''t want to get involved with direct x yet, my suggestion is that first you learn some basic windows programming, like how to actually create a window, if you haven''t already done so. Then you can use the windows GDI function to load a bitmap, i think it''s called LoadImage. Perhaps someone can help you get information on doing this, I can''t help much on this because I''ve never really done any windows programming for C/C++ except with direct x.

If you don''t mind programming in and for MS-DOS, you can get the DJGPP compiler (i think there''s a link of the resources page of gamedev) and use Allegro which has alot of stuff to easily do graphics.

Hope this helps




+AA_970+
Advertisement
I give up, I''ll wait until I know C and can buy a good graphics book. Ah well, at least I try.

Although, that compiled spite still interests me a great deal, if anyone knows or happens to stumble upon how to do this, please let me know. Thanks for trying to help me all this time, I really appreciate it.

............
Guardian Angel Interactive

This topic is closed to new replies.

Advertisement