For a project (homework), I need to manipulate an Array of integers (2D) so that only certain positions take the value 1, and all others take the value 0.
The Array is 800x600 in size, but may vary depending on the instance.
This works fine, the problem lies in the output:
To make output more readable (800x600 Array, dumped into a text file, is annoying to check for errors), I would like to turn this into an Image (.bmp preferred, but it doesn't really matter)
A value of 1 should colour the corresponding pixel black, 0 white. Is there a way to do this without manually building the entire image?
eg
0100001000
0110001100
1111001110
1100010010
1111100000
should turn into a 10x5 pixel image.
If not, does anyone how the .bmp file would have to be created? I know the basics of it's structure, and would have to write it in binary mode, but what values does the header need?
I found some stuff for this, but it was all C++, and I only want to use C.
To make it clear: The assignment is NOT to create the image, technically, the .txt file is ENOUGH. I merely want to make it look nicer. This will not affect my mark in any way (solving the problem is the question, not nice output)
Just to make sure this doesn't get deleted as "Homework Assignment". It isn't.
Hope I can be helped :)
The Array is 800x600 in size, but may vary depending on the instance.
This works fine, the problem lies in the output:
To make output more readable (800x600 Array, dumped into a text file, is annoying to check for errors), I would like to turn this into an Image (.bmp preferred, but it doesn't really matter)
A value of 1 should colour the corresponding pixel black, 0 white. Is there a way to do this without manually building the entire image?
eg
0100001000
0110001100
1111001110
1100010010
1111100000
should turn into a 10x5 pixel image.
If not, does anyone how the .bmp file would have to be created? I know the basics of it's structure, and would have to write it in binary mode, but what values does the header need?
I found some stuff for this, but it was all C++, and I only want to use C.
To make it clear: The assignment is NOT to create the image, technically, the .txt file is ENOUGH. I merely want to make it look nicer. This will not affect my mark in any way (solving the problem is the question, not nice output)
Just to make sure this doesn't get deleted as "Homework Assignment". It isn't.
Hope I can be helped :)
Comment