Bitmaps

This is a discussion on Bitmaps within the C++ Programming forums, part of the General Programming Boards category; Hello this is Ronald I use Borland c++ 3.1 I would like to know how to display images in DOS...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    2

    Bitmaps

    Hello this is Ronald

    I use Borland c++ 3.1

    I would like to know how to display images in DOS

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    True DOS: Use mode 13
    Console DOS: Not possible
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Hello this is Jason

    I use MSVC++ 6

    Read this.

  4. #4
    Registered User
    Join Date
    May 2002
    Posts
    2

    Thanx but a problem


    #include <dos.h>
    #include <stdio.h>
    #include <string.h>
    #include <conio.h>

    char far *Screen;

    //Sets the display to VGA 320x200x256
    void VGAScreen (){
    union REGS r;
    r.h.ah = 0;
    r.h.al = 0x13;
    int86(0x10, &r, &r);
    return;
    }

    //Goes back to textmode
    void TextScreen (){
    union REGS r;
    r.h.ah = 0;
    r.h.al = 0x3;
    int86(0x10, &r, &r);
    return;
    }

    //This sets a DAC register to a specific Red Green Blue-value
    int SetDAC (unsigned char DAC, unsigned char R, unsigned char G, unsigned char B)
    {
    outportb (0x3C8, DAC);
    outportb (0x3C9, R);
    outportb (0x3C9, G);
    outportb (0x3C9, B);
    return 0;
    }

    int LoadBMP (){
    struct BMPHeader {
    unsigned short bfType;
    long bfSize,
    bfReserved,
    bfOffBits,
    biSize,
    biWidth,
    biHeight;
    unsigned short biPlanes,
    biBitCount;
    long biCompression,
    biSizeImage,
    biXPelsPerMeter,
    biYPelsPerMeter,
    biClrUsed,
    biClrImportant;
    } Header;
    FILE *BMPFile;

    unsigned char c, Palette[256][4];
    char *filename = "test.bmp";

    unsigned int offset, lines, paddedWidth;

    //This checks for the file
    BMPFile = fopen (filename, "rb");
    if (BMPFile == NULL) {
    printf ("Cant open file.");
    return 1;
    }

    //Read the headerinformation
    fread (&Header, 54, 1, BMPFile);

    if (Header.bfType != 19778 || Header.bfReserved != 0 || Header.biPlanes !=1) {
    //Not a valid bitmap file - don't display
    printf ("Not a valid bitmap.");
    fclose (BMPFile);
    return 1;
    }
    if (Header.biCompression != 0) {
    //Compressed file - don't display
    printf ("Compressed file.");
    fclose (BMPFile);
    return 1;
    }
    if (Header.biBitCount != 8) {
    //If the file is other than 8-bit dont read.
    printf ("Not an 8-bit bitmap.");
    fclose (BMPFile);
    return 1;
    }
    if (Header.biWidth > 320 || Header.biHeight > 200) {
    //If its larger than 320*200 dont load.
    printf ("Size too large.");
    fclose (BMPFile);
    return 1;
    }

    //Load the palette info
    fread (&Palette, 1024, 1, BMPFile);
    for (c = 0; c < 255; c++)
    SetDAC (c, Palette[c][2] >> 2, Palette[c][1] >> 2, Palette[c][0] >> 2);

    offset = (100 + (Header.biHeight >> 1)) * 320 + 160 - (Header.biWidth >> 1);

    lines = 0;

    paddedWidth = Header.biWidth & 0xFFFC;
    if (Header.biWidth != paddedWidth) paddedWidth += 4;
    //Loop for reading lines
    while (lines < Header.biHeight) {
    fread (Screen + offset, paddedWidth, 1, BMPFile);
    offset -= 320;
    lines++;
    }
    fclose (BMPFile);
    return 0;
    }



    int main (int argcount, char *argvalue[]){
    //Set up a pointer in vga memory
    Screen = (char far *)0xA0000000L;

    VGAScreen ();
    LoadBMP();
    getch ();
    TextScreen ();
    return 0;
    }



    This code is all fine but I am acquainted with BGI graphics not the UNION and thise variables I even don't know they are.

    What I want to do is to develop a GUI. Therefore I need to use text also along with the picture.
    I would like to do it with outtextxy().
    If there is some other way please tell. Please remember that I am just learning graphics and I got this project to make. That is why I am seeking help.
    [/FONT][/FONT]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Drawing bitmaps efficiently
    By scwizzo in forum Windows Programming
    Replies: 28
    Last Post: 06-30-2009, 08:25 PM
  2. DX9 Not Displaying Bitmaps
    By Sentral in forum Game Programming
    Replies: 9
    Last Post: 01-31-2006, 04:35 AM
  3. MFC: Multiple clicks shows multiple bitmaps - how?
    By BrianK in forum Windows Programming
    Replies: 0
    Last Post: 06-20-2004, 07:25 PM
  4. Loading bitmaps with createfile() +CreateDIBSection
    By Stevo in forum Windows Programming
    Replies: 7
    Last Post: 05-13-2004, 09:22 PM
  5. using standard bitmaps in the toolbar editor
    By Kibble in forum Windows Programming
    Replies: 0
    Last Post: 12-23-2002, 07:43 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21