[MSPAINT] Implement canvas rotation (#4360)

- Add Rotate90DegreeBlt function to dib.cpp.
- Implement ImageModel::RotateNTimes90Degrees and SelectionModel::RotateNTimes90Degrees.
- Improve ToolsModel::SetBackgroundTransparent.
- Extend and improve SelectionModel::InsertFromHBITMAP.
CORE-16634
This commit is contained in:
Katayama Hirofumi MZ 2022-02-14 12:08:34 +09:00 committed by GitHub
parent 6eccbe27ec
commit 2d90919047
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 86 additions and 7 deletions

View file

@ -208,3 +208,38 @@ HBITMAP DoLoadImageFile(HWND hwnd, LPCTSTR name, BOOL fIsMainFile)
return hBitmap;
}
HBITMAP Rotate90DegreeBlt(HDC hDC1, INT cx, INT cy, BOOL bRight)
{
HBITMAP hbm2 = CreateDIBWithProperties(cy, cx);
if (!hbm2)
return NULL;
HDC hDC2 = CreateCompatibleDC(NULL);
HGDIOBJ hbm2Old = SelectObject(hDC2, hbm2);
if (bRight)
{
for (INT y = 0; y < cy; ++y)
{
for (INT x = 0; x < cx; ++x)
{
COLORREF rgb = GetPixel(hDC1, x, y);
SetPixelV(hDC2, cy - (y + 1), x, rgb);
}
}
}
else
{
for (INT y = 0; y < cy; ++y)
{
for (INT x = 0; x < cx; ++x)
{
COLORREF rgb = GetPixel(hDC1, x, y);
SetPixelV(hDC2, y, cx - (x + 1), rgb);
}
}
}
SelectObject(hDC2, hbm2Old);
DeleteDC(hDC2);
return hbm2;
}