Advertisement
LilChicha174

Untitled

Jun 5th, 2022
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.18 KB | None | 0 0
  1. void paint_pixel_white(struct Png *image, int x, int y, int width_pixel, int Red, int Green, int
  2. Blue) {
  3.     if (x < 0 || x >= image->width || y < 0 || y >= image->height)
  4.         return;
  5.     png_byte *row = image->row_pointers[y];
  6.     png_byte *ptr = &(row[x * width_pixel]);
  7.     if (!(ptr[0] == 255 && ptr[1] == 255 && ptr[2] == 255)) {
  8.         ptr[0] = Red;
  9.         ptr[1] = Green;
  10.         ptr[2] = Blue;
  11.     }
  12. }
  13.  
  14. void white2(struct Png *image, int width_pixel, int thick, int r, int g, int b) {
  15.     for (int y = 0; y < image->height; y++) {
  16.         png_byte *row = image->row_pointers[y];
  17.         for (int x = 0; x < image->width; x++) {
  18.             png_byte *ptr = &(row[x * width_pixel]);
  19.             if (ptr[0] == 255 && ptr[1] == 255 && ptr[2] == 255) {
  20.                 for (int y1 = y - thick; y1 < (1 + y + thick); y1++) {
  21.                     for (int x1 = x - thick; x1 < (1 + x + thick); x1++) {
  22.                         if ((x - x1) * (x - x1) + (y - y1) * (y - y1) <= (thick * thick)) {
  23.                             paint_pixel_white(image, x1, y1, width_pixel, r, g, b);
  24.                         }
  25.                     }
  26.                 }
  27.             }
  28.  
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement