mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
fixed aspect ratio in the editor's image preview. Closes #784
This commit is contained in:
parent
f1ea039df7
commit
003c0aa281
|
@ -2417,6 +2417,9 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
|
|||
r.w = r.h;
|
||||
else
|
||||
r.h = r.w;
|
||||
float Max = (float)(max(m_Map.m_lImages[i]->m_Width, m_Map.m_lImages[i]->m_Height));
|
||||
r.w *= m_Map.m_lImages[i]->m_Width/Max;
|
||||
r.h *= m_Map.m_lImages[i]->m_Height/Max;
|
||||
Graphics()->TextureSet(m_Map.m_lImages[i]->m_TexID);
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->QuadsBegin();
|
||||
|
|
|
@ -703,7 +703,16 @@ int CEditor::PopupSelectImage(CEditor *pEditor, CUIRect View)
|
|||
}
|
||||
|
||||
if(ShowImage >= 0 && ShowImage < pEditor->m_Map.m_lImages.size())
|
||||
{
|
||||
if(ImageView.h < ImageView.w)
|
||||
ImageView.w = ImageView.h;
|
||||
else
|
||||
ImageView.h = ImageView.w;
|
||||
float Max = (float)(max(pEditor->m_Map.m_lImages[ShowImage]->m_Width, pEditor->m_Map.m_lImages[ShowImage]->m_Height));
|
||||
ImageView.w *= pEditor->m_Map.m_lImages[ShowImage]->m_Width/Max;
|
||||
ImageView.h *= pEditor->m_Map.m_lImages[ShowImage]->m_Height/Max;
|
||||
pEditor->Graphics()->TextureSet(pEditor->m_Map.m_lImages[ShowImage]->m_TexID);
|
||||
}
|
||||
else
|
||||
pEditor->Graphics()->TextureSet(-1);
|
||||
pEditor->Graphics()->QuadsBegin();
|
||||
|
|
Loading…
Reference in a new issue