WIC Direct2D CreateBitmapFromMemory:宽度和高度的限制
WIC Direct2D CreateBitmapFromMemory: limitations on width and height?
CreateBitmapFromMemory在_nWidth等于或小于644时成功执行。如果该值超过此值,则 HRESULT 值为 -2003292276
宽度和高度是否存在限制?
#include <d2d1.h>
#include <d2d1helper.h>
#include <wincodecsdk.h> // Use this for WIC Direct2D functions
void test()
{
IWICImagingFactory *m_pIWICFactory;
ID2D1Factory *m_pD2DFactory;
IWICBitmap *m_pEmbeddedBitmap;
ID2D1Bitmap *m_pD2DBitmap;
unsigned char *pImageBuffer = new unsigned char[1024*1024];
HRESULT hr = S_OK;
int _nHeight = 300;
int _nWidth = 644;
如果 nWidth 超过 644,CreateBitmapFromMemory 将返回错误。
//_nWidth = 648;
if (m_pIWICFactory == 0 )
{
hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
// Create WIC factory
hr = CoCreateInstance(
CLSID_WICImagingFactory,
NULL,
CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&m_pIWICFactory)
);
if (SUCCEEDED(hr))
{
// Create D2D factory
hr = D2D1CreateFactory( D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pD2DFactory );
}
}
hr = m_pIWICFactory->CreateBitmapFromMemory(
_nHeight, // height
_nWidth, // width
GUID_WICPixelFormat24bppRGB, // pixel format of the NEW bitmap
_nWidth*3, // calculated from width and bpp information
1024*1024, // height x width
pImageBuffer, // name of the .c array
&m_pEmbeddedBitmap // pointer to pointer to whatever an IWICBitmap is.
);
if (!SUCCEEDED(hr)) {
char *buffer = "Error in CreateBitmapFromMemoryn";
}
}
错误代码0x88982F8C WINCODEC_ERR_INSUFFICIENTBUFFER
,原因现在很明显了?
第一个参数是宽度,第二个参数是高度。你把它们按错误的顺序排列。总而言之,您提供了不正确的参数,导致缓冲区错误。
您确定为函数 CreateBitmapFromMemory 传递了正确的 pixelFormat 吗? 您将其硬编码为GUID_WICPixelFormat24bppRGB,我认为这是根本原因,您应该确保此格式与您从中复制数据的源位图的格式相同。 尝试使用 GetPixelFormat 函数来获取正确的格式,而不是硬代码。
GPU 上图像的尺寸有上限。
在呈现器目标上调用 GetMaximumBitmapSize。http://msdn.microsoft.com/query/dev11.query?appId=Dev11IDEF1&l=EN-US&k=k(GetMaximumBitmapSize);k(DevLang-C%2B%2B);k(TargetOS-Windows)&rd=true
你得到的是垂直或 horiz 的最大像素。对于较大的图像,您必须将它们加载到软件呈现目标(如位图呈现目标)中,然后从中渲染您想要的内容。
相关文章:
- C++:如何根据地形高度更新玩家身高?
- 如何更改QComboBox项目的高度大小?
- 更改高度贴图,使其在 4x4 网格上显示 16 个 hieghtmap
- 我试图用这段代码找到二叉树的高度,但它一直返回 0,有人可以告诉我为什么吗?
- C++:如何计算二叉树中其值模块高度小于 2 的节点数?
- 如何使用 C++ gdal 库将栅格地理从 EGM96 转换为 WGS84 椭球体高度基准面
- 如何在 Direct2D 窗口中正确初始化 Directwrite IDWriteTextLayout
- 没有专用显卡的 Direct2D 与 GDI+
- 从具有父指针和左子树和右子树高度的树中删除
- 程序输入名称和高度并显示它。我不知道如何显示列表中最高人的姓名和身高
- 我正在尝试创建一个 C++ 贪吃蛇游戏,但我似乎无法绘制第二个高度边框,我该如何解决这个问题?
- 计算树高度的函数
- 尝试创建一个程序来查找非二叉树的高度.最终得到一个很长的循环,没有答案
- 计算BST返回-1的高度混淆
- 使用递归计算一个函数中的高度和大小
- 如何从2D数组为QHeightMapSurfaceDataProxy创建高度图以显示2D傅立叶变换结果
- 如何在 direct2d 中使用随其窗口重新缩放的效果绘制图像
- 接受来自键盘的树节点以确定其高度
- Direct2D 如何打开共享纹理
- WIC Direct2D CreateBitmapFromMemory:宽度和高度的限制