Master
4 unresolved threads
assigned to @sayon
25 27 #define DECLARE_FIELD( t, n ) t n ; 26 28 29 /** описание заголовка 30 */ 27 31 struct __attribute__((packed)) bmp_header 28 32 { 29 33 FOR_BMP_HEADER( DECLARE_FIELD ) 30 34 }; 31 35 32 36 33 void bmp_header_print( struct bmp_header const* header, FILE* f ); 34 bool read_header_from_file( const char* filename, struct bmp_header* header ); 37 /** смещение на мусорные байты в слчуае их наличия 38 * img - изображение 39 */ 40 uint8_t get_padding(struct image img); 15 struct image create_image(uint64_t width, uint64_t height) { 16 struct image image = { 0 }; 17 18 image.width = width; 19 image.height = height; 20 image.data = malloc(width * height * sizeof(struct pixel)); 21 memset(image.data, 0, width * height * sizeof(struct pixel)); 22 23 return image; 24 } 25 26 void destroy_image(const struct image img) { 27 free(img.data); 28 } 29 30 struct pixel get_pixel(uint64_t i, uint64_t j, const struct image img) { 15 struct image create_image(uint64_t width, uint64_t height) { 16 struct image image = { 0 }; 17 18 image.width = width; 19 image.height = height; 20 image.data = malloc(width * height * sizeof(struct pixel)); 21 memset(image.data, 0, width * height * sizeof(struct pixel)); 22 23 return image; 24 } 25 26 void destroy_image(const struct image img) { 27 free(img.data); 28 } 29 30 struct pixel get_pixel(uint64_t i, uint64_t j, const struct image img) { 29 30 struct pixel get_pixel(uint64_t i, uint64_t j, const struct image img) { 31 return *(img.data + i * img.width + j); 32 } 33 34 void set_pixel(struct pixel p, uint64_t i, uint64_t j, const struct image img) { 35 *(img.data + i * img.width + j) = p; 36 } 37 38 /* создаёт копию изображения, которая повёрнута на 90 градусов */ 39 struct image rotate( struct image const source ) { 40 struct image dest = create_image(source.height, source.width); 41 42 for(size_t i = 0; i < source.height; ++i) { 43 for(size_t j = 0; j < source.width; ++j) { 44 struct pixel p = get_pixel(i - 1, j, source);