728x90
728x170
■ Image 클래스를 사용해 이미지를 복사하는 방법을 보여준다.
▶ 예제 코드 (C#)
using System.Drawing;
using System.Drawing.Imaging;
#region 이미지 복사하기 - CopyImage(sourceImage, imageAttributes)
/// <summary>
/// 이미지 복사하기
/// </summary>
/// <param name="sourceImage">소스 이미지</param>
/// <param name="imageAttributes">이미지 어트리뷰트</param>
/// <returns>이미지</returns>
public Image CopyImage(Image sourceImage, ImageAttributes imageAttributes)
{
Bitmap targetBitmap = new Bitmap(sourceImage.Width, sourceImage.Height);
using(Graphics graphics = Graphics.FromImage(targetBitmap))
{
Rectangle targetRectangle = new Rectangle(0, 0, sourceImage.Width, sourceImage.Height);
graphics.DrawImage
(
sourceImage,
targetRectangle,
0,
0,
sourceImage.Width,
sourceImage.Height,
GraphicsUnit.Pixel,
imageAttributes
);
}
return targetBitmap;
}
#endregion
728x90
그리드형(광고전용)
'C# > WinForm' 카테고리의 다른 글
[C#/WINFORM] Bitmap 클래스 : 크기 변경 비트맵 구하기 (0) | 2020.12.27 |
---|---|
[C#/WINFORM] Bitmap 클래스 : 비트맵 파일 로드하기 (0) | 2020.12.27 |
[C#/WINFORM] Application 클래스 : SetSuspendState 정적 메소드를 사용해 절전 모드 만들기 (0) | 2020.12.27 |
[C#/WINFORM] 지정 시간 경과 후 절전 모드에서 활성화하기 (0) | 2020.12.27 |
[C#/WINFORM] Graphics 클래스 : DrawImage 메소드 사용시 이미지 어트리뷰트 설정하기 (0) | 2020.12.27 |
[C#/WINFORM] Image 클래스 : 이미지 복사하기 (0) | 2020.12.26 |
[C#/WINFORM] Bitmap 클래스 : 비트맵 픽셀 밝게하기 (0) | 2020.12.26 |
[C#/WINFORM] 레이더 차트 그리기 (0) | 2020.12.26 |
[C#/WINFORM] Graphics 클래스 : DrawString 메소드를 사용해 회전 텍스트 그리기 (0) | 2020.12.26 |
[C#/WINFORM] PointF 구조체 : 포인트 밀접 여부 구하기 (0) | 2020.12.26 |