CreateDIBSectionの作り方

DIBセクション作成関数です。

BYTE*dib(HDC d,int x,int y)
{
	HBITMAP b;	LPBITMAPINFO o;	BYTE*e;

	x=((x>>2)+((x&3)>0))<<2;

	o=(LPBITMAPINFO)LocalAlloc(LPTR,sizeof(BITMAPINFO));
	o->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
	o->bmiHeader.biWidth=x;
	o->bmiHeader.biHeight=-y;
	o->bmiHeader.biPlanes=1;
	o->bmiHeader.biBitCount=32;

	SelectObject(d,b=CreateDIBSection(0,o,DIB_RGB_COLORS,(void**)&e,0,0));
	DeleteObject(b);

	LocalFree(o);
	return e;
}

Leave a Reply