🔒 Locked
Blt problem
Advertisement
Original Post
Hi all,
i''m having a curious problem with the IDirectDrawSurface7::Blt() function.
When the Destination and Source rectangles have the same widths and heights everything goes fine, but when the Destination and the Source are differents a line appears in the most right part of the sprite, uhmm.....i try to find the reasons of this myself but...NADA.
Anyhelp?
If you have a source rect larger than the surface of the actual source that is probably the reason why you have that line on a sprite. When you blit you are just copying the memory from one area to another, with a larger source rectangle, you will start to grab and copy stuff that''s not a part of the surface...but I would also think that you would get an access violation error - like an illegal operation or something if that was the case.
If you want to strech, make the source rect normal, the destination should be what''s larger.
"Ogun''s Laughter Is No Joke!!!" - Ogun Kills On The Right, A Nigerian Poem.
If you want to strech, make the source rect normal, the destination should be what''s larger.
"Ogun''s Laughter Is No Joke!!!" - Ogun Kills On The Right, A Nigerian Poem.
Thanx all for answering 
But i''m not sure if my problem has been got clearly.
1.I have some sprites in a black picture with no borders!
2.The function IDirectDrawSurface7::Blt() can perfom stretch blitting when the Source and Destination rectangles have differents sizes.
But what is curious is that when those rectangles have the same size it''s works well, when they''re differents it stretch blits greatly but adding another line!
That''s the problem!
But i''m not sure if my problem has been got clearly.
1.I have some sprites in a black picture with no borders!
2.The function IDirectDrawSurface7::Blt() can perfom stretch blitting when the Source and Destination rectangles have differents sizes.
But what is curious is that when those rectangles have the same size it''s works well, when they''re differents it stretch blits greatly but adding another line!
That''s the problem!
I didn't want to do this but i'm force to.
Ok these are ny codes
Everything is here, i really need your help DX Guys!!
[edited by - remi on August 12, 2002 2:48:12 AM]
Ok these are ny codes
//---------------------------------------------------------------------------------------
//LPRECT GDEVICE::LoadBitmapToSurface(LPDIRECTDRAWSURFACE7 *lplpddsSurface,char* filename,WORD dwFlag)
//
//---------------------------------------------------------------------------------------
LPRECT GDEVICE::LoadBitmapToSurface(LPDIRECTDRAWSURFACE7 *lplpddsSurface,char* filename,WORD dwFlag)
{
if(*lplpddsSurface)
{
(*lplpddsSurface)->Release();
*lplpddsSurface=NULL;
}
HBITMAP hBitmap;
BITMAP bBitmap;
LPRECT lpRect=new(RECT);
DDSURFACEDESC2 desc;
HDC hDest,hSrc;
hBitmap=(HBITMAP)LoadImage(NULL,filename,IMAGE_BITMAP,0,0,LR_LOADFROMFILE | LR_DEFAULTSIZE);
GetObject(hBitmap,sizeof(bBitmap),(void *)&bBitmap);
ZeroMemory(&desc,sizeof(desc));
desc.dwSize=sizeof(desc);
desc.dwFlags=DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
lpRect->right=desc.dwWidth=bBitmap.bmWidth;
lpRect->bottom=desc.dwHeight=bBitmap.bmHeight;
lpRect->left=lpRect->top=0;
desc.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN | dwFlag;
if((lpDD->CreateSurface(&desc,lplpddsSurface,NULL))==DDERR_OUTOFVIDEOMEMORY)
{
OutputDebugString("Not enough Video memory");
MessageBox(NULL,"Not enough Video memory","Error",MB_OK);
desc.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
if((lpDD->CreateSurface(&desc,lplpddsSurface,NULL))==DDERR_OUTOFMEMORY )
{
OutputDebugString("Not enough system memory");
return NULL;
}
}
(*lplpddsSurface)->GetDC(&hDest);
hSrc=CreateCompatibleDC(hDest);
SelectObject(hSrc,hBitmap);
BitBlt(hDest,0,0,bBitmap.bmWidth,bBitmap.bmHeight,hSrc,0,0,SRCCOPY);
DeleteObject(hBitmap);
DeleteDC(hSrc);
(*lplpddsSurface)->ReleaseDC(hDest);
return lpRect;
}
And here the codes for drawing
//--------------------------------------------------------------------------------------
//int SPRITE::Draw(LPDIRECTDRAWSURFACE7 lpddsDest)
//
//--------------------------------------------------------------------------------------
int SPRITE::Draw(LPDIRECTDRAWSURFACE7 lpddsDest)
{
int i=spImage->Animation[iCurrAnim][iCurrFrame];
RECT Rect;
SetRect(&Rect,x,y,x+Width,y+Height);
DDBLTFX ddBltfx;
ZeroMemory(&ddBltfx,sizeof(ddBltfx));
ddBltfx.dwSize=sizeof(ddBltfx);
ddBltfx.ddckSrcColorkey=spImage->ddcTransparent;
HRESULT hr;
if(FAILED(hr=lpddsDest->Blt(&Rect,spImage->lplpddsImage[i],NULL,DDBLT_WAIT |
DDBLT_KEYSRCOVERRIDE,&ddBltfx)))
ErrorMessage(hr);
return 0;
}
Everything is here, i really need your help DX Guys!!
[edited by - remi on August 12, 2002 2:48:12 AM]
hi,
Try using:
StretchBlt( hDest, 0, 0,
bBitmap.bmWidth, bBitmap.bmHeight,
hSrc, {dwBMPOriginX}, {dwBMPOriginY},
{dwBMPWidth}, {dwBMPHeight}, SRCCOPY );
instead of:
BitBlt(hDest,0,0,
bBitmap.bmWidth,bBitmap.bmHeight,hSrc,0,0,SRCCOPY);
Just to see what happend. Microsuckft does it this way.
---
int SPRITE::Draw(LPDIRECTDRAWSURFACE7 lpddsDest){
...SetRect(&Rect,x,y,x+Width,y+Height);...
Are you setting the right values for Width and Height? Are you doing it inside a case or if statement?
I hope this can help you. Good luck there
Try using:
StretchBlt( hDest, 0, 0,
bBitmap.bmWidth, bBitmap.bmHeight,
hSrc, {dwBMPOriginX}, {dwBMPOriginY},
{dwBMPWidth}, {dwBMPHeight}, SRCCOPY );
instead of:
BitBlt(hDest,0,0,
bBitmap.bmWidth,bBitmap.bmHeight,hSrc,0,0,SRCCOPY);
Just to see what happend. Microsuckft does it this way.
---
int SPRITE::Draw(LPDIRECTDRAWSURFACE7 lpddsDest){
...SetRect(&Rect,x,y,x+Width,y+Height);...
Are you setting the right values for Width and Height? Are you doing it inside a case or if statement?
I hope this can help you. Good luck there
I try it "xaxa", but it still not working, and personally i don''t find the need to do that modification at that place.
The width and Height are not set in an if statement but by overloaded functions. I mean that if u send a width or height value it''s considered in the other case the default width and height are taken; in which case they are the width and height of the sprite(grapgic).
I''m going crazy.
The width and Height are not set in an if statement but by overloaded functions. I mean that if u send a width or height value it''s considered in the other case the default width and height are taken; in which case they are the width and height of the sprite(grapgic).
I''m going crazy.
have you tried SetRect(.....width-1...) ?
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement