0
私はCreateDIBSection
を使用しようとしています。なぜCreateDIBSection()はcertian BITMAPINFOで失敗しますか?
問題:Windows XPでは
、私はそれがNULL
とGetLastError
= 0
私は2048×1536に例えば画面の解像度を変更しようとすると、それが正しい返しを返し、CreateDIBSection
を呼び出そうとしました値。私はこの機能をテストしている
はnMemSize
(必ずしも少数)と何らかの関係を持っています。
質問:
CreateDIBSection
戻り、正しい値を確保するための任意の保証方法はありますか?
nScreenWidth = 1024;
nScreenHeight= 768;
= nScreenWidth*nScreenHeight*3*7
HDC hdc = ::GetDC(hWnd);
m_hBmpMapFile = ::CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, nMemSize, NULL);
BITMAPINFO bmpInfo = {0};
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmpInfo.bmiHeader.biWidth = nScreenWidth;
bmpInfo.bmiHeader.biHeight = nScreenHeight;
bmpInfo.bmiHeader.biPlanes = 1;
bmpInfo.bmiHeader.biBitCount = 24;
bmpInfo.bmiHeader.biCompression = 0;
bmpInfo.bmiHeader.biSizeImage = nMemSize;
bmpInfo.bmiHeader.biXPelsPerMeter = 0;
bmpInfo.bmiHeader.biYPelsPerMeter = 0;
bmpInfo.bmiHeader.biClrUsed = 0;
bmpInfo.bmiHeader.biClrImportant = 0;
bmpInfo.bmiColors[0].rgbBlue = 204;
bmpInfo.bmiColors[0].rgbGreen = 204;
bmpInfo.bmiColors[0].rgbRed = 204;
bmpInfo.bmiColors[0].rgbReserved = 0;
PVOID pvBits;
m_hBmpAllWstDskWallpaper = ::CreateDIBSection(hdc, &bmpInfo, DIB_RGB_COLORS, &pvBits, m_hBmpMapFile, 0);
なぜそれが失敗するのかは明らかではありません。あなたの質問は本当に "なぜCreateDIBSectionが失敗するのですか?"と思う。あなたがその答えを得ることができれば、本当の問題を解決できるはずです。 –
私はそれを変更しました。私はreail問題はnMemSizeがcertian番号に変更したときにCreateDIBSectionが失敗した本当にだと思います。時にはそれが言う10000で失敗しますが、uは20000より大きいにnMemsizeを変更したときにそれがsuccesed。 – yyy
@yyy: 'bmpinfo.bmiHeader'のポストすべてのフィールド。あなたがそれらに割り当てる値は? – Nawaz