3 lab Daniil Dagaev P32141
11 unresolved threads
- Last updated by Даниил Дагаев
1 // 2 // Created by imia on 11.01.2023. 3 // 4 5 #include "file_manager.h" 6 7 8 int open_file(FILE** file, char const* file_name, char const* mode){ 9 *file = fopen(file_name, mode); 10 return *file != NULL; 11 } changed this line in version 8 of the diff
- Last updated by Даниил Дагаев
18 uint16_t bfType; 19 uint32_t bfileSize; 20 uint32_t bfReserved; 21 uint32_t bOffBits; 22 uint32_t biSize; 23 uint32_t biWidth; 24 uint32_t biHeight; 25 uint16_t biPlanes; 26 uint16_t biBitCount; 27 uint32_t biCompression; 28 uint32_t biSizeImage; 29 uint32_t biXPelsPerMeter; 30 uint32_t biYPelsPerMeter; 31 uint32_t biClrUsed; 32 uint32_t biClrImportant; 33 }; changed this line in version 4 of the diff
5 #ifndef IMAGE_TRANSFORMER_FILE_MANAGER_H 6 #define IMAGE_TRANSFORMER_FILE_MANAGER_H 7 8 9 #include "bmp_manager.h" 10 #include "util.h" 11 #define OK 0 12 #define EXCEPTION 1 13 int open_file(FILE** file, char const* file_name, char const* mode); 14 15 16 int file_handle(char* argv[], FILE ** file_input, FILE ** file_output); 17 int read_file(FILE ** file_input, FILE ** file_output , struct image *img); 18 int write_file(FILE ** file_input, FILE ** file_output , struct image *img); 19 int close_files(FILE *file_first, FILE *file_second); 20 int close_file(FILE *file_open); 3 // 4 5 #ifndef IMAGE_TRANSFORMER_IMG_MANAGER_H 6 #define IMAGE_TRANSFORMER_IMG_MANAGER_H 7 8 #include <stdint.h> 9 #include <stdlib.h> 10 11 12 struct __attribute__ ((__packed__)) image { 13 uint64_t width, height; 14 struct pixel* data; 15 }; 16 struct __attribute__ ((__packed__)) pixel { uint8_t b, g, r; }; 17 struct image create_img(uint64_t width, uint64_t height); 18 void remove_images(struct image img_first, struct image img_second); - Last updated by Даниил Дагаев
1 // 2 // Created by imia on 10.01.2023. 3 // 4 5 #include "bmp_manager.h" 6 7 8 uint64_t calc_padding(const uint64_t img_width) { changed this line in version 2 of the diff
- Last updated by Даниил Дагаев
54 } 55 } 56 return WRITE_OK; 57 } 58 enum read_status from_bmp( FILE* file_input, struct image* img) { 59 struct bmp_header header = {0}; 60 if(!fread(&header, sizeof( struct bmp_header ), 1, file_input )) { 61 return READ_INVALID_HEADER; 62 } 63 if(header.bfType != TYPE) { 64 return READ_INVALID_SIGNATURE; 65 } 66 if(header.biBitCount != BIT_COUNT){ 67 return READ_INVALID_BITS; 68 } 69 struct image img_r = create_img(header.biWidth, header.biHeight); changed this line in version 2 of the diff
- Last updated by Даниил Дагаев
25 if (!open_file(file_output, argv[2], "wb")) { 26 printErr( "Can't write file"); 27 close_file(*file_input); 28 return EXCEPTION; 29 } 30 return OK; 31 } 32 int read_file(FILE ** file_input, FILE ** file_output , struct image *img){ 33 if (from_bmp(*file_input, img) != READ_OK) { 34 printErr( "can't read file"); 35 close_files(*file_input,*file_output); 36 return EXCEPTION; 37 } 38 return OK; 39 } 40 int close_files(FILE *file_first, FILE *file_second){ changed this line in version 8 of the diff
- Last updated by Даниил Дагаев
1 // 2 // Created by imia on 10.01.2023. 3 // 4 5 6 #include "img_manager.h" 7 8 struct image create_img(uint64_t width, uint64_t height){ 9 struct image img = {0}; 10 if(height <= 0 || width <= 0){ 11 return img; 12 } changed this line in version 12 of the diff
- Last updated by Даниил Дагаев
1 // 2 // Created by imia on 10.01.2023. 3 // 4 5 6 #include "img_manager.h" 7 8 struct image create_img(uint64_t width, uint64_t height){ 9 struct image img = {0}; 10 if(height <= 0 || width <= 0){ 11 return img; 12 } 13 struct pixel *pix = (struct pixel*)malloc(sizeof(struct pixel)*width*height); changed this line in version 11 of the diff
- Last updated by Даниил Дагаев
8 struct image create_img(uint64_t width, uint64_t height){ 9 struct image img = {0}; 10 if(height <= 0 || width <= 0){ 11 return img; 12 } 13 struct pixel *pix = (struct pixel*)malloc(sizeof(struct pixel)*width*height); 14 return (struct image){ 15 .width = width, 16 .height = height, 17 .data = pix 18 }; 19 } 20 void remove_img(struct image *img){ 21 free(img->data); 22 img->width = 0; 23 img->height = 0; changed this line in version 10 of the diff
- Last updated by Даниил Дагаев
1 // 2 // Created by imia on 10.01.2023. 3 // 4 5 #ifndef IMAGE_TRANSFORMER_UTIL_H 6 #define IMAGE_TRANSFORMER_UTIL_H 7 #include <stdio.h> 8 void printErr(const char *str); 9 void println(const char *str); changed this line in version 16 of the diff
fixed @andrew