Advertisement
LilChicha174

Untitled

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