Ask coding questions

← Back to all posts
Learning how to render BMP image
h
MocaCDeveloper (713)

BMP IMAGE RENDERING

Hi guys!

I am currently learning how to render a bmp image in C!
It is quite interesting to say the least. It's pretty interesting however.

It really gets you into some of the dirty parts of C. Such as knowing how to work with an array, what each thing does, and pretty much understanding each ideal within the array and what it does corresponding to the image rendering.

It's quite interesting, between the info header(which defines the BMP file outline), and the header which holds the image information(such as the image size, the image pixel offset, the image width, height etc).
There is a catch to this however.

The width and height has to correspond to the amount of bytes put into the colors.
There is an example in the code. The images being rendered are quite small because I cannot seem to figure out how to render a image with a width greater than 90.

Tell me what you think of it. And please, let me know if you want to learn how to render a BMP image in C. I will gladly teach you!

Screenshot of a rendered BMP image:

Comments
hotnewtop
Coder100 (18926)

anyways i see a lot of magic numbers, maybe you should define some constants for them

MocaCDeveloper (713)

@Coder100

Yeah I am going to style up the code a bit when I am done. I am adding in a few cool ideals to spice up the rendering a bit.

Example, making it to where you can render the image at a higher resolution, rendering the image with the exact amount of bytes for each rgb value etc.

MocaCDeveloper (713)

@Coder100

I am tired ok, lol. I stayed up all night reading documentation over rendering a bmp image.