반응형
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 |