ImageMagick错误:无法打开图像 [英] ImageMagick Error: Unable to open image
问题描述
我在我的应用程序中使用ImageMagick(Magick ++),但是当尝试加载图片时出现错误:
无法打开image'??':无效的参数@ error / blob.c / OpenBlob / 2657
阅读其他人在线问题 ??
通常是试图加载的文件,我显然没有将文件位置 ??
传递给加载器 - 所以它似乎无法解析我给它的字符串。尝试使用Unicode和多字节。从示例复制项目设置。
LawlessFBXTexture * LawlessFBXTextureManager :: CreateTexture(std :: string pFullFilePath)
{
Magick :: Image * img = nullptr;
Magick :: Blob blob;
try
{
img = new Magik :: Image();
img-> read(pFullFilePath);
img-> write(& blob,RGBA);
}
catch(Magick :: Error& Err)
{
std :: string errstr = Err.what();
std :: wstring stemps = std :: wstring(errstr.begin(),errstr.end());
LPCWSTR sws = stemps.c_str();
OutputDebugString(LFBXSDK:ERROR:);
OutputDebugString(sws);
OutputDebugString(L\\\
);
int ImageNotFound = 0; /// Image Not found< ---
assert(ImageNotFound);
}
LawlessFBXTexture * tex = new LawlessFBXTexture();
glGenTextures(1,& tex-> TextureBuffer);
glBindTexture(GL_TEXTURE_2D,tex-> TextureBuffer);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,img-> columns(),img-> rows(),0,GL_RGBA,GL_UNSIGNED_BYTE,blob.data());
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
return tex;
}
被呼叫者:
LawlessFBXTexture * tex = CreateTexture(.. \\..\\Asset\\Models\\LawlessCoreAsset\\ DEFAULT_DIFFUSE.png);
我注意到这在发布模式下可以正常工作, 。我很确定这是一个错误,所以我会在Magick论坛上发布我的发现。
I'm using ImageMagick (Magick++) in my application but when trying to load an image I get the error:
Unable to open image '??': Invalid argument @ error/blob.c/OpenBlob/2657
From reading other peoples problems online ??
is typically the file trying to be loaded, and I am obviously not passing the file location ??
to the loader - so it appears not to be able to resolve the string I am giving it. Tried using Unicode and Multi-byte. Copied project settings from example(s). File definitely exists and definitely the correct location.
Code:
LawlessFBXTexture* LawlessFBXTextureManager::CreateTexture(std::string pFullFilePath)
{
Magick::Image* img = nullptr;
Magick::Blob blob;
try
{
img = new Magick::Image();
img->read(pFullFilePath);
img->write(&blob, "RGBA");
}
catch (Magick::Error& Err)
{
std::string errstr = Err.what();
std::wstring stemps = std::wstring(errstr.begin(), errstr.end());
LPCWSTR sws = stemps.c_str();
OutputDebugString(L"FBXSDK: ERROR: ");
OutputDebugString(sws);
OutputDebugString(L"\n");
int ImageNotFound = 0; /// Image Not found <---
assert(ImageNotFound);
}
LawlessFBXTexture* tex = new LawlessFBXTexture();
glGenTextures(1, &tex->TextureBuffer);
glBindTexture(GL_TEXTURE_2D, tex->TextureBuffer);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img->columns(), img->rows(), 0, GL_RGBA, GL_UNSIGNED_BYTE, blob.data());
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
return tex;
}
being called by :
LawlessFBXTexture* tex = CreateTexture("..\\..\\Asset\\Models\\LawlessCoreAsset\\DEFAULT_DIFFUSE.png");
I noticed this works fine in release mode, without making changes. I am pretty sure this is down to a bug so I'll post my findings on the Magick forums.
这篇关于ImageMagick错误:无法打开图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!