Popov P32091
5 unresolved threads
- Last updated by Андрей Попов
4 5 struct image { 6 uint64_t width, height; 7 struct pixel* data; 8 }; 9 10 struct __attribute__((packed)) pixel { 11 uint8_t b, g, r; 12 }; 13 14 int destroyImage( struct image* image); 15 16 struct image createImage(const uint64_t width, const uint64_t height); 17 18 19 int rotate(struct image* source); changed this line in version 3 of the diff
16 } 17 18 struct image img = {0,0,NULL}; 19 20 fromBmp(inFile, &img); 21 22 rotate(&img); 23 24 toBmp(outFile, &img); 25 26 close(&inFile); 27 close(&outFile); 28 29 destroyImage(&img); 30 return 0; 31 } - Last updated by Андрей Попов
12 13 int destroyImage( struct image* image){ 14 free(image->data); 15 return 0; 16 } 17 18 int rotate( struct image* source){ 19 struct image output = createImage(source->height, source->width); 20 21 for (int i= 0; i < source->height; i++){ 22 for (int j = 0; j <source->width; j++ ) 23 output.data[j * source->height + (source->height - i - 1)] = source->data[i * source->width + j]; 24 } 25 destroyImage(source); 26 *source = output; 27 return 0; changed this line in version 2 of the diff
- Last updated by Андрей Попов
18 } 19 20 if (header->biBitCount != 24){ 21 free(header); 22 return READ_INVALID_BITS; 23 } 24 25 *img = createImage(header->biWidth, header->biHeight); 26 free(header); 27 28 uint64_t padding = (4 - (img->width % 4) * sizeof(struct pixel)) % 4; 29 30 for (int i = 0; i < img->height; i++){ 31 if(!fread(img->data + img->width * i, sizeof(struct pixel) * img -> width, 1, in)) 32 return READ_INVALID_DATA; 33 fseek(in, (long) padding, SEEK_CUR); changed this line in version 6 of the diff
- Last updated by Андрей Попов
29 30 for (int i = 0; i < img->height; i++){ 31 if(!fread(img->data + img->width * i, sizeof(struct pixel) * img -> width, 1, in)) 32 return READ_INVALID_DATA; 33 fseek(in, (long) padding, SEEK_CUR); 34 } 35 36 return READ_OK; 37 } 38 39 enum writeStatus toBmp( FILE* out, const struct image * img ){ 40 struct bmpHeader header = createBMPHeader(img); 41 42 fwrite(&header, sizeof(header), 1, out); 43 44 uint64_t padding = (4 - (img->width * sizeof(struct pixel) % 4)) % 4; changed this line in version 6 of the diff
@S1nCosX Всё круто, только вот эти небольшие изменения поправить бы)