I need some help REALLY quick =D

Non-platform specific questions.

I need some help REALLY quick =D

Postby SuperSonic » Fri Apr 06, 2012 6:46 pm

Can anybody make me a quick bmp loading function?

All I need it to do is load the red values from a 64x64 bmp.

Here's the vars that I have:
Code: Select all
unsigned char gameoverscreen[64][64]

All I need is a function that loads a bmp and stores ONLY the red values in the "gameoverscreen" array :D

+1 to whoever can do this for me :wink:
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: I need some help REALLY quick =D

Postby skydereign » Fri Apr 06, 2012 7:22 pm

I assume you already have a bmp loading function, right? If so, you can just remove the gb from it. Or when you display it, just set g and b. Really the most dynamic way to go about this is to create a function that displays the colors, but you can input a mask. That'll allow you to do all kinds of neat effects. In fact, you should be able to change the rgb of the canvas you are using to create the masking effect (and you wouldn't have to redraw the image every frame).
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: I need some help REALLY quick =D

Postby SuperSonic » Fri Apr 06, 2012 7:28 pm

Well first of all, I don't have a function. I've tried bmp loading before but I could never get it to work. Secondly, I want the bmp to be displayed as a greyscale image so there's no reason to waist space with g and b, when I could simply just create the image with red colors and load it into ge like that. Does that make sense? Basically, I'm just going to treat red as a brightness factor :D
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: I need some help REALLY quick =D

Postby skydereign » Fri Apr 06, 2012 8:34 pm

Well this does what you want I believe. It only reads in the red.
Code: Select all
void
readin_red (char* filenamename)
{
    FILE* file = fopen(filename, "r");
    unsigned char temp;
    int i, j;
 
    fseek(file, 54, 0); // jump to the part where colors are stored

    for(i=0;i<64;i++)
    {
        for(j=0;j<64;j++)
        {
            fscanf(file, "%c%c%c", &temp, &temp, &(red[j][i])); // reads in order bgr
            // this part draws it but I commented it out
            // setpen(red[j][i], 0, 0, 0, 1);
            // putpixel(j, i);
        }
    }
    fclose(file);
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: I need some help REALLY quick =D

Postby SuperSonic » Sat Apr 07, 2012 1:49 am

Sky, you rock :P

+1 as promised :wink:
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: I need some help REALLY quick =D

Postby tim4 » Wed Apr 11, 2012 11:26 pm

Hey now... How did we know bitmap headers are always 54 chars long? I'm kamazed. I guess that's the same for PNGs and others too? I mean after decompression.


...Not that this is on-topic or anything, of course. :)
User avatar
tim4
 
Posts: 12
Joined: Mon Apr 09, 2012 4:55 am
Score: 9 Give a positive score

Re: I need some help REALLY quick =D

Postby skydereign » Wed Apr 11, 2012 11:38 pm

bmp's format is pretty simple, and well enough documented. If you want to know more about them, all you need to do is google it. png files though are far more complex, and really you should be using libpng to deal with pngs (namely don't try it in gE, unless you plan to reverse engineer libpng).
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest