Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/155.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ CreateCompatibleBitmap在Windows mobile 6上失败_C++_Bitmap_Mfc_Windows Mobile_Gdi - Fatal编程技术网

C++ CreateCompatibleBitmap在Windows mobile 6上失败

C++ CreateCompatibleBitmap在Windows mobile 6上失败,c++,bitmap,mfc,windows-mobile,gdi,C++,Bitmap,Mfc,Windows Mobile,Gdi,我正在VisualStudio2008下将一个应用程序从WindowsMobile 2003移植到WindowsMobile 6。目标设备有VGA分辨率的屏幕,我惊讶地发现以下代码失败了 CClientDC ClientDC(this); CRect Rect; GetClientRect(&Rect); int nWidth = Rect.Width(),nHeight = Rect.Height(); CBitmap Temp; if (!Temp.CreateCompa

我正在VisualStudio2008下将一个应用程序从WindowsMobile 2003移植到WindowsMobile 6。目标设备有VGA分辨率的屏幕,我惊讶地发现以下代码失败了

CClientDC ClientDC(this);
 CRect Rect;
 GetClientRect(&Rect);

 int nWidth = Rect.Width(),nHeight = Rect.Height();
 CBitmap Temp;
 if (!Temp.CreateCompatibleBitmap(&ClientDC,nWidth,nHeight))
 {
  LogError(elvl_Debug,_T("Error creating bitmap (%s)"),LastSysError());

 } else
 {
  BITMAP bmpinfo;
  Temp.GetBitmap(&bmpinfo);
 }
CreateCompatibleBitmap
的返回代码为8,这表示“内存不足,无法处理命令”。nWidth是350,nHeight是400,显示是每像素16位,所以我的位图是280K。我使用的设备有256mb的程序内存,我已经告诉链接器保留4mb的堆栈和64mb的堆。你知道我做错了什么,更重要的是找到了解决办法吗?自CE2.1以来,我一直在WindowsCE上使用类似于上面的代码,没有任何问题

编辑:根据Josh Kelly的帖子,我转向了在设备上运行良好的设备独立位图。代码现在是这样的

CClientDC ClientDC(this);
CRect Rect;
GetClientRect(&Rect);
int nWidth = Rect.Width(),nHeight = Rect.Height();
BITMAPINFOHEADER bmi = { sizeof(bmi) }; 
bmi.biWidth = nWidth; 
bmi.biHeight = nHeight; 
bmi.biPlanes = 1; 
bmi.biBitCount = 8; 
HDC hdc = CreateCompatibleDC(NULL); 
BYTE* pbData = 0; 
HBITMAP DIB = CreateDIBSection(hdc, (BITMAPINFO*)&bmi, DIB_RGB_COLORS, (void**)&pbData, NULL, 0);
CBitmap *pTempBitmap = CBitmap::FromHandle(DIB);

我没有做过任何Windows CE/Windows Mobile编程,但我在桌面Windows中处理了一个(
CreateCompatibleBitmap
失败,出现
错误\u内存不足
)。显然,从我在网上的观察可以看出,Windows可能会对依赖于设备的位图的可用内存实施全局限制。(例如,某些视频驱动程序可能会选择将设备相关位图存储在视频RAM中,在这种情况下,您的视频卡上的RAM数量会受到限制。)请参阅,例如。据我所知,这些限制是由个人视频卡或司机决定的;有些计算机的存储空间实际上可能是无限的,而另一些可能有严格的限制


一种解决方案是使用与设备无关的位图,即使它们有轻微的性能损失。

这看起来很可能是这样,因为CreateBitMap也不起作用。我会试试这个部分,看看效果如何。