mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 20:53:02 +00:00
[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:
parent
6eccbe27ec
commit
2d90919047
9 changed files with 86 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue