Scale logo to fit box.

Fixes ticket:3667.
master
Cyp 2012-09-09 18:35:57 +02:00
parent b256d995b8
commit 47011db59e
3 changed files with 36 additions and 5 deletions

View File

@ -283,6 +283,24 @@ void iV_DrawImageRect(IMAGEFILE *ImageFile, UWORD ID, int x, int y, int Width, i
}
}
void iV_DrawImageScaled(IMAGEFILE *ImageFile, UWORD ID, int x, int y, int w, int h)
{
if (!assertValidImage(ImageFile, ID))
{
return;
}
PIERECT dest;
PIEIMAGE pieImage = makePieImage(ImageFile, ID, &dest, x, y);
dest.w = w;
dest.h = h;
pie_SetRendMode(REND_ALPHA);
pie_SetAlphaTest(true);
pie_DrawImage(&pieImage, &dest);
}
/* FIXME: WTF is this supposed to do? Looks like some other functionality
* was retrofitted onto something else. - Per */
void pie_UploadDisplayBuffer()

View File

@ -67,6 +67,7 @@ extern void pie_BoxFill(int x0,int y0, int x1, int y1, PIELIGHT colour);
extern void iV_DrawImage(IMAGEFILE *ImageFile, UWORD ID, int x, int y);
void iV_DrawImageTc(IMAGEFILE *imageFile, unsigned id, unsigned idTc, int x, int y, PIELIGHT colour);
extern void iV_DrawImageRect(IMAGEFILE *ImageFile, UWORD ID, int x, int y, int Width, int Height);
void iV_DrawImageScaled(IMAGEFILE *ImageFile, UWORD ID, int x, int y, int w, int h);
extern void iV_TransBoxFill(float x0, float y0, float x1, float y1);
extern void pie_UniTransBoxFill(float x0, float y0, float x1, float y1, PIELIGHT colour);

View File

@ -1494,7 +1494,7 @@ static void displayTitleBitmap(WZ_DECL_UNUSED WIDGET *psWidget, WZ_DECL_UNUSED U
// show warzone logo
static void displayLogo(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
{
iV_DrawImage(FrontImages, IMAGE_FE_LOGO, xOffset + psWidget->x, std::max<int>(yOffset + psWidget->y, 0));
iV_DrawImageScaled(FrontImages, IMAGE_FE_LOGO, xOffset + psWidget->x, yOffset + psWidget->y, psWidget->width, psWidget->height);
}
@ -1678,10 +1678,22 @@ void addTopForm(void)
sFormInit.formID= FRONTEND_TOPFORM;
sFormInit.id = FRONTEND_LOGO;
sFormInit.x = sFormInit.width/2 - iV_GetImageWidth(FrontImages, IMAGE_FE_LOGO)/2;
sFormInit.y = sFormInit.height/2 - iV_GetImageHeight(FrontImages, IMAGE_FE_LOGO)/2;
sFormInit.width = iV_GetImageWidth(FrontImages, IMAGE_FE_LOGO);
sFormInit.height= iV_GetImageHeight(FrontImages, IMAGE_FE_LOGO);
int imgW = iV_GetImageWidth(FrontImages, IMAGE_FE_LOGO);
int imgH = iV_GetImageHeight(FrontImages, IMAGE_FE_LOGO);
int dstW = sFormInit.width;
int dstH = sFormInit.height;
if (imgW*dstH < imgH*dstW) // Want to set aspect ratio dstW/dstH = imgW/imgH.
{
dstW = imgW * dstH/imgH; // Too wide.
}
else if (imgW*dstH > imgH*dstW)
{
dstH = imgH * dstW/imgW; // Too high.
}
sFormInit.x = (sFormInit.width - dstW)/2;
sFormInit.y = (sFormInit.height - dstH)/2;
sFormInit.width = dstW;
sFormInit.height = dstH;
sFormInit.pDisplay= displayLogo;
widgAddForm(psWScreen, &sFormInit);
}