Importing graphics with Borland 5 compiler
I am taking classes in C++, and am reaching the end of the year. However, the class does not cover graphics, and I basically taught myself that, through my prior knowledge of various other languages.
While I have gotten the hang of graphics quite easily, I was wondering if there was a quick and easy way to load an external image from the disk, through use of libraries or an included function.
On another topic, while using the Windows BGI library, is there any way to have the other output window open up, and just use the Windows BGI window? The other window has my project title as it's title, and all of the iostream functions are executed here. While using the DOS BGI library, iostream functions were done in the same window as the graphics.
All help is greatly appreciated.
>> I was wondering if there was a quick and easy way to load an external image from the disk, through use of libraries or an included function
You can use getimage() to get an area of the screen and put it in an array. You could then write this array to disk. Later, when you want to display the image, you can read it from file into an array and then use putimage to transfer the image on to the screen.
I don't believe we have done files quite yet, and so I don't know how to load from an external file...
Is there any way I can use the putimage() function with an already existing bitmap?
If anyone can just tell me the libraries to include, and the basics of what to do, I'm pretty sure I can figure out the rest for myself...
>> Is there any way I can use the putimage() function with an already existing bitmap?
Yes, provided it is in the correct format.
>> If anyone can just tell me the libraries to include,
putimage() is a function of the BGI library. Since it appears that you're already using the BGI library, you don't need to include anything else.
The format for putimage is putimage(int __left, int __top, const void far *__bitmap, int __op), as I'm sure you know. However, the bitmap points to a bitmap already in memory. How would you go about loading a bitmap saved to a disk into memory, so I can use it with the putimage operation?
Sorry for the lack of clarity.
>> How would you go about loading a bitmap saved to a disk into memory.
fread() or blockread(), I guess :)