X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Fmod_png%2Fmptr_png.cpp;h=19f82f35880b1edb0b9203134103fbfd1bb82d47;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=f0fcb86af872fa442931c4b55e5dca75d0715b0a;hpb=5908ecaf8d0b7a2b8b3b56d61c2d4a8a86deb72c;p=synfig.git diff --git a/synfig-core/trunk/src/modules/mod_png/mptr_png.cpp b/synfig-core/trunk/src/modules/mod_png/mptr_png.cpp index f0fcb86..19f82f3 100644 --- a/synfig-core/trunk/src/modules/mod_png/mptr_png.cpp +++ b/synfig-core/trunk/src/modules/mod_png/mptr_png.cpp @@ -217,15 +217,14 @@ png_mptr::png_mptr(const char *file_name) png_read_image(png_ptr, row_pointers); - int x; - int y; + png_uint_32 x, y; surface_buffer.set_wh(width,height); switch(color_type) { case PNG_COLOR_TYPE_RGB: - for(y=0;ypalette[row_pointers[y][x]].red); float g=gamma().g_U8_to_F32((unsigned char)png_ptr->palette[row_pointers[y][x]].green); @@ -333,6 +331,75 @@ png_mptr::png_mptr(const char *file_name) delete [] row_pointers; delete [] data; + + trim = false; + + if (getenv("SYNFIG_DISABLE_CROP_IMPORTED_IMAGES")) + return; + + switch(color_type) + { + case PNG_COLOR_TYPE_RGB_ALPHA: + case PNG_COLOR_TYPE_GRAY_ALPHA: + case PNG_COLOR_TYPE_PALETTE: + for(y=0;yBORDER) min_y = y-BORDER; else min_y = 0; + + for(y=height-1;y>0;y--) + { + for(x=0;xBORDER) min_x = x-BORDER; else min_x = 0; + + for(x=width-1;x>0;x--) + { + for(y=0;y