Advertisement
LilChicha174

Untitled

Jun 5th, 2022
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.93 KB | None | 0 0
  1. void square(struct Png *image, struct Png *image2, int width_pixel, int size) {
  2.     int x1, x2, x3, x4, y1, y2, y3, y4;
  3.     for (int y = 0; y < image->height; y++) {
  4.         png_byte *row = image->row_pointers[y];
  5.         for (int x = 0; x < image->width; x++) {
  6.             png_byte *ptr = &(row[x * width_pixel]);
  7.             if (ptr[0] == 255 && ptr[1] == 0 && ptr[2] == 0) {
  8.                 x1 = x - size / 2;
  9.                 y1 = y + size / 2;
  10.                 x2 = x + size / 2;
  11.                 y2 = y1;
  12.                 x3 = x2;
  13.                 y3 = y - size / 2;
  14.                 x4 = x1;
  15.                 y4 = y3;
  16.                 paint_line(image2, 3, x1, y1, x2, y2, 1, 255, 0, 0);
  17.                 paint_line(image2, 3, x2, y2, x3, y3, 1, 255, 0, 0);
  18.                 paint_line(image2, 3, x3, y3, x4, y4, 1, 255, 0, 0);
  19.                 paint_line(image2, 3, x1, y1, x4, y4, 1, 255, 0, 0);
  20.             }
  21.         }
  22.     }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement