Hi! I just want to know, how can I open an image file using C in Console mode... Yes... I don't want it to open in MSPaint or anywhere like that. I want to open a 16-color bmp image with VGA Graphics Driver using C in console mode. Actually this is what I want to do exactly. I am new to Graphics using C, and ofcourse creating images using C is a tedious job if the images are complex. So I want to create image outside C using MSPaint, save it in 16 color format (or more if possible), and then open it using C in console mode and further write a program using it as Background!
Please help...

Which operating system and compiler are you using?

Well, I am using Windows Operating system (XP right now), and the compiler I am using is the old and out-dated, the vintage Turbo C/C++ Compiler.
Could I get the help for other compilers too? I guess, the GCC is available for Windows too...

Well in the sense that your old compiler can't generate console programs, but instead it generates DOS programs.

On the plus side, being DOS, you can generate simple low-resolution graphics (which a true Win32 console cannot).

On the downside, you're limiting yourself to lots of DOS specific things, like 640K of memory, 16 bit code, 8.3 filenames, low resolution graphics and so on.

Normally, I suggest getting dev-C++ and downloading the LibSDL graphics package.
http://www.libsdl.org/
http://bloodshed.net/

> On the plus side, being DOS, you can generate simple low-resolution graphics (which a true Win32 console cannot).

Actually, if you get the DC of the console window, you can draw on it like any other. Unfortunately, it is impossible to use a window proc on the console window... so the graphic must be considered volatile...

>>Unfortunately, it is impossible to use a window proc on the console window
I just tried SetWindowLong() to hook into the WinProc inside the os, but it doesn't work. According to MSDN

Windows NT/2000/XP: You cannot change this attribute if the window does not belong to the same process as the calling thread.

I've used SetWindowLong() several times successfully on Mobile 5.0 and PocketPC applications to hook into windows that were not part of my process (no console windows). But I guess that's a feature of those operating systems that doesn't exist on desktop windows. Too bad because it could be useful.

Yeah, I'd love to be able to also (I want to catch window resize events [as opposed to buffer resize events]).

Unfortunately, windows doesn't think your console applications have any business using a window proc...

Alas.

Hello friends! That may be quiet embarassing for me, but I have to tell you all, that I am such a newbie to this all that I am not able to get anything you are talking about. Could you please explain what Windows proc is, and what you mean by graphics being taken to be volatile?

Yeah, sorry about that. You don't need to worry about window procedures.

By volatile is meant that it can be destroyed at any time. Since you can't have a window proc, you can't be informed at all the times it needs to be re-drawn. So, while you are technically able to draw in the console window, it doesn't make much sense to do so, since you can't guarantee that the image won't be destroyed before you would like it to.

Since you are using TC, stick with the VGA graphics stuff. I would stick to using a simple, easy-to-read file format like BMP or TGA.

Hope this helps.

This article has been dead for over six months. Start a new discussion instead.