Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void save_img() {
- FILE* si = fopen("1.png","wb");
- png_structp sips = png_create_write_struct(PNG_LIBPNG_VER_STRING,NULL,NULL,NULL);
- png_infop sipi = png_create_info_struct(sips);
- png_init_io (sips,si);
- png_set_IHDR(sips,sipi,holst_x,holst_y,8,PNG_COLOR_TYPE_RGB,PNG_INTERLACE_NONE,PNG_COMPRESSION_TYPE_DEFAULT,PNG_FILTER_TYPE_DEFAULT);
- u8* rows[holst_y];
- u64 do1 = 3*okno_x*((okno_y - holst_y)/2);
- u64 do2 = 3*((okno_x - holst_x)/2);
- u8 dob = (okno_x - holst_x)%2;
- okno_num = okno + do1 + do2;
- holst = malloc(holst_x*holst_y*3);
- i2 = 0;
- while (i2 < holst_y) {
- i = 0;
- rows[holst_y - i2 - 1] = holst + (i2*holst_x*3);
- while (i < holst_x) {
- *(holst + i*i2*3 - 1) = *okno_num;
- okno_num++;
- *(holst + i*i2*3) = *okno_num;
- okno_num++;
- *(holst + i*i2*3 + 1) = *okno_num;
- okno_num++;
- okno_num = okno_num + do2*2 + dob;
- i++;
- }
- }
- free(holst);
- png_set_rows(si,sipi,rows);
- png_write_png(si,sipi,PNG_TRANSFORM_IDENTITY,NULL);
- png_write_end(si,sipi);
- png_destroy_write_struct(&si,NULL);
- fclose(si);
- }
Add Comment
Please, Sign In to add comment