24bit BMP functions!!!

Post here your demos and examples with the source files.
Forum rules
Always post the games with a screenshot.
The file must have the ged and data files (complete game source)
Use the forum attachment to post the files.
It is always better to use the first post to put the game files

24bit BMP functions!!!

Postby pyrometal » Sun Jun 08, 2008 3:31 am

Hello everyone! I've been working of functions that can load, draw and alter uncompressed 24bit bitmap files onto a canvas. Note, the loader uses only the width and height bytes in the header and basically ignores the rest of the header. My functions can load, scale up, flip, rotate by n*90 degrees, add/subtract color, invert colors, and conver to greyscale any compatible bitmap it is fed. The drawing function treats black as a transparent color.

screenshot.PNG

BMP24 reader.zip
It has it uses!
(4.91 KiB) Downloaded 306 times


To use them properly, first use:

- load_bmp24("file_name"); The file MUST be in the same location as the program.

Then use these if you want:

- invert_bmp24(); to invert the image's colors. (reuse to undo change)
- greyscale_bmp24(); to convert the image to a greyscale. (Converts image data, you must reload if you want the original again)
- RGBadd_bmp24(red, green, blue); to add or subtract color from the image. (Converts image data, you must reload if you want the original again)

Then, when you are ready to draw:

-draw_bmp24(positionX, positionY, Scale factor(positive integers only), flip image value (positive is normal, negative flips), number of 90degCW rotations);

The current image limits are that it can't have an area larger than that given by 320*240 pixels. You may increase it by modifying my codes slightly. Using these for realtime anymation is strongly discouraged because it is very demanding on the CPU. I would use these for seldomly updated and stationary elements like healthbars (non animated), and other such things as menu graphics, since it avoids creating numerous actors for very simple things.

I hope this may prove helpful to some of you out there!

ttyl! --Pyro
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: 24bit BMP functions!!!

Postby Caaz Games » Sun Jun 08, 2008 4:01 am

Hmm interesting, you say it treats black as transparent, but i thought bmp doesn't have like the ability to be transparent
You are welcome to join my forum. 4 active members lol but it's a cool place. active... much talking :D it's fun!
http://caaz.freeforums.org/
User avatar
Caaz Games
 
Posts: 729
Joined: Wed Feb 14, 2007 9:09 am
Location: California....knows how to party!
Score: 25 Give a positive score

Re: 24bit BMP functions!!!

Postby pyrometal » Sun Jun 08, 2008 4:05 am

lol, it doesn't, but the algorithm is made so it doesn't draw black pixels on the canvas.
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: 24bit BMP functions!!!

Postby Caaz Games » Sun Jun 08, 2008 4:18 am

oh ok Image
You are welcome to join my forum. 4 active members lol but it's a cool place. active... much talking :D it's fun!
http://caaz.freeforums.org/
User avatar
Caaz Games
 
Posts: 729
Joined: Wed Feb 14, 2007 9:09 am
Location: California....knows how to party!
Score: 25 Give a positive score


Return to Game Demos

Who is online

Users browsing this forum: No registered users and 1 guest

cron