mirror of
https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
synced 2023-10-19 17:58:31 +02:00
Center scaled image in the available target space when preserving aspect
This commit is contained in:
parent
28413f7f2c
commit
0d5773cb7f
@ -33,10 +33,17 @@ cImage *cImageLoader::CreateImage(int width, int height, bool preserveAspect) {
|
||||
double sx = width / (double)w;
|
||||
double sy = height / (double)h;
|
||||
if (preserveAspect) {
|
||||
if (sx < sy)
|
||||
double tx = 0;
|
||||
double ty = 0;
|
||||
if (sx < sy) {
|
||||
sy = sx;
|
||||
if (sy < sx)
|
||||
ty = (height - h * sy) / 2;
|
||||
}
|
||||
if (sy < sx) {
|
||||
sx = sy;
|
||||
tx = (width - w * sx) / 2;
|
||||
}
|
||||
cairo_translate(cr, tx, ty);
|
||||
}
|
||||
cairo_scale(cr, sx, sy);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user