Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void frame2(struct Png *image, int thick, int width_pixel, int r, int g, int b) {
- int new_width = image->width + thick * 1;
- int new_height = image->height + thick * 1;
- png_byte **new_mas = (png_byte **) malloc(sizeof(png_byte * ) * new_height);
- for (int y = 0; y < new_height; y++)
- new_mas[y] = (png_byte *) malloc(sizeof(png_byte) * new_width * width_pixel);
- for (int y = 0; y < new_height; y++) {
- png_byte *new_row = new_mas[y];
- for (int x = 0; x < new_width; x++) {
- png_byte *new_ptr = &(new_row[x * width_pixel]);
- new_ptr[0] = r;
- new_ptr[1] = g;
- new_ptr[2] = b;
- }
- }
- for (int y = thick; y < (new_height - 1*thick); y++) {
- png_byte *row = image->row_pointers[y];
- png_byte *new_row = new_mas[y];
- for (int x = thick; x < (new_width - 1*thick); x++) {
- png_byte *ptr = &(row[x * width_pixel]);
- png_byte *new_ptr = &(new_row[x * width_pixel]);
- new_ptr[0] = ptr[0];
- new_ptr[1] = ptr[1];
- new_ptr[2] = ptr[2];
- }
- }
- image->row_pointers = new_mas;
- image->width = new_width;
- image->height = new_height;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement