달력

52024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
반응형
private Image ScaleImage(Image image, float scale)
{
	if (image == null) return null;

	int width = (int)(image.Width * scale);
	int height = (int)(image.Height * scale);

	Bitmap bm = new Bitmap(width, height);
	using (Graphics gr = Graphics.FromImage(bm))
	{
		gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
		Rectangle dest_rect = new Rectangle(0, 0, width, height);
		Rectangle source_rect = new Rectangle(0, 0, image.Width, image.Height);
		gr.DrawImage(image, dest_rect, source_rect, GraphicsUnit.Pixel);
	}

	return bm;
}

'프로그래밍 > C#' 카테고리의 다른 글

[ C#] 생성자에서 생성자 호출하기  (0) 2020.05.18
[C#]텍스트 배경 반반따로 그리기?  (0) 2019.07.17
[C#]듀얼 스크린 Capture  (0) 2019.06.11
[C#]OpenCvSharp 이미지 로드  (0) 2019.02.05
[C#] 둥근 버튼  (0) 2019.01.12
Posted by 유령회사
|