Skip to main content
gamedev.net
🔒 Locked

Blt problem

Started by remi Aug 11, 2002 at 9:42 AM 13 replies 700+ views
Original Post
remi
remi
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?
"...and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces."----------Scott Meyers, "Effective C++"
Pipo DeClown
Pipo DeClown
you mean you wanna stretch the source?
take a look at stretchblt()

.lick
remi
remi
i don''t think the StretchBlt() function is a DirectX''s function, i may be wrong!

The Dx''s Blt() has the capability to perform Stretch blits, but i have a line that appears in the right most part of my sprite: that''s the problem.

Anyhelp?
"...and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces."----------Scott Meyers, "Effective C++"
remi
remi
Anyhelp?
"...and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces."----------Scott Meyers, "Effective C++"
burgc002
burgc002
When you make your sprites do you have like a border around them?
Like in Game Prog for Dummies or TWGPG? If not ignore this, if you do then you may be accidently picking up your border when you extract the sprite from the bmp. Maybe
EbonySeraph
EbonySeraph
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.
"Ogun's Laughter Is No Joke!!!" - Ogun Kills On The Right, A Nigerian Poem.
remi
remi
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!
"...and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces."----------Scott Meyers, "Effective C++"
owl
owl
Look at how are you loading the bitmaps, maybe the source surface is getting corrupt in some way, or when you set the rects for the sprite. the problem has to be between those.

[edited by - xaxa on August 12, 2002 2:35:40 AM]
[size="2"]I like the Walrus best.
remi
remi
I didn't want to do this but i'm force to.
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]
"...and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces."----------Scott Meyers, "Effective C++"
owl
owl
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
[size="2"]I like the Walrus best.
remi
remi
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.
"...and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces."----------Scott Meyers, "Effective C++"
Pipo DeClown
Pipo DeClown
have you tried SetRect(.....width-1...) ?
remi
remi
I tried it yesterday but ... NADA
"...and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces."----------Scott Meyers, "Effective C++"
owl
owl
Whatta bich of bug, try debugin watching what you do with the rects and the surface before blitting. If you give up, try using functions that comes with ddraw samples, and adapt them to your needs, they work.
ELSE
Google: +"blitting" +"adds a line" +why
[size="2"]I like the Walrus best.
remi
remi
Great idea!
i''ll try to check inside the ddraw sample codes, and see the differences between their codes and mine.

If i find something i''ll let u know, promise
"...and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces."----------Scott Meyers, "Effective C++"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.