X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Fmod_png%2Fmptr_png.cpp;h=23aa9aa469ad6341e8c0692ff5d55bb895d64393;hb=657023f1c16cba4b3908ef61f5ac0ce7f2969128;hp=2a928a834c8a2250c5112baa20dace5bbfdac527;hpb=63e709f66d50c124cc0ece2325f4773ac4ae7b20;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 2a928a8..23aa9aa 100644 --- a/synfig-core/trunk/src/modules/mod_png/mptr_png.cpp +++ b/synfig-core/trunk/src/modules/mod_png/mptr_png.cpp @@ -6,6 +6,7 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -216,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); float b=gamma().b_U8_to_F32((unsigned char)png_ptr->palette[row_pointers[y][x]].blue); + float a=1.0; + if(info_ptr->valid & PNG_INFO_tRNS) + a = (float)(unsigned char)png_ptr->trans[row_pointers[y][x]]*(1.0/255.0); surface_buffer[y][x]=Color( r, g, b, - 1.0 + a ); } break; @@ -329,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