Mail Archives: djgpp/1998/11/15/07:00:42
Message-Id: | <199811151151.LAA25451@remus.clara.net>
|
From: | "Arthur" <arfa AT clara DOT net>
|
To: | <djgpp AT delorie DOT com>
|
Subject: | RE: How Do I Display A Bitmap? W/ Allegro
|
Date: | Sun, 15 Nov 1998 11:50:34 -0000
|
X-Priority: | 3 (Normal)
|
X-MSMail-Priority: | Normal
|
X-Mailer: | Microsoft Outlook 8.5, Build 4.71.2173.0
|
In-Reply-To: | <364e3eb1.16274376@news.flash.net>
|
X-MIMEOLE: | Produced By Microsoft MimeOLE V4.72.3110.3
|
Importance: | Normal
|
Reply-To: | djgpp AT delorie DOT com
|
> >How do I display a bit map on the screen with allegro?
> >Here is what I have so far.
>
> [snip]
>
> It's a start. Don't feel bad. I had problems with this too. Take a
> look at my post above, or you can just look at this bit of code
> instead... (It might help to view this with a fixed-with font.)
>
> #include <stdio.h>
> #include "allegro.h"
>
> BITMAP *bitmap_name;
> PALETTE palette_name;
>
> main()
^^^^^^^^
This should be "int main(void)" or "int main()"
> {
> allegro_init();
> set_gfx_mode(GFX_AUTODETECT, width, height, 0, 0);
The variables width and height should be defined and set before now.
> /* Load our bitmap into memory. */
> bitmap_name = load_bitmap("filename.xxx", palette_name);
>
> set_palette(palette_name);
>
> /* Display the image on the screen. */
> blit(bitmap_name, screen, 0, 0, (SCREEN_W-bitmap_name->w,)/2,
> (SCREEN_H-bitmap_name->h,)/2, bitmap_name->w,
> bitmap_name->h);
This will centre the bitmap. If the bitmap is the same size as the screen
you can use "blit(bitmap_name, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);"
Also, don't you need to mark broken lines with a "\" in DJGPP?
> /* Wait for a keypress */
> readkey();
> destroy_bitmap(bitmap_name);
> return 0;
> }
James Arthur
jaa AT arfa DOT clara DOT net
ICQ#15054819
- Raw text -