Click here to Skip to main content
15,915,319 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Sending email via outlook express Pin
Stephane Rodriguez.6-Sep-02 6:54
Stephane Rodriguez.6-Sep-02 6:54 
GeneralRe: Sending email via outlook express Pin
Joaquín M López Muñoz6-Sep-02 6:59
Joaquín M López Muñoz6-Sep-02 6:59 
GeneralUpgrade Win 3.1 application Pin
Rico6216-Sep-02 6:39
Rico6216-Sep-02 6:39 
GeneralRe: Upgrade Win 3.1 application Pin
Joaquín M López Muñoz6-Sep-02 7:14
Joaquín M López Muñoz6-Sep-02 7:14 
GeneralRe: Upgrade Win 3.1 application Pin
Rico6216-Sep-02 7:54
Rico6216-Sep-02 7:54 
GeneralRe: Upgrade Win 3.1 application Pin
Garth J Lancaster11-Sep-02 18:23
professionalGarth J Lancaster11-Sep-02 18:23 
GeneralIDirectDrawSurface saving as a bitmap Pin
Todd Jeffreys6-Sep-02 6:34
Todd Jeffreys6-Sep-02 6:34 
GeneralRe: IDirectDrawSurface saving as a bitmap Pin
Stephane Rodriguez.6-Sep-02 6:50
Stephane Rodriguez.6-Sep-02 6:50 
First of all, looks like 75% of your code here is useless, you don't need to copy the source surface byte by byte. DirectDraw exposes a DC. Once you've got it, you simply do a StretchBlit to a destination DC.

<pre>

// m_pDDSOffscreen3 is a DirectDraw surface

HDC MemDC, SurfDC;
HBITMAP hBmp,hDib;
DDSURFACEDESC ddsd;
LPBYTE destbuffer=NULL;
BITMAP bmp;
PBITMAPINFO pbmi;
WORD cClrBits;
LPVOID lpBits=NULL;

if (m_pDDSOffscreen3==NULL) return;

// Get the size of the surface...
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_HEIGHT | DDSD_WIDTH;
m_pDDSOffscreen3->GetSurfaceDesc(&ddsd);

// Create the Memorybitmap now...
HRESULT hr = m_pDDSOffscreen3->GetDC(&SurfDC);
if (SUCCEEDED(hr))
{
// Create the Memorybitmap now...
MemDC = ::CreateCompatibleDC( NULL );
hBmp = ::CreateCompatibleBitmap( SurfDC, ddsd.dwWidth, ddsd.dwHeight );
::SelectObject( MemDC, hBmp );
::BitBlt( MemDC, 0, 0, ddsd.dwWidth, ddsd.dwHeight, SurfDC, 0, 0, SRCCOPY );

// Bitmapstruct init...
::GetObject( hBmp, sizeof(BITMAP), (LPSTR)&bmp ); cClrBits = (WORD) 24;
pbmi = (PBITMAPINFO) LocalAlloc(LPTR, sizeof(BITMAPINFOHEADER));

/* Initialize the fields in the BITMAPINFO structure. */
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pbmi->bmiHeader.biWidth = bmp.bmWidth;
pbmi->bmiHeader.biHeight = bmp.bmHeight;
pbmi->bmiHeader.biPlanes = bmp.bmPlanes;
pbmi->bmiHeader.biBitCount = 24;
if( cClrBits < 24 ) pbmi->bmiHeader.biClrUsed = 2^cClrBits;
pbmi->bmiHeader.biCompression = BI_RGB;
pbmi->bmiHeader.biSizeImage = (pbmi->bmiHeader.biWidth + 7) /8 *
pbmi->bmiHeader.biHeight * 24;
pbmi->bmiHeader.biClrImportant = 0;

hDib = ::CreateDIBSection(NULL,pbmi,DIB_RGB_COLORS,&lpBits,NULL,0);
if (hDib==NULL) TRACE("CreateDIBSection failed\n");

// Get the bits from the DC to save it to disk...
GetDIBits( SurfDC, hBmp, 0, (WORD) bmp.bmHeight, lpBits, pbmi, 0 );
if( lpBits == NULL ) TRACE( "No memory for screenshot!\n" );

if (bAddTail)
{
CString name=_T("");
if (GetDocument()->addShot(name,nStart,nEnd) &&
pThumb->AddItem(CBitmap::FromHandle(hDib), name))
{
GetDocument()->addShotInfo(nStart,nEnd,
pThumb->GetImageListIndex(),pThumb->GetItemIndex());
}
}
else
{
// remplace
replaceShot(CBitmap::FromHandle(hDib));
}

m_pDDSOffscreen3->ReleaseDC(SurfDC );
::SelectObject(MemDC,NULL);
::DeleteDC(MemDC);
::DeleteObject(hBmp);
::DeleteObject(hDib);

</pre>

<hr noshade>
<font size="-1" face="arial"><i>And I swallow a small raisin.</i></font>
<b style="background-image:'url(http://www.arstdesign.com/hands.jpg)';width:50px;height:45px"></b>
GeneralRe: IDirectDrawSurface saving as a bitmap Pin
Todd Jeffreys6-Sep-02 7:19
Todd Jeffreys6-Sep-02 7:19 
GeneralRe: IDirectDrawSurface saving as a bitmap Pin
Mike Nordell6-Sep-02 18:24
Mike Nordell6-Sep-02 18:24 
QuestionStrange resource stuff????? Pin
jimNLX6-Sep-02 5:54
jimNLX6-Sep-02 5:54 
AnswerRe: Strange resource stuff????? Pin
pnpfriend6-Sep-02 9:20
pnpfriend6-Sep-02 9:20 
GeneralRe: Strange resource stuff????? Pin
jimNLX6-Sep-02 9:23
jimNLX6-Sep-02 9:23 
GeneralRe: Strange resource stuff????? Pin
pnpfriend6-Sep-02 10:26
pnpfriend6-Sep-02 10:26 
GeneralRe: Strange resource stuff????? Pin
jimNLX6-Sep-02 10:49
jimNLX6-Sep-02 10:49 
GeneralRe: Strange resource stuff????? Pin
Jawache6-Sep-02 12:48
Jawache6-Sep-02 12:48 
GeneralOwner Drawn Menus Pin
Paul C6-Sep-02 5:42
Paul C6-Sep-02 5:42 
GeneralRe: Owner Drawn Menus Pin
Jawache6-Sep-02 12:51
Jawache6-Sep-02 12:51 
GeneralRe: Owner Drawn Menus Pin
Paul C6-Sep-02 23:47
Paul C6-Sep-02 23:47 
GeneralSet window to be topmost Pin
BlackSmith6-Sep-02 5:20
BlackSmith6-Sep-02 5:20 
GeneralRe: Set window to be topmost Pin
Joaquín M López Muñoz6-Sep-02 6:32
Joaquín M López Muñoz6-Sep-02 6:32 
GeneralVery strange behavior trying to exit. Please help! Pin
ns6-Sep-02 5:04
ns6-Sep-02 5:04 
GeneralRe: Very strange behavior trying to exit. Please help! Pin
[James Pullicino]6-Sep-02 5:10
[James Pullicino]6-Sep-02 5:10 
GeneralRe: Very strange behavior trying to exit. Please help! Pin
Joaquín M López Muñoz6-Sep-02 6:25
Joaquín M López Muñoz6-Sep-02 6:25 
GeneralRe: Very strange behavior trying to exit. Please help! Pin
ns6-Sep-02 7:31
ns6-Sep-02 7:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.