rotate_img
9 unresolved threads
press f
Здравствуйте, Игорь Олегович.
Я списал часть кода которая отвечает за сохранение файла.Edited by Svistukhin Andrey
1 #include "file_handler.h" 2 #include "status.h" 3 4 #define READ_MODE "rb" 5 #define WRITE_MODE "wb" 6 7 enum read_status file_read(FILE** file, const char* path) 8 { 9 if (!file) return READ_ERROR; - Last updated by Svistukhin Andrey
1 #ifndef ROTATE_IMAGE_IMAGE_H 2 #define ROTATE_IMAGE_IMAGE_H 3 4 #include <inttypes.h> 5 #include <malloc.h> 6 7 struct image 8 { 9 uint32_t width, height; 10 struct pixel* data; 11 }; 12 13 struct pixel 14 { 15 uint8_t r; changed this line in version 3 of the diff
- Last updated by Svistukhin Andrey
1 #include "status.h" 2 3 const char* read_status_map[] = { changed this line in version 3 of the diff
- Last updated by Svistukhin Andrey
9 READ_OPEN_FILE_ERROR, 10 READ_CLOSE_OK, 11 READ_ERROR, 12 }; 13 14 15 enum write_status { 16 WRITE_OK = 0, 17 WRITE_ERROR, 18 WRITE_FILE_DOESNT_EXIST, 19 WRITE_CLOSE_ERROR, 20 WRITE_INVALID_HEADER, 21 WRITE_PATH_ERROR, 22 }; 23 24 const char* read_status_map[7]; changed this line in version 3 of the diff
- Last updated by Svistukhin Andrey
5 struct image img; 6 img.width = width; 7 img.height = height; 8 img.data = malloc(width * height * sizeof(struct pixel)); 9 10 return img; 11 } 12 13 14 struct image rotate_image(struct image const source) 15 { 16 uint32_t width = source.width; 17 uint32_t height = source.height; 18 struct image rotated_image = create_image(width, height); 19 20 for (size_t i = 0; i < height; i = i + 1) changed this line in version 3 of the diff
11 } 12 13 14 struct image rotate_image(struct image const source) 15 { 16 uint32_t width = source.width; 17 uint32_t height = source.height; 18 struct image rotated_image = create_image(width, height); 19 20 for (size_t i = 0; i < height; i = i + 1) 21 { 22 for (size_t j = 0; j < width; j = j + 1) 23 { 24 // rotated_x = original_height - original_x - 1 25 // rotated_y = original_y 26 *(rotated_image.data + i * width + j) = *(source.data + j * height + i); - Last updated by Svistukhin Andrey
1 #include "image.h" 2 3 struct image create_image(uint32_t width, uint32_t height) 4 { 5 struct image img; changed this line in version 3 of the diff