728x90
반응형
728x170
using System.Drawing;
using System.Windows.Forms;
#region 비트맵 구하기 - GetBitmap(sourceControl, targetSize)
/// <summary>
/// 비트맵 구하기
/// </summary>
/// <param name="sourceControl">소스 컨트롤</param>
/// <param name="targetSize">타겟 크기</param>
/// <returns>비트맵</returns>
public Bitmap GetBitmap(Control sourceControl, Size targetSize)
{
Size formSize = sourceControl.Size;
Rectangle rectangle = new Rectangle(new Point(0, 0), formSize);
Bitmap sourceBitmap = new Bitmap(formSize.Width, formSize.Height);
sourceControl.DrawToBitmap(sourceBitmap, rectangle);
Bitmap targetBitmap = new Bitmap(targetSize.Width, targetSize.Height);
Graphics targetGraphics = Graphics.FromImage(targetBitmap);
rectangle.Size = targetSize;
targetGraphics.DrawImage(sourceBitmap, rectangle);
return targetBitmap;
}
#endregion
728x90
반응형
그리드형(광고전용)
'C# > WinForm' 카테고리의 다른 글
[C#/WINFORM] PictureBox 클래스 : 사용자 그리기 및 확대/축소하기 (0) | 2020.07.05 |
---|---|
[C#/WINFORM] PictureBox 클래스 : 사용자 선 그리기 (0) | 2020.07.05 |
[C#/WINFORM] CommonOpenFileDialog 클래스 : 표준 윈도우즈 대화 상자를 사용해 폴더 선택하기 (0) | 2020.07.05 |
[C#/WINFORM] ListView 클래스 : 항목 인덱스 구하기 (0) | 2020.06.08 |
[C#/WINFORM] ListView 클래스 : 선택 항목 리스트 구하기 (0) | 2020.06.08 |
[C#/WINFORM] Bitmap 클래스 : 회색조 비트맵 구하기 (0) | 2020.06.04 |
[C#/WINFORM/.NETCORE] WinForm .Net Core Class Library 사용하기 (0) | 2020.06.02 |
[C#/WINFORM] Label 클래스 : BackColor 속성을 사용해 투명 배경 설정하기 (0) | 2020.05.27 |
[C#/WINFORM] Cursor 클래스 : Position 정적 속성을 사용해 크레이지 커서 만들기 (0) | 2020.05.26 |
[C#/WINFORM] 윈도우 메시지(Window Message) 상수 (0) | 2020.05.22 |
댓글을 달아 주세요