LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-26-2004, 09:09 AM   #1
hylke
Member
 
Registered: Apr 2004
Location: the Netherlands
Distribution: Ubuntu 7.04
Posts: 329

Rep: Reputation: 30
Displaying Bitmap


Hello
I got the following code to display a bitmap, but it doesn't work.
PHP Code:
#include <iostream>
#include <GL/glut.h>

using namespace std;

void LoadImage(char *filenameGLsizei *widthGLsizei *heightchar *pixels);
void init();
void reshape(int wint h);
void display();

char *pixels;
GLsizei ImgWidthImgHeight;

int main(int argcchar **argv)
{
    
glutInit(&argcargv);
    
glutInitDisplayMode(GLUT_RGB GLUT_DOUBLE);
    
glutInitWindowSize(500500);
    
glutInitWindowPosition(    100100);
    
glutCreateWindow("test");
    
init();
    
glutDisplayFunc(display);
    
glutReshapeFunc(reshape);
    
glutMainLoop();
    return 
0;
}

void LoadImage(char *filenameGLsizei *widthGLsizei *heightchar *pixels)
{
    
FILE *file;
    
unsigned long size;                 // size of the image in bytes.
    
unsigned long i;                    // standard counter.
    
unsigned short int planes;          // number of planes in image (must be 1) 
    
unsigned short int bpp;             // number of bits per pixel (must be 24)
    
char temp;                          // temporary color storage for bgr-rgb conversion.

    
if ((file fopen(filename"rb"))==NULL)
    
cout << "File Not Found: " << filename << "\n";
    
    
fseek(file18SEEK_CUR);

    if ((
fread(width41file)) != 1)
    
cout << "Error reading width from " << filename << endl;
     
    if ((
fread(height41file)) != 1)
    
cout << "Error reading height from " << filename << ".\n";
    
    
size =  *width *  *height 3;
    
    if ((
fread(&planes21file)) != 1)
    
cout << "Error reading planes from " << filename << ".\n";
    
    if (
planes != 1)
    
cout << "Planes from" << filename << " is not 1 but: " << planes << endl;

    if ((
fread(&bpp21file)) != 1
        
cout << "Error reading bpp from " << filename << endl;
    
    if (
bpp != 24)
        
cout << "Bpp from " << filename << " is not 24: " << bpp << endl;
    
    
fseek(file24SEEK_CUR);

    
pixels = (char *) malloc(size);
    if(
pixels == NULL)
       
cout << "Error: Allocating memmory failed.\n";
    
    if (
pixels == NULL)
        
cout << "Error allocating memory for color-corrected image data" << endl;

    if ((
fread(pixelssize1file)) != 1)
        
cout << "Error reading image data from " << filename << endl;

    for (
i=0;i<size;i+=3
    { 
// reverse all of the colors. (bgr -> rgb)
        
temp pixels[i];
        
pixels[i] = pixels[i+2];
        
pixels[i+2] = temp;
    }
}

void display()
{
    
glClear(GL_COLOR_BUFFER_BIT);
    
glRasterPos2f(0.00.0);
    
glDrawPixels(ImgWidthImgHeightGL_RGBGL_BITMAPpixels);
    
glutSwapBuffers();
}

void init()
{
    
glShadeModel(GL_SMOOTH);
    
glClearColor(0.00.00.00.0);
    
LoadImage("Load.dat", &ImgWidth, &ImgHeightpixels);
}

void reshape(int wint h)
{
    
glViewport(00wh);
    
glMatrixMode(GL_PROJECTION);
    
glLoadIdentity();
    
glOrtho(-5.05.0, -5.05.0, -5.05.0);
    
glMatrixMode(GL_MODELVIEW);
    
glLoadIdentity();

I've renamed the bitmap Load.bmp to Load.dat
I have no idea what i do wrong.
Can somebody please help me?
Thanx Hylke
 
Old 08-26-2004, 09:32 AM   #2
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
You have a global pixels variable, but your LoadImage function also takes in a variable named pixels, which will mask your global one. Then when you allocate memory for pixels, you are allocating memory for the local variable pixels, not the global one, which is the one you use later on.

You need to do one of 2 things.

1. Get rid of the pixels parameter in LoadImage and just work with the global pixels variable...

2. Pass in pixels as a char** and when you call it use &pixels so that the address of the global pixels variable is passed in, so that when you allocate memory, the global pixels variable can get an address to the newly allocated memory. Obviously, if you do this, when you allocate or use pixels within the function you then have to use it as *pixels...

Last edited by deiussum; 08-26-2004 at 09:35 AM.
 
Old 08-26-2004, 09:53 AM   #3
hylke
Member
 
Registered: Apr 2004
Location: the Netherlands
Distribution: Ubuntu 7.04
Posts: 329

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by deiussum
You have a global pixels variable, but your LoadImage function also takes in a variable named pixels, which will mask your global one. Then when you allocate memory for pixels, you are allocating memory for the local variable pixels, not the global one, which is the one you use later on.

You need to do one of 2 things.

1. Get rid of the pixels parameter in LoadImage and just work with the global pixels variable...

2. Pass in pixels as a char** and when you call it use &pixels so that the address of the global pixels variable is passed in, so that when you allocate memory, the global pixels variable can get an address to the newly allocated memory. Obviously, if you do this, when you allocate or use pixels within the function you then have to use it as *pixels...
I wanna do the second thing.
My code looks like this now:
PHP Code:
#include <iostream>
#include <GL/glut.h>

using namespace std;

void LoadImage(char *filenameGLsizei *widthGLsizei *heightchar **pixels);
void init();
void reshape(int wint h);
void display();

char mypixels;
GLsizei ImgWidthImgHeight;

int main(int argcchar **argv)
{
    
glutInit(&argcargv);
    
glutInitDisplayMode(GLUT_RGB GLUT_DOUBLE);
    
glutInitWindowSize(500500);
    
glutInitWindowPosition(    100100);
    
glutCreateWindow("test");
    
init();
    
glutDisplayFunc(display);
    
glutReshapeFunc(reshape);
    
glutMainLoop();
    return 
0;
}

void LoadImage(char *filenameGLsizei *widthGLsizei *heightchar **pixels)
{
    
FILE *file;
    
unsigned long size;                 // size of the image in bytes.
    
unsigned long i;                    // standard counter.
    
unsigned short int planes;          // number of planes in image (must be 1) 
    
unsigned short int bpp;             // number of bits per pixel (must be 24)
    
char temp;                          // temporary color storage for bgr-rgb conversion.

    
if ((file fopen(filename"rb"))==NULL)
    
cout << "File Not Found: " << filename << "\n";
    
    
fseek(file18SEEK_CUR);

    if ((
fread(width41file)) != 1)
    
cout << "Error reading width from " << filename << endl;
     
    if ((
fread(height41file)) != 1)
    
cout << "Error reading height from " << filename << ".\n";
    
    
// calculate the size (assuming 24 bits or 3 bytes per pixel).
    
size =  *width *  *height 3;
    
    if ((
fread(&planes21file)) != 1)
    
cout << "Error reading planes from " << filename << ".\n";
    
    if (
planes != 1)
    
cout << "Planes from" << filename << " is not 1 but: " << planes << endl;

    if ((
fread(&bpp21file)) != 1
        
cout << "Error reading bpp from " << filename << endl;
    
    if (
bpp != 24)
        
cout << "Bpp from " << filename << " is not 24: " << bpp << endl;
    
    
fseek(file24SEEK_CUR);

    *
pixels = (char *) malloc(size);
    if(*
pixels == NULL)
       
cout << "Error: Allocating memmory failed.\n";
    
    if (*
pixels == NULL)
        
cout << "Error allocating memory for color-corrected image data" << endl;

    if ((
fread(pixelssize1file)) != 1)
        
cout << "Error reading image data from " << filename << endl;

    for (
i=0;i<size;i+=3
    { 
// reverse all of the colors. (bgr -> rgb)
        
temp = *pixels[i];
        *
pixels[i] = *pixels[i+2];
        *
pixels[i+2] = temp;
    }
}

void display()
{
    
glClear(GL_COLOR_BUFFER_BIT);
    
glRasterPos2f(0.00.0);
    
glDrawPixels(ImgWidthImgHeightGL_RGBGL_BITMAPmypixels);
    
glutSwapBuffers();
}

void init()
{
    
glShadeModel(GL_SMOOTH);
    
glClearColor(0.00.00.00.0);
    
LoadImage("Load.dat", &ImgWidth, &ImgHeight, &mypixels);
}

void reshape(int wint h)
{
    
glViewport(00wh);
    
glMatrixMode(GL_PROJECTION);
    
glLoadIdentity();
    
glOrtho(-5.05.0, -5.05.0, -5.05.0);
    
glMatrixMode(GL_MODELVIEW);
    
glLoadIdentity();

My errors are:
Quote:
gdptest.cpp: In function `void display()':
gdptest.cpp:87: error: invalid conversion from `char' to `const GLvoid*'
gdptest.cpp: In function `void init()':
gdptest.cpp:95: error: cannot convert `char*' to `char**' for argument `4' to `
void LoadImage(char*, GLsizei*, GLsizei*, char**)'
So what did i do wrong?
Thanx Hylke

EDIT:
I just added:
PHP Code:
 glPixelStorei(GL_UNPACK_ALIGNMENT1); 
To the code :-D, but ofcourse, i still got the errors.

Last edited by hylke; 08-26-2004 at 09:54 AM.
 
Old 08-26-2004, 11:05 AM   #4
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
You now have:
char mypixels;

That should be:

char *mypixels;
 
Old 08-26-2004, 12:44 PM   #5
hylke
Member
 
Registered: Apr 2004
Location: the Netherlands
Distribution: Ubuntu 7.04
Posts: 329

Original Poster
Rep: Reputation: 30
It doesn't give any errors anymore, but it does give an segmentation fault.
What gdb says:
Quote:
Starting program: /home/hylke/Desktop/Teacher Killer/gdptest

Program received signal SIGSEGV, Segmentation fault.
0x403944c7 in memcpy () from /lib/libc.so.6
My code:
PHP Code:
#include <iostream>
#include <GL/glut.h>

using namespace std;

void LoadImage(char *filenameGLsizei *widthGLsizei *heightchar **pixels);
void init();
void reshape(int wint h);
void display();

char *mypixels;
GLsizei ImgWidthImgHeight;

int main(int argcchar **argv)
{
    
glutInit(&argcargv);
    
glutInitDisplayMode(GLUT_RGB GLUT_DOUBLE);
    
glutInitWindowSize(500500);
    
glutInitWindowPosition(    100100);
    
glutCreateWindow("test");
    
init();
    
glutDisplayFunc(display);
    
glutReshapeFunc(reshape);
    
glutMainLoop();
    return 
0;
}

void LoadImage(char *filenameGLsizei *widthGLsizei *heightchar **pixels)
{
    
FILE *file;
    
unsigned long size;                 // size of the image in bytes.
    
unsigned long i;                    // standard counter.
    
unsigned short int planes;          // number of planes in image (must be 1) 
    
unsigned short int bpp;             // number of bits per pixel (must be 24)
    
char temp;                          // temporary color storage for bgr-rgb conversion.

    
if ((file fopen(filename"rb"))==NULL)
    
cout << "File Not Found: " << filename << "\n";
    
    
fseek(file18SEEK_CUR);

    if ((
fread(width41file)) != 1)
    
cout << "Error reading width from " << filename << endl;
     
    if ((
fread(height41file)) != 1)
    
cout << "Error reading height from " << filename << ".\n";
    
    
// calculate the size (assuming 24 bits or 3 bytes per pixel).
    
size =  *width *  *height 3;
    
    if ((
fread(&planes21file)) != 1)
    
cout << "Error reading planes from " << filename << ".\n";
    
    if (
planes != 1)
    
cout << "Planes from" << filename << " is not 1 but: " << planes << endl;

    if ((
fread(&bpp21file)) != 1
        
cout << "Error reading bpp from " << filename << endl;
    
    if (
bpp != 24)
        
cout << "Bpp from " << filename << " is not 24: " << bpp << endl;
    
    
fseek(file24SEEK_CUR);

    *
pixels = (char *) malloc(size);
    if(*
pixels == NULL)
       
cout << "Error: Allocating memmory failed.\n";
    
    if (*
pixels == NULL)
        
cout << "Error allocating memory for color-corrected image data" << endl;

    if ((
fread(pixelssize1file)) != 1)
        
cout << "Error reading image data from " << filename << endl;

    for (
i=0;i<size;i+=3
    { 
// reverse all of the colors. (bgr -> rgb)
        
temp = *pixels[i];
        *
pixels[i] = *pixels[i+2];
        *
pixels[i+2] = temp;
    }
}

void display()
{
    
glClear(GL_COLOR_BUFFER_BIT);
    
glRasterPos2f(0.00.0);
    
glDrawPixels(ImgWidthImgHeightGL_RGBGL_BITMAPmypixels);
    
glutSwapBuffers();
}

void init()
{
    
glShadeModel(GL_SMOOTH);
    
glClearColor(0.00.00.00.0);
    
glPixelStorei(GL_UNPACK_ALIGNMENT1);
    
LoadImage("Load.dat", &ImgWidth, &ImgHeight, &mypixels);
}

void reshape(int wint h)
{
    
glViewport(00wh);
    
glMatrixMode(GL_PROJECTION);
    
glLoadIdentity();
    
glOrtho(-5.05.0, -5.05.0, -5.05.0);
    
glMatrixMode(GL_MODELVIEW);
    
glLoadIdentity();

I hope you can help me.
Thanx Hylke
 
Old 08-26-2004, 01:32 PM   #6
aiza
LQ Newbie
 
Registered: Jul 2004
Posts: 18

Rep: Reputation: 0
Quote:
Originally posted by hylke
It doesn't give any errors anymore, but it does give an segmentation fault.
What gdb says:

My code:
PHP Code:
#include <iostream>
#include <GL/glut.h>

using namespace std;

void LoadImage(char *filenameGLsizei *widthGLsizei *heightchar **pixels);
void init();
void reshape(int wint h);
void display();

char *mypixels;
GLsizei ImgWidthImgHeight;

int main(int argcchar **argv)
{
    
glutInit(&argcargv);
    
glutInitDisplayMode(GLUT_RGB GLUT_DOUBLE);
    
glutInitWindowSize(500500);
    
glutInitWindowPosition(    100100);
    
glutCreateWindow("test");
    
init();
    
glutDisplayFunc(display);
    
glutReshapeFunc(reshape);
    
glutMainLoop();
    return 
0;
}

void LoadImage(char *filenameGLsizei *widthGLsizei *heightchar **pixels)
{
    
FILE *file;
    
unsigned long size;                 // size of the image in bytes.
    
unsigned long i;                    // standard counter.
    
unsigned short int planes;          // number of planes in image (must be 1) 
    
unsigned short int bpp;             // number of bits per pixel (must be 24)
    
char temp;                          // temporary color storage for bgr-rgb conversion.

    
if ((file fopen(filename"rb"))==NULL)
    
cout << "File Not Found: " << filename << "\n";
    
    
fseek(file18SEEK_CUR);

    if ((
fread(width41file)) != 1)
    
cout << "Error reading width from " << filename << endl;
     
    if ((
fread(height41file)) != 1)
    
cout << "Error reading height from " << filename << ".\n";
    
    
// calculate the size (assuming 24 bits or 3 bytes per pixel).
    
size =  *width *  *height 3;
    
    if ((
fread(&planes21file)) != 1)
    
cout << "Error reading planes from " << filename << ".\n";
    
    if (
planes != 1)
    
cout << "Planes from" << filename << " is not 1 but: " << planes << endl;

    if ((
fread(&bpp21file)) != 1
        
cout << "Error reading bpp from " << filename << endl;
    
    if (
bpp != 24)
        
cout << "Bpp from " << filename << " is not 24: " << bpp << endl;
    
    
fseek(file24SEEK_CUR);

    *
pixels = (char *) malloc(size);
    if(*
pixels == NULL)
       
cout << "Error: Allocating memmory failed.\n";
    
    if (*
pixels == NULL)
        
cout << "Error allocating memory for color-corrected image data" << endl;

    if ((
fread(pixelssize1file)) != 1)
        
cout << "Error reading image data from " << filename << endl;

    for (
i=0;i<size;i+=3
    { 
// reverse all of the colors. (bgr -> rgb)
        
temp = *pixels[i];
        *
pixels[i] = *pixels[i+2];
        *
pixels[i+2] = temp;
    }
}

void display()
{
    
glClear(GL_COLOR_BUFFER_BIT);
    
glRasterPos2f(0.00.0);
    
glDrawPixels(ImgWidthImgHeightGL_RGBGL_BITMAPmypixels);
    
glutSwapBuffers();
}

void init()
{
    
glShadeModel(GL_SMOOTH);
    
glClearColor(0.00.00.00.0);
    
glPixelStorei(GL_UNPACK_ALIGNMENT1);
    
LoadImage("Load.dat", &ImgWidth, &ImgHeight, &mypixels);
}

void reshape(int wint h)
{
    
glViewport(00wh);
    
glMatrixMode(GL_PROJECTION);
    
glLoadIdentity();
    
glOrtho(-5.05.0, -5.05.0, -5.05.0);
    
glMatrixMode(GL_MODELVIEW);
    
glLoadIdentity();

I hope you can help me.
Thanx Hylke
Replace
glDrawPixels(ImgWidth, ImgHeight, GL_RGB, GL_BITMAP, mypixels);
with
glDrawPixels(ImgWidth, ImgHeight, GL_RGB, GL_BITMAP, &mypixels);

Good luck
Aiza
 
Old 08-26-2004, 02:15 PM   #7
hylke
Member
 
Registered: Apr 2004
Location: the Netherlands
Distribution: Ubuntu 7.04
Posts: 329

Original Poster
Rep: Reputation: 30
Thanx
But now i got another segmentation fault:
Quote:
Starting program: /home/hylke/Desktop/Teacher Killer/gdptest

Program received signal SIGSEGV, Segmentation fault.
0x403944c7 in memcpy () from /lib/libc.so.6
Thanx for your help so far.
Hylke
 
Old 08-26-2004, 02:39 PM   #8
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
GL_BITMAP isn't what you want for the type parameter of glDrawPixels. That basically says that each pixel is stored in a single bit, which it isn't. A "bitmap" in this case is a "true" bitmap where each bit of data represents whether a pixel is "on" or "off."

That parameter tells it what sort of data type you are using, which in this case should be GL_BYTE or GL_UNSIGNED_BYTE.

So it should be:
glDrawPixels(ImgWidth, ImgHeight, GL_RGB, GL_UNSIGNED_BYTE, mypixels);

Last edited by deiussum; 08-26-2004 at 02:51 PM.
 
Old 08-26-2004, 03:11 PM   #9
hylke
Member
 
Registered: Apr 2004
Location: the Netherlands
Distribution: Ubuntu 7.04
Posts: 329

Original Poster
Rep: Reputation: 30
After i've changed that and then compiled it, it still gave an segmentation fault, and still the same error
That it's so hard to write a program to display a bitmap
Could you please help me again, debug the source?
Thanx Hylke
 
Old 08-26-2004, 03:52 PM   #10
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
Ok... I went through your code and got all your segmentation faults fixed. It was occuring in the LoadImage function. Here's the new code for that function, with the parts I changed in bold:

Code:
void LoadImage(char *filename, GLsizei *width, GLsizei *height, char **pixels)
{
    FILE *file;
    unsigned long size;                 // size of the image in bytes.
    unsigned long i;                    // standard counter.
    unsigned short int planes;          // number of planes in image (must be 1)

    unsigned short int bpp;             // number of bits per pixel (must be 24)

    char temp;                          // temporary color storage for bgr-rgb conversion.

    if ((file = fopen(filename, "rb"))==NULL)
    cout << "File Not Found: " << filename << "\n";

    fseek(file, 18, SEEK_CUR);

    if ((i = fread(width, 4, 1, file)) != 1)
    cout << "Error reading width from " << filename << endl;

    if ((i = fread(height, 4, 1, file)) != 1)
    cout << "Error reading height from " << filename << ".\n";

    // calculate the size (assuming 24 bits or 3 bytes per pixel).
    size =  *width *  *height * 3;

    if ((fread(&planes, 2, 1, file)) != 1)
    cout << "Error reading planes from " << filename << ".\n";

    if (planes != 1)
    cout << "Planes from" << filename << " is not 1 but: " << planes << endl;

    if ((i = fread(&bpp, 2, 1, file)) != 1)
        cout << "Error reading bpp from " << filename << endl;

    if (bpp != 24)
        cout << "Bpp from " << filename << " is not 24: " << bpp << endl;

    fseek(file, 24, SEEK_CUR);

    *pixels = (char *) malloc(size);

    if(*pixels == NULL)
       cout << "Error: Allocating memmory failed.\n";

    if (*pixels == NULL)
        cout << "Error allocating memory for color-corrected image data" << endl;

    if ((i = fread(*pixels, size, 1, file)) != 1)
        cout << "Error reading image data from " << filename << endl;

    for (i=0;i<size;i+=3)
    { // reverse all of the colors. (bgr -> rgb)
        temp = (*pixels)[i];
        (*pixels)[i] = (*pixels)[i+2];
        (*pixels)[i+2] = temp;
    }

}
There still appears to be a problem with your image loading code. BMP files have padding at the end of each row to ensure that each rows lines up on a 4(?) byte boundary. It doesn't appear that you have taken that into account. I didn't take the time to open up the BMP spec and fix that part for you, though...

Last edited by deiussum; 08-26-2004 at 04:09 PM.
 
Old 08-27-2004, 12:55 PM   #11
hylke
Member
 
Registered: Apr 2004
Location: the Netherlands
Distribution: Ubuntu 7.04
Posts: 329

Original Poster
Rep: Reputation: 30
Sorry, but i have no idea how to it(i just got the source from nehe and changed it a bit).
I found on google that the padding is (char 0), but i have no idea how to ad it to my code.
Thanx Hylke

Last edited by hylke; 08-27-2004 at 12:56 PM.
 
Old 08-27-2004, 02:29 PM   #12
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
Your code will be fine for BMP files that are of appropriate dimensions to be used as a texture. (Dimensions for textures must be a power of 2, such as 1,2,4,8,16,32,64,128,256,512,1024, etc...) However, there is no such restriction when using glDrawPixels, so if you plan to use your BMP loading routing to load a BMP that does not have dimensions that are a power of 2, you will likely want to handle the padding.

If you check wotsit.org, you can find the file format specification for BMP and many other file formats. You'll probably want to check that to make sure my memory is correct about each row being on a 4 byte boundary. It could be 8, but I think it was 4....

Basically the padding is at the end of each row of data. So say you have an image that has dimensions of 15x15 pixels... One row of data would take up 15*3 = 45 bytes, because there are 3 bytes for each pixel (1R 1G 1B). Now if you take 45 % 4, you get a result of 1. That means that it is 1 byte over the 4 byte boundary at byte 44. So to get that row of data back onto a 4 byte boundary, you add 3 padding bytes. That brings you up to 48 bytes per row, which will get you onto the next 4 byte boundary...

Hopefully that helps a bit and gives you some ideas on how you could modify your routine to allow for BMP files of any dimension.

As an alternative, you could use TGA files, which I find more useful anyway, due to the ability to use an alpha channel. Nehe has a TGA loading routine in one of the later lessons, if I recall correctly. For a good excercise, you might consider looking at the TGA spec at wotsit.org and trying to implement your own, though. It's a pretty simple spec to work with.
 
Old 08-28-2004, 02:40 AM   #13
hylke
Member
 
Registered: Apr 2004
Location: the Netherlands
Distribution: Ubuntu 7.04
Posts: 329

Original Poster
Rep: Reputation: 30
Ok, thank you very much for your help.
I'il check that website out.
Hylke
 
Old 09-01-2004, 03:25 PM   #14
hylke
Member
 
Registered: Apr 2004
Location: the Netherlands
Distribution: Ubuntu 7.04
Posts: 329

Original Poster
Rep: Reputation: 30
I've checked out wotsit, but the first bmp loading thing used the win32 api, the second was for os/2 and doesn't work for linux too(checked that out), the third was a doc file, that i couldn't read properly using kword, and the last was just a simple text file about how windows loads bmp files :-\
So can you please help me?
Hylke
 
Old 09-02-2004, 02:59 PM   #15
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
The file you'd want is here. It is a Word document, but using OpenOffice or something similar, you should be able to read it. Don't expect it to give you code, though. It explains the details of the BMP file format, byte for byte...

A similar document for the TGA file specification can be found here. This one is in PDF format, and you can view it using Adobe Acrobat, or gv...

Trying to understand documents like this and writing a loader for these formats can be a good experience. You may find you learn a lot from doing so.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bitmap indexes in c++ crapodino Programming 2 11-27-2005 08:43 PM
Bitmap fonts, but not Helvetica mschutte Debian 2 09-18-2005 11:41 AM
Convert to 16 bit bitmap static_drc Linux - Software 2 06-29-2005 02:21 PM
illegal bitmap block(s) HOHCEHC Linux - General 0 05-04-2004 10:07 PM
creating a bitmap qanopus Programming 1 12-04-2002 06:57 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration