improve picture widget stretchable mode

This commit is contained in:
Jinhao
2015-02-23 18:05:18 +08:00
parent d7a0d6f7d3
commit 022f7168c0
3 changed files with 170 additions and 17 deletions

View File

@@ -246,6 +246,19 @@ namespace nana
result_s = ref_s;
}
size fit_zoom(const size& input_s, size ref_s)
{
double rate_input = double(input_s.width) / double(input_s.height);
double rate_ref = double(ref_s.width) / double(ref_s.height);
if (rate_input < rate_ref)
ref_s.width = static_cast<unsigned>(ref_s.height * rate_input);
else if (rate_input > rate_ref)
ref_s.height = static_cast<unsigned>(ref_s.width / rate_input);
return ref_s;
}
void zoom(const rectangle& ref, const rectangle& scaled, const rectangle& ref_dst, rectangle& r)
{
double rate_x = (scaled.x - ref.x) / double(ref.width);