bitmap image getting strectched
For some reason, when I load a bitmap into an offscreen buffer, the image is getting stretched. I''m using code pretty similar to that used in Game Genesis article 6, but I''ll post it if someone wants. I''m curious what kinds of things could cause a bitmap to get stretched when I''m not explicitly telling it to stretch it (I think)?
Well, I am working in 32-bit, but I tried loading the bitmap in 8-bit, and it did the same thing. Here's the code I'm using:
I know some of the stuff is redundant. I probably don't need to have both a BITMAP variable and the BITMAPFILEHEADER and BITMAPINFOHEADER variables in the same struct, but I don't think it's causing a problem right now, so I left it.
[edited by - Igrum on March 17, 2003 12:44:45 PM]
typedef struct BITMAP_FILE_TYP_24{ BITMAPFILEHEADER bitmapfileheader; BITMAPINFOHEADER bitmapinfoheader; LPDIRECTDRAWSURFACE7 lpddsbuffer; BITMAP bmp;} BITMAP_FILE_24, *BITMAP_FILE_PTR_24;int Load24bitBitmap(BITMAP_FILE_PTR_24 bitmap, char *filename){ OFSTRUCT file_data; // the file data information int file_handle; DDSURFACEDESC2 ddsd; HRESULT hr; DDRAW_INIT_STRUCT(ddsd); // open the file if it exists if ((file_handle = OpenFile(filename,&file_data,OF_READ))==-1) return(0); _lread(file_handle, &bitmap->bitmapfileheader,sizeof(BITMAPFILEHEADER)); _lread(file_handle, &bitmap->bitmapinfoheader,sizeof(BITMAPINFOHEADER)); _lclose(file_handle); bitmap->lpddsbuffer = CreateOffscreenSurface(bitmap->bitmapinfoheader.biWidth, bitmap->bitmapinfoheader.biHeight); HBITMAP hbitmap; HDC hSrcDC; HDC hDestDC; if ((hbitmap = (HBITMAP) LoadImage(NULL, filename, IMAGE_BITMAP, bitmap->bitmapinfoheader.biWidth, bitmap->bitmapinfoheader.biHeight, LR_LOADFROMFILE | LR_CREATEDIBSECTION)) == NULL) { return(0); } if ((hSrcDC = CreateCompatibleDC(NULL)) == NULL) { return(0); } if (SelectObject(hSrcDC, hbitmap) == NULL) { DeleteDC(hSrcDC); return(0); } if (GetObject(hbitmap, sizeof(BITMAP), &bitmap->bmp) == 0) { DeleteDC(hSrcDC); return(0); } if (FAILED(bitmap->lpddsbuffer->GetDC(&hDestDC))) { DeleteDC(hSrcDC); return(0); } if (BitBlt(hDestDC, 0, 0, bitmap->bmp.bmWidth, bitmap->bmp.bmHeight, hSrcDC, 0, 0, SRCCOPY) == NULL) { DeleteDC(hSrcDC); bitmap->lpddsbuffer->ReleaseDC(hDestDC); return(0); } DeleteDC(hSrcDC); bitmap->lpddsbuffer->ReleaseDC(hDestDC); return(1);}
I know some of the stuff is redundant. I probably don't need to have both a BITMAP variable and the BITMAPFILEHEADER and BITMAPINFOHEADER variables in the same struct, but I don't think it's causing a problem right now, so I left it.
[edited by - Igrum on March 17, 2003 12:44:45 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement