本文整理汇总了C++中DllImageLib::LoadImageFromMemory方法的典型用法代码示例。如果您正苦于以下问题:C++ DllImageLib::LoadImageFromMemory方法的具体用法?C++ DllImageLib::LoadImageFromMemory怎么用?C++ DllImageLib::LoadImageFromMemory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DllImageLib
的用法示例。
在下文中一共展示了DllImageLib::LoadImageFromMemory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadFromFileInMem
bool CBaseTexture::LoadFromFileInMem(unsigned char* buffer, size_t size, const std::string& mimeType, unsigned int maxWidth, unsigned int maxHeight)
{
if (!buffer || !size)
return false;
//ImageLib is sooo sloow for jpegs. Try our own decoder first. If it fails, fall back to ImageLib.
if (mimeType == "image/jpeg")
{
CJpegIO jpegfile;
if (jpegfile.Read(buffer, size, maxWidth, maxHeight))
{
if (jpegfile.Width() > 0 && jpegfile.Height() > 0)
{
Allocate(jpegfile.Width(), jpegfile.Height(), XB_FMT_A8R8G8B8);
if (jpegfile.Decode(m_pixels, GetPitch(), XB_FMT_A8R8G8B8))
{
m_hasAlpha=false;
ClampToEdge();
return true;
}
}
}
}
DllImageLib dll;
if (!dll.Load())
return false;
ImageInfo image;
memset(&image, 0, sizeof(image));
unsigned int width = maxWidth ? std::min(maxWidth, g_Windowing.GetMaxTextureSize()) : g_Windowing.GetMaxTextureSize();
unsigned int height = maxHeight ? std::min(maxHeight, g_Windowing.GetMaxTextureSize()) : g_Windowing.GetMaxTextureSize();
CStdString ext = mimeType;
int nPos = ext.Find('/');
if (nPos > -1)
ext.Delete(0, nPos + 1);
if(!dll.LoadImageFromMemory(buffer, size, ext.c_str(), width, height, &image))
{
CLog::Log(LOGERROR, "Texture manager unable to load image from memory");
return false;
}
LoadFromImage(image);
dll.ReleaseImage(&image);
return true;
}