From e6c23361a12e994d529c5ab6c1ce904300b3bb71 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Fri, 11 Aug 2023 20:27:12 +0900 Subject: [PATCH] [MSPAINT] Support converting to black and white (#5554) - Add ImageModel::IsBlackAndWhite and ImageModel::PushBlackAndWhite helper functions. - Add CAttributesDialog::m_bBlackAndWhite. - If IDD_ATTRIBUTESRB4 is checked, then make the bitmap black and white. - Add IDS_LOSECOLOR to show message. CORE-19094 --- base/applications/mspaint/dialogs.cpp | 7 +++- base/applications/mspaint/dialogs.h | 1 + base/applications/mspaint/history.cpp | 44 +++++++++++++++++++++++++ base/applications/mspaint/history.h | 2 ++ base/applications/mspaint/lang/bg-BG.rc | 1 + base/applications/mspaint/lang/cs-CZ.rc | 1 + base/applications/mspaint/lang/de-DE.rc | 1 + base/applications/mspaint/lang/en-GB.rc | 1 + base/applications/mspaint/lang/en-US.rc | 1 + base/applications/mspaint/lang/es-ES.rc | 1 + base/applications/mspaint/lang/et-EE.rc | 1 + base/applications/mspaint/lang/eu-ES.rc | 1 + base/applications/mspaint/lang/fr-FR.rc | 1 + base/applications/mspaint/lang/he-IL.rc | 1 + base/applications/mspaint/lang/hu-HU.rc | 1 + base/applications/mspaint/lang/id-ID.rc | 1 + base/applications/mspaint/lang/it-IT.rc | 1 + base/applications/mspaint/lang/ja-JP.rc | 1 + base/applications/mspaint/lang/nl-NL.rc | 1 + base/applications/mspaint/lang/no-NO.rc | 1 + base/applications/mspaint/lang/pl-PL.rc | 1 + base/applications/mspaint/lang/pt-BR.rc | 1 + base/applications/mspaint/lang/pt-PT.rc | 1 + base/applications/mspaint/lang/ro-RO.rc | 1 + base/applications/mspaint/lang/ru-RU.rc | 1 + base/applications/mspaint/lang/sk-SK.rc | 1 + base/applications/mspaint/lang/sq-AL.rc | 1 + base/applications/mspaint/lang/sv-SE.rc | 1 + base/applications/mspaint/lang/tr-TR.rc | 1 + base/applications/mspaint/lang/uk-UA.rc | 1 + base/applications/mspaint/lang/vi-VN.rc | 1 + base/applications/mspaint/lang/zh-CN.rc | 1 + base/applications/mspaint/lang/zh-HK.rc | 1 + base/applications/mspaint/lang/zh-TW.rc | 1 + base/applications/mspaint/resource.h | 1 + base/applications/mspaint/winproc.cpp | 17 +++++++++- 36 files changed, 100 insertions(+), 2 deletions(-) diff --git a/base/applications/mspaint/dialogs.cpp b/base/applications/mspaint/dialogs.cpp index 7ec302dfe7f..9cda67b3d72 100644 --- a/base/applications/mspaint/dialogs.cpp +++ b/base/applications/mspaint/dialogs.cpp @@ -103,10 +103,14 @@ LRESULT CAttributesDialog::OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam, newHeight = imageModel.GetHeight(); CheckDlgButton(IDD_ATTRIBUTESRB3, BST_CHECKED); - CheckDlgButton(IDD_ATTRIBUTESRB5, BST_CHECKED); SetDlgItemInt(IDD_ATTRIBUTESEDIT1, newWidth, FALSE); SetDlgItemInt(IDD_ATTRIBUTESEDIT2, newHeight, FALSE); + if (imageModel.IsBlackAndWhite()) + CheckRadioButton(IDD_ATTRIBUTESRB4, IDD_ATTRIBUTESRB5, IDD_ATTRIBUTESRB4); + else + CheckRadioButton(IDD_ATTRIBUTESRB4, IDD_ATTRIBUTESRB5, IDD_ATTRIBUTESRB5); + if (g_isAFile) { TCHAR date[100]; @@ -142,6 +146,7 @@ LRESULT CAttributesDialog::OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL LRESULT CAttributesDialog::OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { + m_bBlackAndWhite = (IsDlgButtonChecked(IDD_ATTRIBUTESRB4) == BST_CHECKED); EndDialog(1); return 0; } diff --git a/base/applications/mspaint/dialogs.h b/base/applications/mspaint/dialogs.h index d760c59d556..f4354de11fe 100644 --- a/base/applications/mspaint/dialogs.h +++ b/base/applications/mspaint/dialogs.h @@ -64,6 +64,7 @@ public: public: int newWidth; int newHeight; + BOOL m_bBlackAndWhite; }; class CStretchSkewDialog : public CDialogImpl diff --git a/base/applications/mspaint/history.cpp b/base/applications/mspaint/history.cpp index 3f1878ad3d3..8867a53025a 100644 --- a/base/applications/mspaint/history.cpp +++ b/base/applications/mspaint/history.cpp @@ -267,3 +267,47 @@ HBITMAP ImageModel::CopyBitmap() m_hbmOld = ::SelectObject(m_hDrawingDC, m_hBms[m_currInd]); // Re-select return ret; } + +BOOL ImageModel::IsBlackAndWhite() +{ + LONG cxWidth = GetWidth(), cyHeight = GetHeight(); + for (LONG y = 0; y < cyHeight; ++y) + { + for (LONG x = 0; x < cxWidth; ++x) + { + COLORREF rgbColor = ::GetPixel(m_hDrawingDC, x, y); + if (rgbColor != RGB(0, 0, 0) && rgbColor != RGB(255, 255, 255)) + return FALSE; + } + } + return TRUE; +} + +void ImageModel::PushBlackAndWhite() +{ + HBITMAP hNewBitmap = CopyBitmap(); + if (!hNewBitmap) + return; + + HDC hdc2 = ::CreateCompatibleDC(NULL); + HGDIOBJ hbm2Old = ::SelectObject(hdc2, hNewBitmap); + LONG cxWidth = GetWidth(), cyHeight = GetHeight(); + for (LONG y = 0; y < cyHeight; ++y) + { + for (LONG x = 0; x < cxWidth; ++x) + { + COLORREF rgbColor = ::GetPixel(m_hDrawingDC, x, y); + BYTE Red = GetRValue(rgbColor); + BYTE Green = GetGValue(rgbColor); + BYTE Blue = GetBValue(rgbColor); + if ((Red + Green + Blue) / 3 >= 255 / 2) + ::SetPixelV(hdc2, x, y, RGB(255, 255, 255)); // White + else + ::SetPixelV(hdc2, x, y, RGB(0, 0, 0)); // Black + } + } + ::SelectObject(hdc2, hbm2Old); + ::DeleteDC(hdc2); + + PushImageForUndo(hNewBitmap); +} diff --git a/base/applications/mspaint/history.h b/base/applications/mspaint/history.h index b9fe323db67..5bee4105240 100644 --- a/base/applications/mspaint/history.h +++ b/base/applications/mspaint/history.h @@ -37,6 +37,8 @@ public: void RotateNTimes90Degrees(int iN); void Clamp(POINT& pt) const; void NotifyImageChanged(); + BOOL IsBlackAndWhite(); + void PushBlackAndWhite(); protected: HDC m_hDrawingDC; // The device context for this class diff --git a/base/applications/mspaint/lang/bg-BG.rc b/base/applications/mspaint/lang/bg-BG.rc index 66bf74763c3..cfc791946ae 100644 --- a/base/applications/mspaint/lang/bg-BG.rc +++ b/base/applications/mspaint/lang/bg-BG.rc @@ -264,4 +264,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/cs-CZ.rc b/base/applications/mspaint/lang/cs-CZ.rc index 57608b40f96..32d33bf98d2 100644 --- a/base/applications/mspaint/lang/cs-CZ.rc +++ b/base/applications/mspaint/lang/cs-CZ.rc @@ -264,4 +264,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/de-DE.rc b/base/applications/mspaint/lang/de-DE.rc index fb947b1eeb2..20fb505484f 100644 --- a/base/applications/mspaint/lang/de-DE.rc +++ b/base/applications/mspaint/lang/de-DE.rc @@ -263,4 +263,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/en-GB.rc b/base/applications/mspaint/lang/en-GB.rc index 9dc21b13c6a..b5267ad1d0e 100644 --- a/base/applications/mspaint/lang/en-GB.rc +++ b/base/applications/mspaint/lang/en-GB.rc @@ -263,4 +263,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/en-US.rc b/base/applications/mspaint/lang/en-US.rc index 805c239e8d0..987e1ab7449 100644 --- a/base/applications/mspaint/lang/en-US.rc +++ b/base/applications/mspaint/lang/en-US.rc @@ -264,4 +264,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/es-ES.rc b/base/applications/mspaint/lang/es-ES.rc index a851b972dfc..850307363b6 100644 --- a/base/applications/mspaint/lang/es-ES.rc +++ b/base/applications/mspaint/lang/es-ES.rc @@ -266,4 +266,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/et-EE.rc b/base/applications/mspaint/lang/et-EE.rc index 78d33480f3a..b3996096fd2 100644 --- a/base/applications/mspaint/lang/et-EE.rc +++ b/base/applications/mspaint/lang/et-EE.rc @@ -263,4 +263,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/eu-ES.rc b/base/applications/mspaint/lang/eu-ES.rc index f9f38cd2056..708d62466d2 100644 --- a/base/applications/mspaint/lang/eu-ES.rc +++ b/base/applications/mspaint/lang/eu-ES.rc @@ -264,4 +264,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/fr-FR.rc b/base/applications/mspaint/lang/fr-FR.rc index 8ea08410321..9fd0034abdc 100644 --- a/base/applications/mspaint/lang/fr-FR.rc +++ b/base/applications/mspaint/lang/fr-FR.rc @@ -264,4 +264,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/he-IL.rc b/base/applications/mspaint/lang/he-IL.rc index 7735f853725..1623e258a0c 100644 --- a/base/applications/mspaint/lang/he-IL.rc +++ b/base/applications/mspaint/lang/he-IL.rc @@ -266,4 +266,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/hu-HU.rc b/base/applications/mspaint/lang/hu-HU.rc index 03315eabded..07f84d6a3a9 100644 --- a/base/applications/mspaint/lang/hu-HU.rc +++ b/base/applications/mspaint/lang/hu-HU.rc @@ -264,4 +264,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/id-ID.rc b/base/applications/mspaint/lang/id-ID.rc index eeda00200d3..556aa5efb6c 100644 --- a/base/applications/mspaint/lang/id-ID.rc +++ b/base/applications/mspaint/lang/id-ID.rc @@ -263,4 +263,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/it-IT.rc b/base/applications/mspaint/lang/it-IT.rc index 63ad7624367..ae66f2a3e33 100644 --- a/base/applications/mspaint/lang/it-IT.rc +++ b/base/applications/mspaint/lang/it-IT.rc @@ -264,4 +264,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/ja-JP.rc b/base/applications/mspaint/lang/ja-JP.rc index a98a0f73bab..c6e72466acc 100644 --- a/base/applications/mspaint/lang/ja-JP.rc +++ b/base/applications/mspaint/lang/ja-JP.rc @@ -265,4 +265,5 @@ BEGIN IDS_CANTPASTE "クリップボードからの貼り付けに失敗しました。データ形式が間違っているか、未対応です。" IDS_SAVEERROR "次のファイルとして画像を保存するのに失敗しました:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/nl-NL.rc b/base/applications/mspaint/lang/nl-NL.rc index 29daec70fc7..199c8be03f7 100644 --- a/base/applications/mspaint/lang/nl-NL.rc +++ b/base/applications/mspaint/lang/nl-NL.rc @@ -263,4 +263,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/no-NO.rc b/base/applications/mspaint/lang/no-NO.rc index 7a16a4d668f..3cc7679639f 100644 --- a/base/applications/mspaint/lang/no-NO.rc +++ b/base/applications/mspaint/lang/no-NO.rc @@ -263,4 +263,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/pl-PL.rc b/base/applications/mspaint/lang/pl-PL.rc index b35b2691d2a..04dde3f8aa4 100644 --- a/base/applications/mspaint/lang/pl-PL.rc +++ b/base/applications/mspaint/lang/pl-PL.rc @@ -266,4 +266,5 @@ BEGIN IDS_CANTPASTE "Nie można wkleić ze schowka. Format danych jest nieprawidłowy lub nieobsługiwany." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/pt-BR.rc b/base/applications/mspaint/lang/pt-BR.rc index c551cd77671..fc38012623b 100644 --- a/base/applications/mspaint/lang/pt-BR.rc +++ b/base/applications/mspaint/lang/pt-BR.rc @@ -264,4 +264,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/pt-PT.rc b/base/applications/mspaint/lang/pt-PT.rc index 7ff2ba98503..7457d339fee 100644 --- a/base/applications/mspaint/lang/pt-PT.rc +++ b/base/applications/mspaint/lang/pt-PT.rc @@ -264,4 +264,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/ro-RO.rc b/base/applications/mspaint/lang/ro-RO.rc index 447e01c5337..516d15bc335 100644 --- a/base/applications/mspaint/lang/ro-RO.rc +++ b/base/applications/mspaint/lang/ro-RO.rc @@ -265,4 +265,5 @@ BEGIN IDS_CANTPASTE "Nu a putut fi lipit din clipboard. Formatul de date este fie incorect, fie nesuportat." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/ru-RU.rc b/base/applications/mspaint/lang/ru-RU.rc index 125eadbcfdf..94e187feb63 100644 --- a/base/applications/mspaint/lang/ru-RU.rc +++ b/base/applications/mspaint/lang/ru-RU.rc @@ -267,4 +267,5 @@ BEGIN IDS_CANTPASTE "Не удалось вставить из буфера обмена. Формат данных либо некорректный, либо не поддерживается." IDS_SAVEERROR "Не удалось сохранить точечный рисунок в файл:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/sk-SK.rc b/base/applications/mspaint/lang/sk-SK.rc index dd80ce12592..16695f6d212 100644 --- a/base/applications/mspaint/lang/sk-SK.rc +++ b/base/applications/mspaint/lang/sk-SK.rc @@ -263,4 +263,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/sq-AL.rc b/base/applications/mspaint/lang/sq-AL.rc index a60ef9a2774..916fb382a0d 100644 --- a/base/applications/mspaint/lang/sq-AL.rc +++ b/base/applications/mspaint/lang/sq-AL.rc @@ -263,4 +263,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/sv-SE.rc b/base/applications/mspaint/lang/sv-SE.rc index dfe72b9b0b9..95a379dbdf8 100644 --- a/base/applications/mspaint/lang/sv-SE.rc +++ b/base/applications/mspaint/lang/sv-SE.rc @@ -264,4 +264,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/tr-TR.rc b/base/applications/mspaint/lang/tr-TR.rc index fab8c39fcc3..42706400c2d 100644 --- a/base/applications/mspaint/lang/tr-TR.rc +++ b/base/applications/mspaint/lang/tr-TR.rc @@ -264,4 +264,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/uk-UA.rc b/base/applications/mspaint/lang/uk-UA.rc index f0e0676589a..3df7b6724fa 100644 --- a/base/applications/mspaint/lang/uk-UA.rc +++ b/base/applications/mspaint/lang/uk-UA.rc @@ -265,4 +265,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/vi-VN.rc b/base/applications/mspaint/lang/vi-VN.rc index b1c7c2cc227..6d5847da4b3 100644 --- a/base/applications/mspaint/lang/vi-VN.rc +++ b/base/applications/mspaint/lang/vi-VN.rc @@ -263,4 +263,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/zh-CN.rc b/base/applications/mspaint/lang/zh-CN.rc index 43fa7f34582..ec8eab59263 100644 --- a/base/applications/mspaint/lang/zh-CN.rc +++ b/base/applications/mspaint/lang/zh-CN.rc @@ -266,4 +266,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/zh-HK.rc b/base/applications/mspaint/lang/zh-HK.rc index ff88459ddc6..748acf93f03 100644 --- a/base/applications/mspaint/lang/zh-HK.rc +++ b/base/applications/mspaint/lang/zh-HK.rc @@ -264,4 +264,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/lang/zh-TW.rc b/base/applications/mspaint/lang/zh-TW.rc index 10401e53cb8..d3c35628019 100644 --- a/base/applications/mspaint/lang/zh-TW.rc +++ b/base/applications/mspaint/lang/zh-TW.rc @@ -264,4 +264,5 @@ BEGIN IDS_CANTPASTE "Failed to paste from the clipboard. The data format is either incorrect or not supported." IDS_SAVEERROR "Failed to save the bitmap to file:\n\n%s" IDS_CANTSENDMAIL "Failed to send a mail." + IDS_LOSECOLOR "The color information will be lost in this operation. Are you sure to proceed?" END diff --git a/base/applications/mspaint/resource.h b/base/applications/mspaint/resource.h index 4ec9f9a0f98..310554de200 100644 --- a/base/applications/mspaint/resource.h +++ b/base/applications/mspaint/resource.h @@ -222,3 +222,4 @@ #define IDS_CANTPASTE 940 #define IDS_SAVEERROR 941 #define IDS_CANTSENDMAIL 942 +#define IDS_LOSECOLOR 943 diff --git a/base/applications/mspaint/winproc.cpp b/base/applications/mspaint/winproc.cpp index 7aa25091766..3db01639a34 100644 --- a/base/applications/mspaint/winproc.cpp +++ b/base/applications/mspaint/winproc.cpp @@ -949,7 +949,22 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH { if (attributesDialog.DoModal(mainWindow.m_hWnd)) { - imageModel.Crop(attributesDialog.newWidth, attributesDialog.newHeight, 0, 0); + if (attributesDialog.m_bBlackAndWhite && !imageModel.IsBlackAndWhite()) + { + CString strText(MAKEINTRESOURCE(IDS_LOSECOLOR)); + CString strTitle(MAKEINTRESOURCE(IDS_PROGRAMNAME)); + INT id = MessageBox(strText, strTitle, MB_ICONINFORMATION | MB_YESNOCANCEL); + if (id != IDYES) + break; + + imageModel.PushBlackAndWhite(); + } + + if (imageModel.GetWidth() != attributesDialog.newWidth || + imageModel.GetHeight() != attributesDialog.newHeight) + { + imageModel.Crop(attributesDialog.newWidth, attributesDialog.newHeight); + } } break; }