Hi Friends,
I want to display a bitmap image in my C++ program running on Turbo C++ 3.0 (16 bit compiler)...
I'm doing a project on graphic calculator.....My code is nearly complete but I am not able to display a bitmap image......I have got a code

http://www.brackeen.com/home/vga/source/djgpp20/bitmap.c.html But that doesn't give the desired output nor any error....Please help me out

Dani AI

Generated

Brief recap: compiled the Borland/BC31 variant but saw no output; correctly pointed out the DJGPP vs Borland split and suggested moving to a modern toolchain. Common causes for “no output” with old Turbo/Borland bitmap loaders are environmental (wrong runtime or OS), file-format mismatches, or memory/model limits in 16-bit compilers.

Practical checklist to diagnose the loader:

  • Confirm the BC31 source is being used (not the DJGPP version) and that the program actually opens the .bmp with fopen(..., "rb") (check for NULL). Use an absolute path if unsure of the working directory.
  • Read the first two bytes to verify the BMP signature ('B' 'M') and check bfOffBits so the code reads pixel data from the right offset. Check every fread/fseek return value and print sizes for debugging.
  • Verify the image bit depth. Many DOS/VGA loaders expect 8-bit indexed (256-colour) BMPs. A 24-bit or RLE-compressed BMP will silently produce garbage or nothing. Convert to a standard uncompressed 8-bit BMP (Paint/GIMP: Save as 256-color bitmap) if the loader assumes mode 13h output.

Important BMP and DOS/VGA notes:

  • BMP scanlines are padded to 4-byte boundaries and are stored bottom-up; compute row stride correctly. Palette entries in Windows BMP are 4 bytes (B,G,R,reserved) and must be scaled to the VGA DAC range if writing a 256-color mode (VGA DAC uses 6-bit values).
  • Turbo C++ 3.0 runs into 64KB segment limits: large images or a single large allocation can fail silently under small memory models. Use a large/huge data model or split allocations, and check allocation returns.

Environment sanity checks and longer-term options:

  • If running on modern Windows, direct VGA mode switching will fail — test under real DOS or DOSBox. A simple sanity test is to try filling the A000:0000 video segment with a constant byte and see if the screen changes; if not, the program never entered graphics mode or is blocked by the OS.
  • For an easier, future-proof route, use a modern compiler and a library (SDL, stb_image, etc.) as suggested; they remove low-level VGA, palette, and memory hassles while supporting many image formats.

Recommended Answers

All 4 Replies

That program is meant to be compiled with . Use the version meant to compile with Borland compilers:

Better yet, stop using such an old compiler and get Dev-C++ and install the SDL (which has built-in support for .BMP files, and with SDL_Image supports .pngs, .jpegs, .tiffs, and many others).

That program is meant to be compiled with . Use the version meant to compile with Borland compilers:

Better yet, stop using such an old compiler and get Dev-C++ and install the SDL (which has built-in support for .BMP files, and with SDL_Image supports .pngs, .jpegs, .tiffs, and many others).

Separate codes aregiven for DJGPP
http://www.brackeen.com/home/vga/source/djgpp20/bitmap.c.html

and Turbo C

I realize that, but I thought you didn't, because you said

I want to display a bitmap image in my C++ program running on Turbo C++ 3.0 (16 bit compiler)...

and linked to the DJGPP version.

Does the Borland version work?

I realize that, but I thought you didn't, because you said

and linked to the DJGPP version.

Does the Borland version work?

Oh sorry for that! Yeah the version worked but showed no output<<

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.