Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

HOW TO PUT COLOR IMAGES ON SCREEN BY USING TURBO C++ 3.0 DOS VER.

i am trying to do some demo on my front page of my sistem, but can't do. May somebody please kindly send

some tips or examples to guide me ? Please.




Comments

  • : i am trying to do some demo on my front page of my sistem, but can't do. May somebody please kindly send

    : some tips or examples to guide me ? Please

    There are 5 functions you need to use that are

    included in the BGI. After you have drawn the image

    on the screen, you need to declare a void pointer

    (void *image = malloc( imagesize( x1, y1, x2, y2 ) );)

    this will allocate memory for the image. To get the image

    into memory you type: getimage( x1, y1, x2, y2, image );

    now you can put the image using putimage( x1, y1, x2, y2, op );




  • : i am trying to do some demo on my front page of my sistem, but can't do. May somebody please kindly send

    : some tips or examples to guide me ? Please.




    SIMPLICITY!


    unsigned char far *VIDEO = (char far *)0xa0000000l;

    // pointer to video memory

    // to plot pixel-> VIDEO[y*320+x]=color; |or| VIDEO[(y<<8)+(y<<6)+x]=color;<br>
    // the 2 bit shifts should be faster


    so simply load your image into a segment of memory

    and use:


    memcpy(*VIDEO, *IMAGE, x) //where x is the number of BYTES to copy


    to load a RAW image (RAW file format)



    FILE *in;


    if ((in = fopen("image.raw", "rb")) == NULL)

    {

    printf("Ooops cannot open file :(
    ", filename);

    exit(1);

    }

    fseek(in, 18, SEEK_SET); //skip header

    fread(palette, 768, 1, in); //load palette

    fread(IMAGE, width*height, 1, in); //load image

    fclose(in); //65536


    you sould now change your palette to match by using your favorite

    palette set routine


    remember: to write to video you must me in video mode!!!


    _AX=0x13; //load 13hex (19 dec) into register AX

    geninterrupt(0x10); //put register ax into interrupt 0x10 (video int)


    and use _AX=0x03; to set text mode


    create an array for palette

    char palette[768]; // (256*3 [one for RGB])




    change it then copy your palette to video:




    outp(0x3c8,0);

    for (i = 0; i < 256; i++)

    {

    outp(0x3c9, palette[i*3+2]);

    outp(0x3c9, palette[i*3+1]);

    outp(0x3c9, palette[i*3+0]);

    }




    it's really very simple....

    hope this helps and happy coding!!!




  • : : i am trying to do some demo on my front page of my sistem, but can't do. May somebody please kindly send

    : : some tips or examples to guide me ? Please

    : There are 5 functions you need to use that are

    : included in the BGI. After you have drawn the image

    : on the screen, you need to declare a void pointer

    : (void *image = malloc( imagesize( x1, y1, x2, y2 ) );)

    : this will allocate memory for the image. To get the image

    : into memory you type: getimage( x1, y1, x2, y2, image );

    : now you can put the image using putimage( x1, y1, x2, y2, op );

    :





Sign In or Register to comment.