X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fpalette.cpp;fp=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fpalette.cpp;h=5ba36aeea45951ffd8312862f1cefe744c2d1fe5;hb=5ddcf36f04cfbd10fabda4e3c5633cb27cdd4c0a;hp=8355407f52a84a3455c01cae06bfcafab7ba6e25;hpb=cee5940bae97612105db8b7e1ffcf513f9d9150c;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/palette.cpp b/synfig-core/trunk/src/synfig/palette.cpp index 8355407..5ba36ae 100644 --- a/synfig-core/trunk/src/synfig/palette.cpp +++ b/synfig-core/trunk/src/synfig/palette.cpp @@ -87,7 +87,7 @@ PaletteItem::add(const Color& x,int xweight) Palette::Palette(const Surface& surface, int max_colors): name_(_("Surface Palette")) -{ +{ max_colors-=2; for(int i=0;(signed)size()<(max_colors-1) && iadd(color); continue; } - + /*if(size()>=max_colors) { iterator iterlight(find_light()); @@ -125,9 +125,9 @@ Palette::Palette(const Surface& surface, int max_colors): find_closest(light.color)->add(light.color,light.weight); } */ - + push_back(color); - continue; + continue; } /* @@ -138,7 +138,7 @@ Palette::Palette(const Surface& surface, int max_colors): { float dist; Color color(surface[y][x]); - + if(empty()) { push_back(color); @@ -159,10 +159,10 @@ Palette::Palette(const Surface& surface, int max_colors): iter->add(color); continue; } - - + + push_back(color); - continue; + continue; } sort(rbegin(),rend()); @@ -203,7 +203,7 @@ Palette::find_closest(const Color& color, float* dist) const float prep_y(powf(color.get_y(),2.2f)*color.get_a()); const float prep_u(color.get_u()); const float prep_v(color.get_v()); - + for(iter=begin();iter!=end();++iter) { const float diff_y(prep_y-powf(iter->color.get_y(),2.2f)*iter->color.get_a()); @@ -216,12 +216,12 @@ Palette::find_closest(const Color& color, float* dist) diff_y*diff_y*1.5f+ diff_a*diff_a+ - diff_u*diff_u+ + diff_u*diff_u+ diff_v*diff_v - + // cross product /*abs( - prep_u*iter->color.get_u()- + prep_u*iter->color.get_u()- prep_v*iter->color.get_v() )*/ ); @@ -233,7 +233,7 @@ Palette::find_closest(const Color& color, float* dist) } if(dist) *dist=best_dist; - + return best_match; } @@ -244,13 +244,13 @@ Palette::find_heavy() iterator iter; iterator best_match(begin()); - + for(iter=begin();iter!=end();++iter) { if(iter->weight>best_match->weight) best_match=iter; } - + return best_match; } @@ -260,13 +260,13 @@ Palette::find_light() iterator iter; iterator best_match(begin()); - + for(iter=begin();iter!=end();++iter) { if(iter->weightweight) best_match=iter; } - + return best_match; } @@ -294,12 +294,12 @@ Palette::save_to_file(const synfig::String& filename)const const_iterator iter; std::ofstream file(filename.c_str()); - + if(!file) throw strprintf(_("Unable to open %s for write"),filename.c_str()); - + file<name<color.get_g()<color.get_b()<color.get_a()<