D
DonDilworth
Guest
Here's my code:
BitmapClip.Attach(HBitmapClip);
BitmapClip.GetObject( sizeof (BITMAP), &BitmapClipInfo );
MemDC.CreateCompatibleDC( m_paintDC );
MemDC.SelectObject( &BitmapClip);
xx = BitmapClipInfo.bmWidth;
yy = BitmapClipInfo.bmHeight;
if ( xx > m_HSize ) xx = m_HSize;
if ( yy > m_VSize ) yy = m_VSize;
HDC hd;
hd = (HDC) dc;
BitBlt
( hd,
ix,
iy,
xx,
yy,
MemDC,
0,
0,
SRCCOPY );
::CloseClipboard();
m_textflag = 2;
CString text;
showprogressbar();
for ( y = 0; y < 400; y++ ) { // scan photo here
progress = y/4;
updateprogressbar( progress );
if ( checkstopsign() ) {
InvalidateRect( &m_DWGarea );
killprogressbar();
wndout("Scan aborted \r\n");
return;
}
for ( x = 0; x < 400; x++ ) {
xx = x * m_nFfactX * xfudge + m_nXoffSet;
yy = y * m_nFfactY * yfudge + m_nYoffSet;
clr = dc.GetPixel( xx, yy );
if ( clr == CLR_INVALID ) clr = RGB(0,0,0);
m_mapRGB[x][y] = clr; // use all three colors in map only for photo
}
}
killprogressbar();
I put a graphics picture on the clipboard, and this code copies it to a dialog window. Then it samples that window, loading the array m_mapRGB[][] with each of 400 x 400 pixels. Later, I process this picture.
In debug mode, this works perfectly. In release mode, the loop on y gets about 1/3 of the way through, and then the dialog vanishes. I can display the dialog again with a keystroke, but the sampled array is blank below the 1/3 point. If I start the sampling loop again, it works as it should, and the whole picture is sampled. What is going on?
Continue reading...
BitmapClip.Attach(HBitmapClip);
BitmapClip.GetObject( sizeof (BITMAP), &BitmapClipInfo );
MemDC.CreateCompatibleDC( m_paintDC );
MemDC.SelectObject( &BitmapClip);
xx = BitmapClipInfo.bmWidth;
yy = BitmapClipInfo.bmHeight;
if ( xx > m_HSize ) xx = m_HSize;
if ( yy > m_VSize ) yy = m_VSize;
HDC hd;
hd = (HDC) dc;
BitBlt
( hd,
ix,
iy,
xx,
yy,
MemDC,
0,
0,
SRCCOPY );
::CloseClipboard();
m_textflag = 2;
CString text;
showprogressbar();
for ( y = 0; y < 400; y++ ) { // scan photo here
progress = y/4;
updateprogressbar( progress );
if ( checkstopsign() ) {
InvalidateRect( &m_DWGarea );
killprogressbar();
wndout("Scan aborted \r\n");
return;
}
for ( x = 0; x < 400; x++ ) {
xx = x * m_nFfactX * xfudge + m_nXoffSet;
yy = y * m_nFfactY * yfudge + m_nYoffSet;
clr = dc.GetPixel( xx, yy );
if ( clr == CLR_INVALID ) clr = RGB(0,0,0);
m_mapRGB[x][y] = clr; // use all three colors in map only for photo
}
}
killprogressbar();
I put a graphics picture on the clipboard, and this code copies it to a dialog window. Then it samples that window, loading the array m_mapRGB[][] with each of 400 x 400 pixels. Later, I process this picture.
In debug mode, this works perfectly. In release mode, the loop on y gets about 1/3 of the way through, and then the dialog vanishes. I can display the dialog again with a keystroke, but the sampled array is blank below the 1/3 point. If I start the sampling loop again, it works as it should, and the whole picture is sampled. What is going on?
Continue reading...