I'm having a bit of a problem here... I'm trying to use GDI+ to load in .jpg images.
What I'm doing is creating an off-screen surface:
int PlainSurface(LPDIRECTDRAWSURFACE *lpSource, int width, int height)
{
DDSURFACEDESC ddsd; // DirectDraw surface descriptor
// set size parameter
memset(&ddsd,0,sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
// set the flags
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
// set dimensions of the new surface
ddsd.dwWidth = width;
ddsd.dwHeight = height;
// what kind of offscreen surface
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
// Create the surface and check for error
if(lpdd->CreateSurface(&ddsd, lpSource, NULL)!=DD_OK)
{ /* error */ }
return 0;
}
Now according to what I've learned, that should make an off-screen plain surface. It returns no errors so I'm supposing it is fine.
My second part was to load the bitmap into that surface:
VOID image(const WCHAR *filename, IDirectDrawSurface *lpSurface)
{
lpSurface->GetDC(&hdc);
Graphics graphics(hdc);
Bitmap bitmap(filename);
graphics.DrawImage(&bitmap, 0, 0, bitmap.GetWidth(), bitmap.GetHeight());
lpSurface->ReleaseDC(hdc);
}
This is where I think I made mistakes.
Then to combine the two,
int BitmapLoader(const WCHAR *filename, LPDIRECTDRAWSURFACE lpSurface, int width, int height) {
PlainSurface(&lpSurface, width, height);
image(filename, lpSurface);
return 0;
}
Whenever I try to blt that from the surface to the primary, it never shows up.
I'm not quite sure what I'm doing wrong though [sad]