diff options
author | louis <louis.braun@gmx.de> | 2013-10-25 20:50:08 +0200 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2013-10-25 20:50:08 +0200 |
commit | 1aa2f6ace2419406b305f9fe238d9d341f761c73 (patch) | |
tree | b58da850e207efd038ac0b88cbdf9fa444667dfd /helpers.c | |
parent | 086588958f25fcf065a947bd908e65c4a4c345bd (diff) | |
download | skin-nopacity-1aa2f6ace2419406b305f9fe238d9d341f761c73.tar.gz skin-nopacity-1aa2f6ace2419406b305f9fe238d9d341f761c73.tar.bz2 |
Version 0.9.0
Diffstat (limited to 'helpers.c')
-rw-r--r-- | helpers.c | 35 |
1 files changed, 30 insertions, 5 deletions
@@ -13,15 +13,12 @@ static cOsd *CreateOsd(int Left, int Top, int Width, int Height) { return NULL; } -static void DrawBlendedBackground(cPixmap *pixmap, tColor color, tColor colorBlending, bool fromTop) { - int width = pixmap->ViewPort().Width(); +static void DrawBlendedBackground(cPixmap *pixmap, int xStart, int width, tColor color, tColor colorBlending, bool fromTop) { int height = pixmap->ViewPort().Height(); - pixmap->Fill(color); int numSteps = 16; int alphaStep = 0x0F; int alpha = 0x00; int step, begin, end; - bool cont = true; if (fromTop) { step = 1; begin = 0; @@ -32,9 +29,10 @@ static void DrawBlendedBackground(cPixmap *pixmap, tColor color, tColor colorBle end = height - numSteps; } tColor clr; + bool cont = true; for (int i = begin; cont; i = i + step) { clr = AlphaBlend(color, colorBlending, alpha); - pixmap->DrawRectangle(cRect(0,i,width,1), clr); + pixmap->DrawRectangle(cRect(xStart,i,width,1), clr); alpha += alphaStep; if (i == end) cont = false; @@ -75,6 +73,33 @@ static void DrawRoundedCornersWithBorder(cPixmap *p, tColor borderColor, int rad } +static cSize ScaleToFit(int widthMax, int heightMax, int widthOriginal, int heightOriginal) { + int width = 1; + int height = 1; + + if ((widthMax == 0)||(heightMax==0)||(widthOriginal==0)||(heightOriginal==0)) + return cSize(width, height); + + if ((widthOriginal <= widthMax) && (heightOriginal <= heightMax)) { + width = widthOriginal; + height = heightOriginal; + } else if ((widthOriginal > widthMax) && (heightOriginal <= heightMax)) { + width = widthMax; + height = (double)width/(double)widthOriginal * heightOriginal; + } else if ((widthOriginal <= widthMax) && (heightOriginal > heightMax)) { + height = heightMax; + width = (double)height/(double)heightOriginal * widthOriginal; + } else { + width = widthMax; + height = (double)width/(double)widthOriginal * heightOriginal; + if (height > heightMax) { + height = heightMax; + width = (double)height/(double)heightOriginal * widthOriginal; + } + } + return cSize(width, height); +} + static int Minimum(int a, int b, int c, int d, int e, int f) { int min = a; if (b < min) min = b; |