Mercurial > pidgin
diff src/buddyicon.c @ 10523:f5c9438982f8
[gaim-migrate @ 11840]
This should preserve aspect ratios when scaling buddy icons.
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Tue, 18 Jan 2005 02:16:48 +0000 |
parents | 748aa3c6de36 |
children | 0f7452b1f777 |
line wrap: on
line diff
--- a/src/buddyicon.c Tue Jan 18 02:11:51 2005 +0000 +++ b/src/buddyicon.c Tue Jan 18 02:16:48 2005 +0000 @@ -454,18 +454,32 @@ void gaim_buddy_icon_get_scale_size(GaimBuddyIconSpec *spec, int *width, int *height) { - /* this should eventually get smarter about preserving the aspect - * ratio when scaling, but gimmie a break, I just woke up */ if(spec && spec->scale_rules & GAIM_ICON_SCALE_DISPLAY) { + int new_width, new_height; + + new_width = *width; + new_height = *height; + if(*width < spec->min_width) - *width = spec->min_width; + new_width = spec->min_width; else if(*width > spec->max_width) - *width = spec->max_width; + new_width = spec->max_width; if(*height < spec->min_height) - *height = spec->min_height; + new_height = spec->min_height; else if(*height > spec->max_height) - *height = spec->max_height; + new_height = spec->max_height; + + /* preserve aspect ratio */ + if ((double)*height * (double)new_width > + (double)*width * (double)new_height) { + new_width = 0.5 + (double)*width * (double)new_height / (double)*height; + } else { + new_height = 0.5 + (double)*height * (double)new_width / (double)*width; + } + + *width = new_width; + *height = new_height; } }