2015년 11월 6일 금요일

Graphics 내용을 Bitmap으로 리턴 합니다

ㆍ언어대상 : C#   ㆍ작성자 : 김민석  

[Graphics 내용을 Bitmap으로 리턴하는 함수 원형]

        /// <summary>
        /// Graphics to Bitmap
        /// </summary>
        /// <param name="g"></param>
        /// <param name="bounds"></param>
        /// <returns></returns>
        public Bitmap GraphicsToBitmap(Graphics g, Rectangle bounds, PixelFormat format = PixelFormat.Format32bppArgb)
        {
            Bitmap bmp = new Bitmap(bounds.Width, bounds.Height, format);           
            using (Graphics bmpGrf = Graphics.FromImage(bmp))
            {
                IntPtr hdc1 = g.GetHdc();
                IntPtr hdc2 = bmpGrf.GetHdc();
                API.BitBlt(hdc2, 0, 0, bmp.Width, bmp.Height, hdc1, 0, 0, ApiConstants.SRCCOPY);
                g.ReleaseHdc(hdc1);
                bmpGrf.ReleaseHdc(hdc2);
            }

            return bmp;
        }

[BitBlt API 함수 원형]

        [System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
        public static extern bool BitBlt(
            IntPtr hdcDest, // handle to destination DC
            int nXDest, // x-coord of destination upper-left corner
            int nYDest, // y-coord of destination upper-left corner
            int nWidth, // width of destination rectangle
            int nHeight, // height of destination rectangle
            IntPtr hdcSrc, // handle to source DC
            int nXSrc, // x-coordinate of source upper-left corner
            int nYSrc, // y-coordinate of source upper-left corner
            System.Int32 dwRop // raster operation code
        );



해당 내용은 (주)데브존의 웹봇이 자동으로 저희 홈페이지와 API로 동기화한 내용입니다. 자세한 내용은 홈페이지 http://www.devzone.co.kr 또는 모바일 폰에서 http://devzone.co.kr을 접속 하여 확인해 보시기 비랍니다.
-  대표 전화 : 02) 2061 - 0753   - Fax : 02) 2061 - 0759   - Skype : devzone24
-  주소 : 서울특별시 양천구 목1동 923-14. 현대드림타워 1024호
-  기술 문의: 02) 2061-1259 김민석 기술이사


댓글 없음:

댓글 쓰기