[MSPAINT] Use better units for image resolution (#5301)

Our paint program used the pixels per meter (PPM)
unit but this unit is hardly used in the world.
Let's use DPI (dots per inch) and/or pixels per
centimeter (PPCM). CORE-18867
This commit is contained in:
Katayama Hirofumi MZ 2023-06-04 11:24:00 +09:00 committed by GitHub
parent b29b2682bf
commit d708c7947b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 141 additions and 132 deletions

View file

@ -73,8 +73,6 @@ LRESULT CMirrorRotateDialog::OnRadioButton12(WORD wNotifyCode, WORD wID, HWND hW
return 0;
}
LRESULT CAttributesDialog::OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
newWidth = imageModel.GetWidth();
@ -98,8 +96,16 @@ LRESULT CAttributesDialog::OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam,
SetDlgItemText(IDD_ATTRIBUTESTEXT6, date);
SetDlgItemText(IDD_ATTRIBUTESTEXT7, strSize);
}
CString strUnit;
GetDlgItemText(IDD_ATTRIBUTESTEXT8, strUnit);
CString strRes;
strRes.Format(IDS_PRINTRES, (INT)PpmFromDpi(g_xDpi), (INT)PpmFromDpi(g_yDpi));
if (strUnit == L"dpi")
strRes.Format(IDS_PRINTRES, ROUND(g_xDpi), ROUND(g_yDpi));
else
strRes.Format(IDS_PRINTRES, ROUND(PpcmFromDpi(g_xDpi)), ROUND(PpcmFromDpi(g_yDpi)));
SetDlgItemText(IDD_ATTRIBUTESTEXT8, strRes);
return 0;
}
@ -146,9 +152,9 @@ LRESULT CAttributesDialog::OnRadioButton1(WORD wNotifyCode, WORD wID, HWND hWndC
LRESULT CAttributesDialog::OnRadioButton2(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
CString strNum;
strNum.Format(_T("%.3lf"), newWidth * 100 / PpmFromDpi(g_xDpi));
strNum.Format(_T("%.3lf"), newWidth / PpcmFromDpi(g_xDpi));
SetDlgItemText(IDD_ATTRIBUTESEDIT1, strNum);
strNum.Format(_T("%.3lf"), newHeight * 100 / PpmFromDpi(g_yDpi));
strNum.Format(_T("%.3lf"), newHeight / PpcmFromDpi(g_yDpi));
SetDlgItemText(IDD_ATTRIBUTESEDIT2, strNum);
return 0;
}
@ -173,7 +179,7 @@ LRESULT CAttributesDialog::OnEdit1(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOO
else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB2))
{
GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, _countof(tempS));
newWidth = max(1, (int) (_tcstod(tempS, NULL) * PpmFromDpi(g_xDpi) / 100));
newWidth = max(1, (int) (_tcstod(tempS, NULL) * PpcmFromDpi(g_xDpi)));
}
else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB3))
{
@ -198,7 +204,7 @@ LRESULT CAttributesDialog::OnEdit2(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOO
else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB2))
{
GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, _countof(tempS));
newHeight = max(1, (int) (_tcstod(tempS, NULL) * PpmFromDpi(g_yDpi) / 100));
newHeight = max(1, (int) (_tcstod(tempS, NULL) * PpcmFromDpi(g_yDpi)));
}
else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB3))
{