The simplest format you can think of contains exactly the minimum of information:
sizeX, sizeY first, then the color information of every pixel starting with the first row, split up into
rates of red, green and blue.
let's imagine the following image or 'bitmap', consisting only of 2 rows with 6 pixels each:
r w k g g g
b b g g k k
where r stands for red, w for white, k for black, g for green b for blue.
each of the color values is represented by their red/green/blue ratios, which are given in values between 0
(dark) and 255 (bright).
We now have to decide for a data-format: let's allow the height and width to be between 0 and 65535, assigning
2 bytes to each one, storing the most significant byte first (e.g. a size of 258 x 13 would be stored as
1 2 0 13, because 258 = 1*256 + 2, 13 = 0*256 + 13).
The color ratios only need one byte, their values will not extend the interval of 0..255.
Given this format, the bitmap shown above would be stored as:
0 6 0 2 255 0 0 255 255 255 0 0 0 0 255 0 ...
Let's see why:
The size was given as an x/y-pair, two bytes each. Hence the x-size is 0 6, which means 256*0 + 6,
the y-size results in 0 2, being 256*0 + 2: our image is 6 pixels wide, 2 pixels high.
The rest of the data must be red in triplets of single bytes, defining the color of each pixel row-wise
starting at the upper left pixel.
The first triplet is 255 0 0, which is red.
The second triplet is 255 255 255, which is white
The third triplet is 0 0 0, which is black
And so on.
The image-file shall be stored as a binary file, not as a textfile.
Let's call this selfmade bitmape-format 'the c68-format'.
And here's your task:
Write a program that reads and shows the image 'assignmentImage.c68'.
assignmentImage.c68 is -you hopefully guessed it- an image stored in the c68-format.
You can read it HERE (260kB).
Hints:
Scoring: 5 points, as usual.
Good Luck !