Reading and displaying a bmp file manually

Hello people!

I have a little problem. I have a file, myfile.bmp, and I want to read it
and display it in a sdl surface, all manually.

I have some examples of sdl games, and I have read the BMP specs in wotsit,
but I not have a clear example of this.

All tutorials about this what I read are in VC++ using winapi, what is not
possible for me because I what the examples for win and linux.

Thanks :slight_smile:

SDL_Surface *image;
SDL_Surface *temp;

temp = SDL_LoadBMP(“image.bmp”);
if (temp == NULL) {
printf(“Unable to load bitmap: %s\n”, SDL_GetError());
return 1;
}

image = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);

-michael bernsteinOn May 19, 2005, at 5:51 AM, ALTAIR - wrote:

Hello people!

I have a little problem. I have a file, myfile.bmp, and I want to
read it and display it in a sdl surface, all manually.

I have some examples of sdl games, and I have read the BMP specs in
wotsit, but I not have a clear example of this.

All tutorials about this what I read are in VC++ using winapi, what
is not possible for me because I what the examples for win and linux.

Thanks :slight_smile:


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

ALTAIR - wrote:

Hello people!

I have a little problem. I have a file, myfile.bmp, and I want to read
it and display it in a sdl surface, all manually.

I have some examples of sdl games, and I have read the BMP specs in
wotsit, but I not have a clear example of this.

All tutorials about this what I read are in VC++ using winapi, what is
not possible for me because I what the examples for win and linux.

The sdl_image library should help you a lot. Check the libraries section
from the sdl main page.

I have a little problem. I have a file, myfile.bmp, and I
want to read it and display it in a sdl surface, all manually.

Why manually? What’s wrong with SDL_LoadBMP()?

--Gabriel

Nothing wrong in SDL_LoadBMP() :slight_smile:

I want to read and display a bmp file manually for a simple reason. I want
to use 3D file formats (3DS, MAX, ASE, etc) in my games using SDL+openGL,
all in Windows+Linux.

I was searching in Google about a library for C/C++ for this and I only
found thwo projects what, more o less, are near of this: l3ds is a very
simple library, but are discontinued and it have some errors in some cases;
lib3ds is a very good library, but the documentation is how a very very very
bad sleep.

Later, I search in Google about a simple tutorial for load and display the
more used 3D file format but all of I found are using WinAPI. Of course
this is not valid for me, I want to run in Windows+Linux.

Reading in some forums of Internet about to load file formats, I read a good
start is to load a bmp file format because is a simple and basic format.
Searching in Google about this, all are an incomplete example (only read the
bmp from a file) .

This is the reason I need to learn how lo load and display a bmp file format
manually.