Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void cut(struct Png *image, int x1, int y1, int x2, int y2) {
- int y, x;
- for (y = 0; y <= y2 - y1; y++) {
- png_byte *cut_row1 = image->row_pointers[y + y1];
- for (x = 0; x <= x2 - x1; x++) {
- png_byte *row = image->row_pointers[y];
- png_byte *ptr = &(row[x * 3]);
- png_byte *cut_ptr1 = &(cut_row1[(x + x1) * 3]);
- ptr[0] = cut_ptr1[0];
- ptr[1] = cut_ptr1[1];
- ptr[2] = cut_ptr1[2];
- }
- }
- for (y = y2 - y1 + 1; y < image->height; y++)
- free(image->row_pointers[y]);
- image->height = y2 - y1;
- image->width = x2 - x1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement