728x90
728x170
■ Bitmap 클래스를 사용해 비트맵 크기를 변경하는 방법을 보여준다.
▶ 예제 코드 (C#)
using System.Drawing;
#region 비트맵 크기 변경하기 - ResizeBitmap(sourceBitmap, targetWidth, targetHeight)
/// <summary>
/// 비트맵 크기 변경하기
/// </summary>
/// <param name="sourceBitmap">소스 비트맵</param>
/// <param name="targetWidth">타겟 너비</param>
/// <param name="targetHeight">타겟 높이</param>
/// <returns>크기 변경 비트맵</returns>
public Bitmap ResizeBitmap(Bitmap sourceBitmap, int targetWidth, int targetHeight)
{
Bitmap targetBitmap = new Bitmap(targetWidth, targetHeight);
using(Graphics graphics = Graphics.FromImage(targetBitmap))
{
graphics.DrawImage(sourceBitmap, 0, 0, targetWidth, targetHeight);
}
return targetBitmap;
}
#endregion
728x90
그리드형(광고전용)
'C# > WinForm' 카테고리의 다른 글
[C#/WINFORM] Image 클래스 : BASE64 문자열에서 이미지 구하기 (0) | 2021.08.20 |
---|---|
[C#/WINFORM] Button 클래스 : FlatStyle/FlatAppearance 속성을 사용해 버튼 테두리 제거하기 (0) | 2021.08.19 |
[C#/WINFORM] Panel 클래스 : 패널에서 폼 드래그하기 (0) | 2021.08.19 |
[C#/WINFORM] Form 클래스 : 클라이언트 영역에서 폼 드래그하기 (0) | 2021.08.19 |
[C#/WINFORM] Form 클래스 : 클라이언트 영역에서 폼 드래그하기 (0) | 2021.08.19 |
[C#/WINFORM] Image 클래스 : Save 메소드를 사용해 JPEG 파일 저장하기 (0) | 2021.08.19 |
[C#/WINFORM] ImageCodecInfo 클래스 : GetImageEncoders 정적 메소드를 사용해 이미지 코덱 정보 구하기 (0) | 2021.08.19 |
[C#/WINFORM/.NET5] 누겟 설치 : System.Drawing.Common (0) | 2021.08.15 |
[C#/WINFORM/.NET5] C# 프로젝트 파일에서 비주얼 소스 세이프 태그 제거하기 (0) | 2021.08.01 |
[C#/WINFORM] Windows Media Player COM 객체를 사용해 MP3 파일 재생하기 (0) | 2021.07.31 |