728x90
728x170
■ Bitmap 클래스를 사용해 비트맵을 회전하는 방법을 보여준다.
▶ 예제 코드 (C#)
using System.Drawing;
using System.Drawing.Drawing2D;
#region 비트맵 회전하기 - RotateBitmap(sourceBitmap, angle)
/// <summary>
/// 비트맵 회전하기
/// </summary>
/// <param name="sourceBitmap">소스 비트맵</param>
/// <param name="angle">각도</param>
/// <returns>회전 비트맵</returns>
public Bitmap RotateBitmap(Bitmap sourceBitmap, double angle)
{
Bitmap targetBitmap = new Bitmap(sourceBitmap.Width, sourceBitmap.Height);
using(Graphics graphics = Graphics.FromImage(targetBitmap))
{
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.TranslateTransform(sourceBitmap.Width / 2, sourceBitmap.Height / 2);
graphics.RotateTransform(-(float)angle);
graphics.DrawImage
(
sourceBitmap,
-sourceBitmap.Width / 2,
-sourceBitmap.Height / 2,
sourceBitmap.Width,
sourceBitmap.Height
);
}
return targetBitmap;
}
#endregion
728x90
그리드형(광고전용)
'C# > WinForm' 카테고리의 다른 글
[C#/WINFORM] UserControl 클래스 : 푯말 레이블 사용하기 (0) | 2019.12.28 |
---|---|
[C#/WINFORM] UserControl 클래스 : 체크 버튼 사용하기 (0) | 2019.12.28 |
[C#/WINFORM] Label 클래스 : 외곽선 텍스트 사용하기 (0) | 2019.12.27 |
[C#/WINFORM] WebBrowser 클래스 : DocumentText 속성을 사용해 HTML 문자열 설정하기 (0) | 2019.12.26 |
[C#/WINFORM] 스캔 이미지 왜곡 자동 보정하기 (0) | 2019.12.24 |
[C#/WINFORM] Form 클래스 : 마우스 위치에 따라 폼 불투명도 변경하기 (0) | 2019.11.29 |
[C#/WINFORM] Process 클래스 : BeginOutputReadLine 메소드를 사용해 도스 명령 실행 결과 구하기 (0) | 2019.10.19 |
[C#/WINFORM] TreeView 클래스 : 드래그 & 드롭 사용하기 (0) | 2019.10.03 |
[C#/WINFORM] TreeView 클래스 : 첫번째 종말 노드 구하기 (0) | 2019.09.15 |
[C#/WINFORM] TreeView 클래스 : 특정 레벨까지 노드 확장하기 (0) | 2019.09.15 |