本文整理汇总了C++中LPDIRECTDRAWSURFACE7::Blt方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAWSURFACE7::Blt方法的具体用法?C++ LPDIRECTDRAWSURFACE7::Blt怎么用?C++ LPDIRECTDRAWSURFACE7::Blt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTDRAWSURFACE7
的用法示例。
在下文中一共展示了LPDIRECTDRAWSURFACE7::Blt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DDraw_Draw_Surface_Scaled
int DDraw_Draw_Surface_Scaled(LPDIRECTDRAWSURFACE7 source, // source surface to draw
int x, int y, // position to draw at
int width_src, int height_src,// size of source surface
int width_dest, int height_dest,// size of dest surface
LPDIRECTDRAWSURFACE7 dest, // surface to draw the surface on
int transparent = 1) // transparency flag
{
// draw the surface at the x,y defined by dest, send both the original
// source size of surface, along with the desired size, if they are
// different then directdraw will scale the bitmap for you
// note that we are sending
// the size of the surface, we could query for it, but that takes time
// basically, we are really lacking datastructure as this point, since
// you would create a datastructure that keep important info about the
// surface, so you did't have to query it from directdraw
RECT dest_rect, // the destination rectangle
source_rect; // the source rectangle
// fill in the destination rect
dest_rect.left = x;
dest_rect.top = y;
dest_rect.right = x+width_dest-1;
dest_rect.bottom = y+height_dest-1;
// fill in the source rect
source_rect.left = 0;
source_rect.top = 0;
source_rect.right = width_src-1;
source_rect.bottom = height_src-1;
// test transparency flag
if (transparent)
{
// enable color key blit
// blt to destination surface
if (FAILED(dest->Blt(&dest_rect, source,
&source_rect,(DDBLT_WAIT | DDBLT_KEYSRC),
NULL)))
return(0);
} // end if
else
{
// perform blit without color key
// blt to destination surface
if (FAILED(dest->Blt(&dest_rect, source,
&source_rect,(DDBLT_WAIT),
NULL)))
return(0);
} // end if
// return success
return(1);
} // end DDraw_Draw_Surface_Scaled
示例2: DDraw_Draw_Surface
int DDraw_Draw_Surface(LPDIRECTDRAWSURFACE7 source, // source surface to draw
int x, int y, // position to draw at
int width, int height, // size of source surface
LPDIRECTDRAWSURFACE7 dest, // surface to draw the surface on
int transparent = 1) // transparency flag
{
// draw a bob at the x,y defined in the BOB
// on the destination surface defined in dest
RECT dest_rect, // the destination rectangle
source_rect; // the source rectangle
// fill in the destination rect
// 目标表面、也就是需要填充的表面
dest_rect.left = x;
dest_rect.top = y;
dest_rect.right = x+width-1;
dest_rect.bottom = y+height-1;
// fill in the source rect
// 源表面、也就是需要拷贝数据的表面、这里将拷贝的表面
// 由传递过来的高宽决定
source_rect.left = 0;
source_rect.top = 0;
source_rect.right = width-1;
source_rect.bottom = height-1;
// test transparency flag
// 设置是否为透明、要就必须设置色彩键
if (transparent)
{
// enable color key blit
// blt to destination surface
if (FAILED(dest->Blt(&dest_rect, source,
&source_rect,(DDBLT_WAIT | DDBLT_KEYSRC),
NULL)))
return(0);
} // end if
else
{
// perform blit without color key
// blt to destination surface
if (FAILED(dest->Blt(&dest_rect, source,
&source_rect,(DDBLT_WAIT),
NULL)))
return(0);
} // end if
// return success
return(1);
} // end DDraw_Draw_Surface
示例3: DDDrawBorder
void DDDrawBorder()
{
DDBLTFX ddbltfx;
if (FScreen.Stretch) return;
ddbltfx.dwSize=sizeof(ddbltfx);
ddbltfx.dwFillColor = LetterBoxColour; //RGB(250, 25, 5);
m_pddsFrontBuffer->Blt(&BorderTop, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
m_pddsFrontBuffer->Blt(&BorderBottom, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
m_pddsFrontBuffer->Blt(&BorderRight, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
m_pddsFrontBuffer->Blt(&BorderLeft, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
}
示例4: Blt
void CPage::Blt(LPDIRECTDRAWSURFACE7 lpSurf)
{
if (childwindow)
{
childwindow->Blt(lpSurf);
return;
}
PreBlt();
RECT d={0,0,sx,sy};
RECT s={0,0,w,h};
lpSurf->Blt(&d,surf,&s,DDBLT_WAIT,NULL);
{ // Cursor malen
POINT mp;
GetCursorPos(&mp);
if (WindowFromPoint(mp)==hWnd)
{
::ScreenToClient(hWnd,&mp);
lpCursor->SetPos(mp.x,mp.y);
lpCursor->Draw(lpSurf,sx,sy);
}
}
}
示例5: dx_Affiche
//-----------------------------------------------------------------------------
// Name: dx_Affiche()
// Desc: Affiche le contenu du buffer à l'écran
//-----------------------------------------------------------------------------
bool dx_Affiche ()
{
if (PleinEcran)
{
ErrDd = SurfacePrimaire->Flip (0, DDFLIP_WAIT);
}
else
{
RECT tRectSrc;
RECT tRectDest;
POINT tPosition = {0,0};
// Copie de Surface suivant la position de la fenêtre
ClientToScreen (Fenetre, &tPosition);
GetClientRect (Fenetre, &tRectDest);
if (TailleFenetre)
SetRect (&tRectSrc, 0, 0, tRectDest.right-tRectDest.left,
tRectDest.bottom-tRectDest.top);
else SetRect (&tRectSrc, 0, 0, ResolutionX, ResolutionY);
OffsetRect (&tRectDest, tPosition.x, tPosition.y);
ErrDd = SurfacePrimaire->Blt
(&tRectDest,SurfaceBack,&tRectSrc,DDBLT_WAIT,NULL);
}
return dx_Test ();
};
示例6: Blt
HRESULT STDMETHODCALLTYPE Blt(LPDIRECTDRAWSURFACE7 surface, LPRECT lpDestRect, LPDIRECTDRAWSURFACE7 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx)
{
//logOutput << CurrentTimeString() << "Hooked Blt()" << endl;
EnterCriticalSection(&ddrawMutex);
ddrawSurfaceBlt.Unhook();
HRESULT hr = surface->Blt(lpDestRect, lpDDSrcSurface, lpSrcRect, dwFlags, lpDDBltFx);
ddrawSurfaceBlt.Rehook();
if (SUCCEEDED(hr))
{
if (!g_bUseFlipMethod)
{
if (getFrontSurface(surface))
{
CaptureDDraw();
}
}
}
LeaveCriticalSection(&ddrawMutex);
return hr;
}
示例7: Draw_Rectangle
int Draw_Rectangle(int x1, int y1, int x2, int y2, int color,
LPDIRECTDRAWSURFACE7 lpdds)
{
// this function uses directdraw to draw a filled rectangle
DDBLTFX ddbltfx; // this contains the DDBLTFX structure
RECT fill_area; // this contains the destination rectangle
// clear out the structure and set the size field
DD_INIT_STRUCT(ddbltfx);
// set the dwfillcolor field to the desired color
ddbltfx.dwFillColor = color;
// fill in the destination rectangle data (your data)
fill_area.top = y1;
fill_area.left = x1;
fill_area.bottom = y2+1;
fill_area.right = x2+1;
// ready to blt to surface, in this case blt to primary
lpdds->Blt(&fill_area, // ptr to dest rectangle
NULL, // ptr to source surface, NA
NULL, // ptr to source rectangle, NA
DDBLT_COLORFILL | DDBLT_WAIT | DDBLT_ASYNC, // fill and wait
&ddbltfx); // ptr to DDBLTFX structure
// return success
return(1);
} // end Draw_Rectangle
示例8: dx_Efface
//-----------------------------------------------------------------------------
// Name: dx_Efface()
// Desc: Efface le buffer d'affichage
//-----------------------------------------------------------------------------
bool dx_Efface (uint8 Rouge, uint8 Vert, uint8 Bleu)
{
ZeroMemory (&BlitFX, sizeof(BlitFX));
BlitFX.dwSize = sizeof (BlitFX);
BlitFX.dwFillColor = RGB (Rouge,Vert,Bleu);
SurfaceBack->Blt (NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &BlitFX);
return dx_Test ();
}
示例9: CopySurface
//-----------------------------------------------------------------------------
// Name: CopySurface()
// Desc: this function copies one surface to another
//-----------------------------------------------------------------------------
int CopySurface(LPDIRECTDRAWSURFACE7 lpddsDestSurface, RECT *destRect,LPDIRECTDRAWSURFACE7 lpddsSorSurface, RECT *sorRect)
{// this function flips a surface onto the primary surface
//Blt the frame
ddReturnVal = lpddsDestSurface->Blt(destRect/*dest rect*/,lpddsSorSurface, //pointer to source surface
sorRect, //pointer to the source rectangle
DDBLT_WAIT | DDBLT_KEYSRC, NULL/*ddbltfx struct*/);//NULL means entire surface
if (DDFailedCheck(ddReturnVal, "CopySurface(), Blt failed", cpErrorBuf ))
{ MessageBox(NULL, cpErrorBuf, "DrawSprite()", MB_ICONEXCLAMATION); return(0); }
return 1;
}
示例10: dx_SurfaceCopie
//-----------------------------------------------------------------------------
// Name: dx_SurfaceCopie(...)
// Desc: Copie le contenu d'une surface dans le buffer d'affichage
//-----------------------------------------------------------------------------
bool dx_SurfaceCopie (uint8 pNoSurface, uint16 pPosX, uint16 pPosY)
{
DDSURFACEDESC2 ddsd;
ZeroMemory ((void*)&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_HEIGHT | DDSD_WIDTH;
Surfaces[pNoSurface]->GetSurfaceDesc (&ddsd);
RECT rDest = {pPosX, pPosY, pPosX+ddsd.dwWidth-1, pPosY+ddsd.dwHeight-1};
return (ErrDd = SurfaceBack->Blt (&rDest, Surfaces[pNoSurface], NULL,
DDBLT_WAIT, NULL)) == DD_OK;
}
示例11: Draw
void CCursor::Draw(LPDIRECTDRAWSURFACE7 lpSurf,const int w,const int h)const
{
//#define STRETCHCURSOR
if (lpSurface[curframe]==NULL)return;
if ((CursorPos.x<0)||(CursorPos.y<0)||(CursorPos.x>w)||(CursorPos.y>w))return;
const int hotspotx=10;
const int hotspoty=5;
#ifdef STRETCHCURSOR
const int cw=(width*w)/800;
const int ch=(height*h)/600;
RECT s={0,0,width,height};
RECT d={x,y,x+cw,y+ch};
if (d.right>w)
{
s.right-=((d.right-w)*800)/w;
d.right=w;
}
if (d.bottom>h)
{
s.bottom-=((d.bottom-h)*600)/h;
d.bottom=h;
}
lpSurf->Blt(&d,lpSurface[curframe],&s,DDBLT_WAIT|DDBLT_KEYSRC,NULL);
#else
RECT src={0,0,width,height};
int mx=CursorPos.x-hotspotx;
int my=CursorPos.y-hotspoty;
if (mx<0)
{
src.left-=mx;
mx=0;
}
if (my<0)
{
src.top-=my;
my=0;
}
if (mx+src.right>w)
src.right=w-mx;
if (my+src.bottom>h)
src.bottom=h-my;
lpSurf->BltFast(mx,my,lpSurface[curframe],&src,DDBLTFAST_SRCCOLORKEY);
#endif
}
示例12: DrawSprite
//-----------------------------------------------------------------------------
// Name: DrawSprite()
// Desc: Draws a list of sprites to a surface using internal (x,y)
//-----------------------------------------------------------------------------
int CSPRITE::DrawSprite(LPDIRECTDRAWSURFACE7 lpddsSurface)
{
static RECT destRect;
//static int j=0;
//static DWORD start=GetTickCount();
//static CTIMER timer;
if( (m_iState != SPRITE_STATE_DEAD) && ( m_iAttr == SPRITE_ATTR_LOADED) )
{
//Fill in dest rect
destRect.top = m_iY;
destRect.left = m_iX;
destRect.bottom = m_iY + m_iHeight;
destRect.right = m_iX + m_iWidth;
//Setup the time between frames drawn
if( m_Timer.Elapsed(m_iTimeBetweenFrames) && (m_ipAnimAttr[m_iCurrentAnimSequence] != SPRITE_ANIM_DONE) )
{
m_Counter++; m_Timer.StartTimer();//m_StartTime=GetTickCount();
//Check to see if reached last frame in sequence
if( m_Counter > m_ipAnimSeqMax[m_iCurrentAnimSequence])
if(m_ipAnimAttr[m_iCurrentAnimSequence] == SPRITE_ANIM_CONT) //check to see if sprite is supposed to be cont animated
m_Counter=0;
else //animate it once
if( m_ipAnimAttr[m_iCurrentAnimSequence] == SPRITE_ANIM_ONCE )
{
m_Counter = m_ipAnimSeqMax[m_iCurrentAnimSequence];
m_ipAnimAttr[m_iCurrentAnimSequence] = SPRITE_ANIM_DONE;
}
}
//Get the next frame from the anim sequence
m_iCurrentFrame = m_ipAnimations[m_iCurrentAnimSequence][m_Counter];
//Blt the frame
ddReturnVal = lpddsSurface->Blt(&destRect/*dest rect*/,m_lpddsImage[m_iCurrentFrame], //pointer to source surface
&m_Rect, //pointer to the source rectangle
DDBLT_WAIT | DDBLT_KEYSRC, NULL/*ddbltfx struct*/);
if(ddReturnVal != DD_OK)
if(ddReturnVal==DDERR_SURFACELOST)
{ this->RestoreSurface(); lpddsPrimary->Restore();OutputDebugString("Surfacelost DrawSprite()\n"); return(1); }
else
if (DDFailedCheck(ddReturnVal, "DrawSprite(), Blt failed", cpErrorBuf ))
{ MessageBox(main_window_handle, cpErrorBuf, "DrawSprite()", MB_ICONEXCLAMATION); return(0); }
}//End if( (m_iState != SPRITE_STATE_DEAD) && ( m_iAttr == SPRITE_ATTR_LOADED) )
return(1);
}
示例13: Flip
//-----------------------------------------------------------------------------
// Name: Flip()
// Desc: this function flips a surface onto the primary surface
//-----------------------------------------------------------------------------
int Flip(LPDIRECTDRAWSURFACE7 lpddsSurface, RECT destrect)
{// this function flips a surface onto the primary surface
//Blt the frame
ddReturnVal = lpddsPrimary->Blt(&destrect/*dest rect*/,lpddsSurface, //pointer to source surface
NULL, //pointer to the source rectangle
DDBLT_WAIT | DDBLT_KEYSRC, NULL/*ddbltfx struct*/);//NULL means entire surface
if(ddReturnVal!=DD_OK)
if(ddReturnVal==DDERR_SURFACELOST)
{ OutputDebugString("Surfacelost Flip(RECT)\n"); lpddsSurface->Restore(); lpddsPrimary->Restore(); return(1); }
else
if (DDFailedCheck(ddReturnVal, "Flip(lpddsSurface, RECT), Blt failed", cpErrorBuf ))
{ MessageBox(NULL, cpErrorBuf, "SurfaceFuncs", MB_ICONEXCLAMATION); return(0); }
return 1;
}
示例14: Test_PrivateData
BOOL Test_PrivateData (INT* passed, INT* failed)
{
LPDIRECTDRAWSURFACE7 Surface;
DWORD size, dummy = 0xBAADF00D;
GUID guid = { 0 };
GUID guid2 = { 0x1 };
if(!CreateSurface(&Surface))
return FALSE;
// General test
TEST(Surface->SetPrivateData(guid, NULL, 0, 0) == DDERR_INVALIDPARAMS);
TEST(Surface->SetPrivateData(guid, (LPVOID)&dummy, 0, 0) == DDERR_INVALIDPARAMS);
TEST(Surface->SetPrivateData(guid, (LPVOID)0xdeadbeef, sizeof(DWORD), 0) == DDERR_INVALIDPARAMS);
TEST(Surface->SetPrivateData(guid, (LPVOID)&dummy, sizeof(DWORD), 0) == DD_OK);
TEST(Surface->GetPrivateData(guid, NULL, 0) == DDERR_INVALIDPARAMS);
TEST(Surface->GetPrivateData(guid, &dummy, 0) == DDERR_INVALIDPARAMS);
size = 0;
TEST(Surface->GetPrivateData(guid, &dummy, &size) == DDERR_MOREDATA && size == sizeof(DWORD));
size = 2;
TEST(Surface->GetPrivateData(guid, NULL, &size) == DDERR_MOREDATA && size == sizeof(DWORD));
TEST(Surface->GetPrivateData(guid, NULL, &size) == DDERR_INVALIDPARAMS);
TEST(Surface->GetPrivateData(guid, &dummy, &size) == DD_OK && dummy == 0xBAADF00D);
TEST(Surface->GetPrivateData(guid2, NULL, 0) == DDERR_NOTFOUND);
TEST(Surface->FreePrivateData(guid) == DD_OK);
TEST(Surface->FreePrivateData(guid) == DDERR_NOTFOUND);
// Test for DDSPD_VOLATILE flag
TEST(Surface->SetPrivateData(guid, (LPVOID)&dummy, sizeof(DWORD), DDSPD_VOLATILE) == DD_OK);
size = 0;
TEST(Surface->GetPrivateData(guid, NULL, &size) == DDERR_MOREDATA && size == sizeof(DWORD));
TEST(Surface->GetPrivateData(guid, &dummy, &size) == DD_OK && dummy == 0xBAADF00D);
DDBLTFX bltfx;
bltfx.dwSize = sizeof(DDBLTFX);
bltfx.dwFillColor = RGB(0, 0, 0);
if(Surface->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &bltfx) != DD_OK)
printf("ERROR: Failed to draw to surface !");
TEST(Surface->GetPrivateData(guid, &dummy, &size) == DDERR_EXPIRED);
// TODO: Test for DDSPD_IUNKNOWNPOINTER (see http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/ddraw7/directdraw7/ddref_5qyf.asp)
Surface->Release();
return TRUE;
}
示例15: GameDisplayLoop
HRESULT GameDisplayLoop(HWND hWnd, PFPImage pImage, LONG destX, LONG destY)
{
HRESULT hResult;
DDBLTFX ddBltFx;
memset(&ddBltFx, 0, sizeof(ddBltFx));
ddBltFx.dwSize = sizeof(ddBltFx);
ddBltFx.dwROP = SRCCOPY;
RECT rcMain = { 0 };
GetClientRect(hWnd, &rcMain);
ClientToScreen(hWnd, ((LPPOINT)&rcMain) + 0);
ClientToScreen(hWnd, ((LPPOINT)&rcMain) + 1);
//FP_DEBUG_MSG(_T("CLINET RECT: (%d, %d) - (%d, %d)\n"), rcMain.top, rcMain.bottom, rcMain.left, rcMain.right);
RECT rcBack = { 0 };
DDSURFACEDESC2 ddsd;
DDRAW_INIT_STRUCT(ddsd);
if (FAILED(hResult = lpddsBack->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL)))
{
FP_DEBUG_MSG(_T("Lock Error: 0x%08x\n"), hResult);
return E_FAIL;
}
LPPALETTEENTRY lpPalet = NULL;
if (FAILED(gameGraphics->ChangePalette(FP_PALETTE_DAY, &lpPalet)))
{
return E_FAIL;
}
LPBYTE lpPixel = (LPBYTE)ddsd.lpSurface;
LPBYTE lpData = (LPBYTE)pImage->data;
LONG n = 0;
for (LONG i = 0; i < pImage->height; i++)
{
n = (i + destY) * ddsd.lPitch + destX * sizeof(PALETTEENTRY);
for (LONG j = 0; j < pImage->width; j++, n += 4)
{
LPBYTE lpPtr = &lpPixel[n];
*(lpPtr + 0) = lpPalet[lpData[(pImage->height - i - 1) * pImage->width + j]].peRed;
*(lpPtr + 1) = lpPalet[lpData[(pImage->height - i - 1) * pImage->width + j]].peGreen;
*(lpPtr + 2) = lpPalet[lpData[(pImage->height - i - 1) * pImage->width + j]].peBlue;
*(lpPtr + 3) = 0;
}
}
lpddsBack->Unlock(NULL);
lpddsMain->Blt(&rcMain, lpddsBack, NULL, DDBLT_WAIT, &ddBltFx);
return S_OK;
}