0

これは、コントロールが int WindowRatio = WidthOfPreviewPane / HeightOfPreviewPane; に移動したときにクラッシュする画像の縦横比を維持するためのコードです。誰でも理由がわかりますか??

int WidthOfPreviewPane = RECTWIDTH(m_rcParent); 
int HeightOfPreviewPane = RECTHEIGHT(m_rcParent) ; 

int ImageRatio = WidthOfImage / HeightOfImage;
int WindowRatio = WidthOfPreviewPane / HeightOfPreviewPane;

if (WindowRatio > ImageRatio && WidthOfPreviewPane< WidthOfImage)
{
    m_iFinalHeight = HeightOfPreviewPane;
    m_iFinalWidth = m_iFinalHeight * ImageRatio;
    MessageBox(NULL, L"1",L"Error", 
            MB_ICONERROR | MB_OK);
}
else if (WindowRatio < ImageRatio && WidthOfPreviewPane< WidthOfImage)
{
    m_iFinalWidth = WidthOfPreviewPane;
    m_iFinalHeight = m_iFinalWidth / ImageRatio;
        MessageBox(NULL, L"2",L"Error", 
            MB_ICONERROR | MB_OK);
}
else if(WindowRatio > ImageRatio && WidthOfPreviewPane> WidthOfImage)
{
    m_iFinalHeight = HeightOfImage;
    m_iFinalWidth = WidthOfImage;
        MessageBox(NULL, L"3",L"Error", 
            MB_ICONERROR | MB_OK);

}
else if(WindowRatio < ImageRatio && WidthOfPreviewPane> WidthOfImage)
{
    m_iFinalHeight = HeightOfImage;
    m_iFinalWidth = WidthOfImage;
        MessageBox(NULL, L"4",L"Error", 
            MB_ICONERROR | MB_OK);

}
4

1 に答える 1