www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/13/05:47:10

From: Einar <"eincar"@[EINAR]vip.cybercity.dk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Displaying bmps
Date: Thu, 13 Aug 1998 11:26:26 +0200
Organization: CyberCity Internet
Lines: 41
Message-ID: <6quaud$lki$2@news.cybercity.dk>
References: <19980812161854 DOT 16290 DOT qmail AT hotmail DOT com>
NNTP-Posting-Host: 195.8.142.108
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Jakes....... Who else?? wrote:
> 
> how the &&*%$£"* you load and display a bmp file on the screen!
> But for the life of me, I can't find any source code on how to do
> 

If you have allegro, you can use the following lines of code as an
example:

#include <allegro.h>

#define XRES 640 //The horizontal screen resolution, can be changed.
#define YRES 480 //The vertical screen resolution, can be changed.

BITMAP *test;
PALETTE p;

int main()
{
 allegro_init();//Activates Allegro
 install_keyboard();

 set_gfx_mode(GFX_AUTODETECT,XRES,YRES,0,0);//Defines the graphic screen

 test=load_bitmap("picture.bmp", p);//Loads test BMP into memory.
 set_palette(p);//Sets up a palette with color scheme from BMP.
 blit(test,screen,0,0,0,0,test->w,test->h);//Showes BMP on the screen.

 readkey();//Waits for a key to be pressed.
 allegro_exit();//Exits Allegro.
 destroy_bitmap(test);//removes BMP from memory.
 return 0;
}

Hope this can show you the way ;)

Einar.

-------------------------------------------------------

Remove [EINAR] from e-mail address when replying

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019