다이얼로그에서 화면 부분캡쳐 후 뿌려주는 코드..결과가 안나오네요~해결방안좀 알려주세요~^^
겨울c
void CVSSecurityDlg::OnRButtonDown(UINT nFlags, CPoint point)
{
CaptureEnd();
CDC *pDC = GetDC();
ASSERT_VALID(pDC);
CDC cdc;
cdc.CreateCompatibleDC(pDC);
cdc.SelectObject(&m_pBitmap);
StretchDIBits( pDC-m_hDC, (320+23)*3, 4, m_rect.Width(), m_rect.Height(), 0, 0,
m_rect.Width(), m_rect.Height(),BMRawData, pih, DIB_RGB_COLORS, SRCCOPY);
//pDC-BitBlt((320+23)*2,2,m_rect.BottomRight().x-m_rect.TopLeft().x,m_rect.BottomRight().y-m_rect.TopLeft().y,&cdc,0,0,SRCCOPY);
CDialog::OnRButtonDown(nFlags, point);
}
void CVSSecurityDlg::CaptureEnd()
{
OnCapture();
KillTimer(1);
POINT point;
CDC ScreenDC;
CPen pen, *oldpen;
CDC memDC;
GetCursorPos(&point);
m_rect=CRect(start.x,start.y,point.x,point.y);
ScreenDC.CreateDC(DISPLAY, NULL,NULL,NULL);
pen.CreatePen(PS_SOLID,2,RGB(0xff,0xff,0xff));
ScreenDC.SelectStockObject(NULL_BRUSH);
oldpen=ScreenDC.SelectObject(&pen);
ScreenDC.SetROP2(R2_XORPEN);
ScreenDC.Rectangle(m_oldrect);
ScreenDC.SelectObject(oldpen);
m_oldrect=m_rect;
memDC.CreateCompatibleDC(&ScreenDC);
m_pBitmap.CreateCompatibleBitmap(&ScreenDC,m_rect.Width(),m_rect.Height());
memDC.SelectObject(&m_pBitmap);
memDC.BitBlt((320+23)*2,2,m_rect.Width(),m_rect.Height(),
&ScreenDC,m_rect.TopLeft().x,m_rect.TopLeft().y,SRCCOPY);
m_nCapture=1;
////////////////////////////////////////////////////////////////////////////////////
int width = m_rect.Width();
int height = m_rect.Height();
membit = (HBITMAP)m_pBitmap.m_hObject;
GetObject(membit,sizeof(BITMAP),&bit);
ih.biSize=sizeof(BITMAPINFOHEADER);
ih.biWidth=bit.bmWidth;
ih.biHeight=bit.bmHeight;
ih.biPlanes=1;
ih.biBitCount=bit.bmPlanes*bit.bmBitsPixel;
if (ih.biBitCount 8) ih.biBitCount=24;
ih.biCompression=BI_RGB;
ih.biSizeImage=0;
ih.biXPelsPerMeter=0;
ih.biYPelsPerMeter=0;
ih.biClrUsed=0;
ih.biClrImportant=0;
PalSize=(ih.biBitCount==24 ? 0:1 ih.biBitCount)*sizeof(RGBQUAD);
pih=(BITMAPINFO *)malloc(ih.biSize+PalSize);
pih-bmiHeader=ih;
GetDIBits(memDC,membit,0,bit.bmHeight,NULL,pih,DIB_RGB_COLORS);
ih=pih-bmiHeader;
if (ih.biSizeImage == 0)
{
ih.biSizeImage=((((ih.biWidth*ih.biBitCount)+31) & ~31) 3) * ih.biHeight;
}
Size=ih.biSize+PalSize+ih.biSizeImage;
pih=(BITMAPINFO *)realloc(pih,Size);
LPBYTE offset = (PBYTE)pih+ih.biSize+PalSize;
GetDIBits(memDC,membit,0,bit.bmHeight,(PBYTE)pih+ih.biSize+PalSize,pih,DIB_RGB_COLORS);
BMRawData = new BYTE[width*height*3];
memcpy(BMRawData,(PBYTE)pih+ih.biSize+PalSize,width*height*3);
}
다이얼 로그 화면에 사각영역을 마우스 클릭 후 그린 후 그 부분을 출력하는 소스 입니다.
하지만 사각형 영역을 그린 후 마우스 오른쪽 버튼을 누르면 설정한 좌표값에 뿌려주는 코드인데...
오른쪽 버튼 클릭하는 함수에서 BitBlt를 사용하여 뿌리면 사각영역에 대한 캡쳐화면이 검게 나옵니다.
그리고 StretchDIBits를 사용하여 뿌리면 아예 나오질 않네요~혹시 해결방안을 아시는 분 알려주세요~^^
복받으실꺼에요~ㅎㅎ이 문제로 2틀간 요것만 잡고 있네요~흑흑