Updated example with proper length checking
This commit is contained in:
parent
4b56c24ab2
commit
270cfa0177
15
src/main.c
15
src/main.c
@ -31,12 +31,17 @@ int main() {
|
|||||||
|
|
||||||
if (result == CIFF_PARSE_SUCCESS) {
|
if (result == CIFF_PARSE_SUCCESS) {
|
||||||
|
|
||||||
uint8_t *flipped_image = (uint8_t *) magic_malloc(context, pixel_data_size);
|
uint8_t *flipped_image = (uint8_t *) magic_malloc(context, fsize - pixel_data_starts);
|
||||||
flip_image(ciff_file + pixel_data_starts, flipped_image, pixel_data_size, width, height);
|
if (flip_image(ciff_file + pixel_data_starts, flipped_image, pixel_data_size, width, height) !=
|
||||||
|
IMAGE_FLIP_SUCCESS) {
|
||||||
if (!tga_write_raw("test.tga", width, height, flipped_image, TGA_TRUECOLOR_24)) {
|
printf("Literally failed to flip the image");
|
||||||
printf("%s", tga_error_string(tga_get_last_error()));
|
} else {
|
||||||
|
if (!tga_write_raw("test.tga", width, height, flipped_image, TGA_TRUECOLOR_24)) {
|
||||||
|
printf("%s", tga_error_string(tga_get_last_error()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printf("%d", result);
|
printf("%d", result);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user