Mercurial > pidgin.yaz
comparison 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 |
comparison
equal
deleted
inserted
replaced
10522:e8b160971254 | 10523:f5c9438982f8 |
---|---|
452 g_hash_table_destroy(account_cache); | 452 g_hash_table_destroy(account_cache); |
453 } | 453 } |
454 | 454 |
455 void gaim_buddy_icon_get_scale_size(GaimBuddyIconSpec *spec, int *width, int *height) | 455 void gaim_buddy_icon_get_scale_size(GaimBuddyIconSpec *spec, int *width, int *height) |
456 { | 456 { |
457 /* this should eventually get smarter about preserving the aspect | |
458 * ratio when scaling, but gimmie a break, I just woke up */ | |
459 if(spec && spec->scale_rules & GAIM_ICON_SCALE_DISPLAY) { | 457 if(spec && spec->scale_rules & GAIM_ICON_SCALE_DISPLAY) { |
458 int new_width, new_height; | |
459 | |
460 new_width = *width; | |
461 new_height = *height; | |
462 | |
460 if(*width < spec->min_width) | 463 if(*width < spec->min_width) |
461 *width = spec->min_width; | 464 new_width = spec->min_width; |
462 else if(*width > spec->max_width) | 465 else if(*width > spec->max_width) |
463 *width = spec->max_width; | 466 new_width = spec->max_width; |
464 | 467 |
465 if(*height < spec->min_height) | 468 if(*height < spec->min_height) |
466 *height = spec->min_height; | 469 new_height = spec->min_height; |
467 else if(*height > spec->max_height) | 470 else if(*height > spec->max_height) |
468 *height = spec->max_height; | 471 new_height = spec->max_height; |
469 } | 472 |
470 } | 473 /* preserve aspect ratio */ |
471 | 474 if ((double)*height * (double)new_width > |
475 (double)*width * (double)new_height) { | |
476 new_width = 0.5 + (double)*width * (double)new_height / (double)*height; | |
477 } else { | |
478 new_height = 0.5 + (double)*height * (double)new_width / (double)*width; | |
479 } | |
480 | |
481 *width = new_width; | |
482 *height = new_height; | |
483 } | |
484 } | |
485 |