Original Post
I've made a class named CBmp which has a member-function that loads the bmp-image from the hard disk to an offscreen-surface. The function can load a part of a .bmp -image. This functions has 5 parameters. One to give the name of the file, Two to parameters to give coordinates of the left bottom of the picture and two paramters for the picture width and height. Everything in my fucntion succeeds until my functions tries to copy the actually image. Here you can see a part of the function:
prototype:
BOOL CBmp::Load(char * filename, int x, int y, int t_width, int t_height)
part that fails to copy the image to an offscreen surface:
if(ok){
// try to move pointer to the left bottom of the image
SetFilePointer(hFile, (y-1)*width_mul4+x, NULL, FILE_CURRENT);
dest=(BYTE *)ddsd.lpSurface;
ok=image->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL) == DD_OK;
for(int i=0; i < height && ok; i++){
ok=ok && ReadFile(hFile, dest, width, &nr_bytes_read, NULL)!=0;
// next row
dest+=ddsd.lPitch;
// skip the number of bytes that aren't part of the part that must be load
SetFilePointer(hFile, skip_bytes, NULL, FILE_CURRENT);
}
image->Unlock(NULL);
}
I think an explanation of some var's might be helpful:
width_mul4 = an integer with get's the value of the next multiple from 4 of the width of the image;
dest = destination (the offscreen surface);
image = pointer to an IDrectDrawSurface4
skip_bytes = width_mul4 - width, number of unimportant bytes of the image
any help would be welcome...
Merwin
[edited by - Merwin van Dijk on April 11, 2002 12:36:08 PM]
[edited by - Merwin van Dijk on April 11, 2002 12:36:53 PM]
[edited by - Merwin van Dijk on April 11, 2002 1:14:25 PM]
[edited by - Merwin van Dijk on April 11, 2002 1:15:43 PM]
[edited by - Merwin van Dijk on April 11, 2002 1:36:15 PM]
[edited by - Merwin van Dijk on April 11, 2002 1:37:03 PM]
[edited by - Merwin van Dijk on April 11, 2002 6:10:14 PM]