HSURF APIENTRY EngCreateDeviceSurface( _In_ DHSURF dhsurf, _In_ SIZEL sizl, _In_ ULONG iFormat) { PSURFACE psurf; HSURF hsurf; /* Allocate a surface */ psurf = SURFACE_AllocSurface(STYPE_DEVICE, sizl.cx, sizl.cy, iFormat, 0, 0, 0, NULL); if (!psurf) { DPRINT1("SURFACE_AllocSurface failed.\n"); return NULL; } /* Set the device handle */ psurf->SurfObj.dhsurf = dhsurf; /* Set public ownership */ GDIOBJ_vSetObjectOwner(&psurf->BaseObject, GDI_OBJ_HMGR_PUBLIC); /* Get the handle for the surface */ hsurf = psurf->SurfObj.hsurf; /* Unlock the surface and return */ SURFACE_UnlockSurface(psurf); return hsurf; }
HBITMAP APIENTRY EngCreateBitmap( _In_ SIZEL sizl, _In_ LONG lWidth, _In_ ULONG iFormat, _In_ ULONG fl, _In_opt_ PVOID pvBits) { PSURFACE psurf; HBITMAP hbmp; /* Allocate a surface */ psurf = SURFACE_AllocSurface(STYPE_BITMAP, sizl.cx, sizl.cy, iFormat, fl, lWidth, 0, pvBits); if (!psurf) { DPRINT1("SURFACE_AllocSurface failed.\n"); return NULL; } /* Get the handle for the bitmap */ hbmp = (HBITMAP)psurf->SurfObj.hsurf; /* Set public ownership */ GDIOBJ_vSetObjectOwner(&psurf->BaseObject, GDI_OBJ_HMGR_PUBLIC); /* Unlock the surface and return */ SURFACE_UnlockSurface(psurf); return hbmp; }
HBITMAP NTAPI GreCreateBitmapEx( _In_ ULONG nWidth, _In_ ULONG nHeight, _In_ ULONG cjWidthBytes, _In_ ULONG iFormat, _In_ USHORT fjBitmap, _In_ ULONG cjSizeImage, _In_opt_ PVOID pvBits, _In_ FLONG flags) { PSURFACE psurf; HBITMAP hbmp; PVOID pvCompressedBits = NULL; /* Verify format */ if (iFormat < BMF_1BPP || iFormat > BMF_PNG) return NULL; /* The infamous RLE hack */ if ((iFormat == BMF_4RLE) || (iFormat == BMF_8RLE)) { pvCompressedBits = pvBits; pvBits = NULL; iFormat = (iFormat == BMF_4RLE) ? BMF_4BPP : BMF_8BPP; } /* Allocate a surface */ psurf = SURFACE_AllocSurface(STYPE_BITMAP, nWidth, nHeight, iFormat, fjBitmap, cjWidthBytes, pvBits); if (!psurf) { DPRINT1("SURFACE_AllocSurface failed.\n"); return NULL; } /* The infamous RLE hack */ if (pvCompressedBits) { SIZEL sizl; LONG lDelta; sizl.cx = nWidth; sizl.cy = nHeight; lDelta = WIDTH_BYTES_ALIGN32(nWidth, gajBitsPerFormat[iFormat]); pvBits = psurf->SurfObj.pvBits; DecompressBitmap(sizl, pvCompressedBits, pvBits, lDelta, iFormat); } /* Get the handle for the bitmap */ hbmp = (HBITMAP)psurf->SurfObj.hsurf; /* Mark as API bitmap */ psurf->flags |= (flags | API_BITMAP); /* Unlock the surface and return */ SURFACE_UnlockSurface(psurf); return hbmp; }