mfc_GDI_Rotation - 8BitsCoding/RobotMentor GitHub Wiki

CPaintDC dc(this);
Graphics ScreenG(dc.GetSafeHdc());
Bitmap *pBitmap;
pBitmap = (Bitmap*)Image::FromFile(๊ฐ€์ ธ์˜ฌJPG๊ฒฝ๋กœ);
Gdiplus::Matrix matrix;
matrix.RotateAt(์›ํ•˜๋Š” ๊ฐ๋„(์˜ˆ:235.7), Gdiplus::PointF((float)(pBitmap->GetWidth()/2), (float)(pBitmap->GetHeight()/2)));
                           //ํ•ด๋‹น ์ด๋ฏธ์ง€์˜ ์ •์ค‘์•™์„ ๊ธฐ์ค€์œผ๋กœ 235.7๋„ ๋Œ๋ฆฌ๋ผ๋Š” ์–˜๊ธฐ์ž…๋‹ˆ๋‹ค. 
                           //์ฐธ๊ณ ๋กœ ๊ฐ€์šด๋ฐ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋Œ๋ฆฌ๊ธฐ ์œ„ํ•ด์„œ๋Š” ์ด๋ฏธ์ง€์˜ ๊ฐ€๋กœ์„ธ๋กœ ์‚ฌ์ด์ฆˆ๊ฐ€ ํ™€์ˆ˜์—ฌ์•ผ ๊น”๋”ํ•˜๊ฒŒ ๋Œ์•„๊ฐˆ๊ฒ๋‹ˆ๋‹ค.
ScreenG.SetTransform(&matrix); //ScreenG๋ฅผ ์œ„์— ๊ทœ์น™๋Œ€๋กœ ๋Œ๋ ค๋ฒ„๋ ธ์Šต๋‹ˆ๋‹ค.
ScreenG.DrawImage(pBitmap, 0, 0); //์ด๋ฏธ ๋Œ์•„๊ฐ„ ScreenG์— pBitmap ์ด๋ฏธ์ง€๋ฅผ ๊ทธ๋ ค์ค๋‹ˆ๋‹ค. ์•Œ์•„์„œ ๊ฐ™์ด ๋Œ์•„๊ฐ€๊ฒŒ๋ฉ๋‹ˆ๋‹ค.
delete pBitmap;

Roation์‹œ Matrix ์ค‘๋ณตํ•ด์„œ ์‚ฌ์šฉํ•˜๋ฉด ์•ˆ๋จ

Rotation์ดํ›„ Matrix ๋ฆฌ์…‹ํ•ด์ค˜์•ผํ•จ ์ดํ›„์— ์˜ํ–ฅ์„ ์คŒ