My Object is to display a 24bit color .bmp picture in 24 bit colors via Turbo C Compiler.

Turbo C can display only 16 colors so I will need to use a Windows Interrupt[or something like that] to display the image.

I googled a lot but couldn't get a hint on how to proceed. I know how to display images in turbo C in 16 colors and etc.

If Someone can guide me to the topics/books/websites/functions that will be used/ etc..... that can help me achieve my goal I will be very grateful.

Recommended Answers

All 17 Replies

>>Turbo C can display only 16 colors so I will need to use a Windows Interrupt[or something like that] to display the image.

Not with that compiler you won't. That compiler can not access any of the win32 api functions. Get a 32-bit compiler such as either Code::Blocks or VC++ 2010 Express both are free).

This is more information on initgraph() which changes the screen resolution:

But obviously it doesn't support 24 bit color. If you wanted to force initgraph() to use 24 bit color, you'd have to create your own screen mode driver, which in Turbo C might prove to be very difficult. Turbo C creates DOS programs, hence the limitation with the turbo graphics library. What you need is to work in the Windows world with your video driver built into it, and to do that means to create a full blown windows program, which Turbo C isn't made to compile into. And since you are at the mercy of the limitations of DOS, making your own driver to support 24-bit color may not even be compatible with DOS.

I'd suggest working in 16-bit color and converting your bitmap to a 16 bit bitmap. Otherwise your only good option is to get a windows C compiler and program it in there.

I know about initgraph() and as you said it won't work.

Secondly will VC++ 2010 compile programs written in C?

I don't know if VC++ 2010 compiles ANSI C, but it should, since C++ is supposed to be backwards compatible with C. Your Turbo C graphics library functions, like initgraph() does not exist in windows. If your program is going to be dealing with graphics in windows, id suggest using the OpenGL or DirectX library to draw images to the screen, unless all you are making is a simple User Interface, in which case its simpler to use the windows GDI.

>>Secondly will VC++ 2010 compile programs written in C?

Yes -- it compiles *.cpp files as c++ and *.c files as C.

Well, I made a new file in VC++ with filename.c and made a simple hello world program, but how can I run it??? because the debugging option is grayed out.

Ok, I will try that.

In the mean while I found this.

Although I was not able to make it work like I wanted. But it is quite similar to what I want, I think....

bad link. Try posting it again.

You can't use those interrupts with any of the modern 32-bit compilers. They, and the operating systems, will not permit you direct access to hardware. You have to use standard C functions such as ansi C or win32 api. See these windows console functions

but I am using 16-bit turbo C compiler, so will they work with it?

Yes -- I thought you said you was using a more modern compiler.

I used this interrupt on Turbo C and it didn't worked as intended. tst.bmp is an image with 24 bit colors, and even after using the interrupt it is not displayed in 24 bit colors.

Code is as follows:

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <graphics.h>
#include <dos.h>

void main()
	int gd=0,gm;
	char ch;
	unsigned int pix;
	unsigned long dos,hor,ver;

	union REGS iregs,oregs;

	FILE *fp;
		printf("Cannot Open File");


	fread(&ver,4,1,fp);; //or 0xFF both didn't worked; //or 30 etc. 


	for(int y=ver;y>0;y--)
		for(int x=0;x<hor;x++)


	printf("AL = %d",;
	printf("AH = %d",oregs.h.ah);


m I doing some thing wrong in the code or it is the interrupt?

you can only go 16 bit colors with Turbo C.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.