Hello how can i strech an img from 320x200 to 640x480 ?

I made a little game that need 320x200 res. Well i can init this
res on win200 without problems but i have problems init it on win98.

Can u help me ?
Posted on 2002-01-11 01:38:29 by eXterminator
I wrote this for directx 4.0 -- Not the best or fastest way to do this... but I hope it helps (wouldn't mind seeing your example either)...

Sliver




;szTesting is the filename of the bitmap
;lpDD is pointer to directdraw object

invoke Utils_LoadBitmap, DDRAW.lpDD, ADDR szTesting

....


Utils_LoadBitmap PROC pDD:DWORD, szBitmap:DWORD

LOCAL hbm :HBITMAP
LOCAL bm :BITMAP

invoke LoadImage, NULL, szBitmap, IMAGE_BITMAP, 0, 0, \
LR_LOADFROMFILE or LR_CREATEDIBSECTION
mov hbm, eax

invoke GetObject, hbm, sizeof BITMAP, ADDR bm

DDINITSTRUCT offset DDRAW.ddsd, SIZEOF(DDSURFACEDESC2)
mov DDRAW.ddsd.dwSize, SIZEOF(DDSURFACEDESC2)
mov DDRAW.ddsd.dwFlags, DDSD_CAPS or DDSD_HEIGHT or DDSD_WIDTH;
mov DDRAW.ddsd.ddsCaps.dwCaps, DDSCAPS_OFFSCREENPLAIN

xor eax, eax
mov eax, bm.bmWidth
mov DDRAW.ddsd.dwWidth, eax
mov eax, bm.bmHeight
mov DDRAW.ddsd.dwHeight, eax

DD4INVOKE CreateSurface, pDD, ADDR DDRAW.ddsd, ADDR DDRAW.lpDDSResource, NULL

invoke Utils_CopyBitmap, ADDR DDRAW.lpDDSResource, hbm, 0, 0, 0, 0
invoke DeleteObject, hbm

ret

Utils_LoadBitmap endp

Utils_CopyBitmap PROC pDDS:DWORD, hbm:HBITMAP, x:DWORD, y:DWORD, bitmapWidth:DWORD, bitmapHeight:DWORD

LOCAL bm :BITMAP
LOCAL hdcImage :HDC

invoke CreateCompatibleDC, NULL
mov hdcImage, eax

invoke SelectObject, hdcImage, hbm

invoke GetObject, hbm, sizeof BITMAP, ADDR bm

.if bitmapWidth == 0
mov eax, bm.bmWidth
mov bitmapWidth, eax
.endif

.if bitmapHeight == 0
mov eax, bm.bmHeight
mov bitmapHeight, eax
.endif

mov DDRAW.ddsd.dwSize, SIZEOF(DDSURFACEDESC2)
mov DDRAW.ddsd.dwFlags, DDSD_HEIGHT or DDSD_WIDTH
DDS4INVOKE GetSurfaceDesc, DDRAW.lpDDSResource, ADDR DDRAW.ddsd

DDS4INVOKE GetDC, DDRAW.lpDDSResource, ADDR DDRAW.hDC
.if eax != DD_OK
jmp err
.endif

invoke StretchBlt, DDRAW.hDC, 0, 0, DDRAW.ddsd.dwWidth, DDRAW.ddsd.dwHeight, hdcImage, x, y, \
bitmapWidth, bitmapHeight, SRCCOPY

;invoke BitBlt, DDRAW.hDC, 0, 0, DDRAW.ddsd.dwWidth, DDRAW.ddsd.dwHeight, hdcImage, 0, 0, SRCCOPY

DDS4INVOKE ReleaseDC, DDRAW.lpDDSResource, DDRAW.hDC
.if eax != DD_OK
jmp err
.endif


invoke DeleteDC, hdcImage

done:
mov eax, TRUE
ret

err:
mov eax, FALSE
ret


Utils_CopyBitmap endp
Posted on 2002-01-11 01:48:14 by Sliver