[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
);
- 대표 전화 : 02) 2061 - 0753 - Fax : 02) 2061 - 0759 - Skype : devzone24
- 주소 : 서울특별시 양천구 목1동 923-14. 현대드림타워 1024호
- 기술 문의: 02) 2061-1259 김민석 기술이사
댓글 없음:
댓글 쓰기