1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
// This is to help you start thinking about HW12. Not required for HW11.
void _make_bmp(size_t w, size_t h, uint8_t r, uint8_t g, uint8_t b) {
uint32_t header_size_bytes = sizeof(BMPHeader);
// Exception to sizeof(…); necessary
uint32_t row_size_bytes = _get_row_size(w);
uint32_t pixel_data_bytes = row_size_bytes * h;
uint32_t size = 0; // FIXME
BMPHeader header = {
.type = 0x424d; // TODO: check
.image_size_bytes = pixel_data_bytes,
.size = pixel_data_bytes + header_size_bytes,
…
};
FILE* fp = fopen(…)
uint8_t* pixel_bytes = malloc(image_size_bytes);
fwrite(…); // write the header
fwrite(…); // write the pixel data
free(pixel_bytes);
fclose(fp);
}
int main(int argc, char* argv[]) {
return EXIT_SUCCESS;
}
/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */
|
© Copyright 2019 Alexander J. Quinn This content is protected and may not be shared, uploaded, or distributed.