All pastes #948700 Raw Edit

Anonym

public cpp v1 · immutable
·published 2008-03-19 11:49 UTC
rendered paste body
HBITMAP CreateBitmapFromPixel(HDC hDC, UINT uWidth, UINT uHeight, UINT uBitsPerPixel, LPVOID pBits) {	HBITMAP hBitmap = 0;	if (!uWidth || !uHeight || !uBitsPerPixel) return hBitmap;		LONG lBmpSize = uWidth * uHeight * (uBitsPerPixel/8);		BITMAPINFO bmpInfo = {0};	bmpInfo.bmiHeader.biBitCount = uBitsPerPixel;	bmpInfo.bmiHeader.biHeight = uHeight;	bmpInfo.bmiHeader.biWidth = uWidth;	bmpInfo.bmiHeader.biPlanes = 1;	bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);	// Pointer to access the pixels of bitmap	UINT *pPixels = 0;	hBitmap = CreateDIBSection(hDC, (BITMAPINFO *)&bmpInfo,                  DIB_RGB_COLORS, (void **)&pPixels, NULL, 0);		if (!hBitmap) return hBitmap;		//Entweder:	SetBitmapBits(hBitmap, lBmpSize, pBits);	//Oder:	//memcpy(pPixels, pBits, lBmpSize);	return hBitmap;}