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.

>>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:

http://www.cs.colorado.edu/~main/bgi/doc/initgraph.html

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.

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.

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?

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;
	fp=fopen("C:\\BIN\\tst.bmp","r");
	if(fp==NULL)
	{
		printf("Cannot Open File");
		getch();
		exit(0);
	}

	initgraph(&gd,&gm,"C:\\BGI");

	
	fseek(fp,10,SEEK_SET);
	fread(&dos,4,1,fp);
	fread(&hor,4,1,fp);
	fread(&ver,4,1,fp);

	iregs.h.bl=0x3E; //or 0xFF both didn't worked
	iregs.h.bh=0x38; //or 30 etc. 


	int86(0x10,&iregs,&oregs);

	fseek(fp,dos,SEEK_SET);
	for(int y=ver;y>0;y--)
	{
		for(int x=0;x<hor;x++)
		{
			fread(&pix,1,1,fp);
			putpixel(x,y,pix);
		}
	}




	fclose(fp);


	getch();
	//closegraph();
	printf("AL = %d",oregs.h.al);
	printf("\n");
	printf("AH = %d",oregs.h.ah);

	getch();
}

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

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