[英]Magick++ not loading from blog
I am using Magick++ to load some images. 我正在使用Magick ++加载一些图像。 Because I want to wrap PhysFS for all of my image loads, I needed to load an image by blob instead of file path.
因为我要为所有图像加载包装PhysFS,所以我需要通过blob(而不是文件路径)加载图像。
This code: 这段代码:
Magick::Image test("path/to/some.png");
Works without issue. 没有问题的作品。
However once I do a blob I get an exception: 但是,一旦我做一个blob,我就会得到一个例外:
PhysFS::ifstream img ("path/to/some.png");
Magick::Blob blob( img.rdbuf(), img.length() );
Magick::Image test(blob);
Exception thrown is: 引发的异常是:
terminating with uncaught exception of type Magick::ErrorMissingDelegate no decode delegate for this image format `' @ error/blob.c/BlobToImage/350 以类型为Magick :: ErrorMissingDelegate的未捕获异常终止,此图像格式为''@ error / blob.c / BlobToImage / 350,没有解码委托
I have verified the blob is the same size as the file. 我已验证Blob与文件大小相同。 So I am sure it is reading it into memory.
因此,我确定它正在将其读入内存。
I tried using the standard library ifstream as well setting std::ios::binary but the problem remains. 我尝试使用标准库ifstream以及设置std :: ios :: binary,但问题仍然存在。
Magick::Blob as a constructor needs a void*, in other words a memory location to read the data from. Magick :: Blob作为构造函数需要一个void *,换句话说,就是一个用于读取数据的内存位置。 But you are providing pointer to a std::filebuf object and that won't work.
但是,您提供了指向std :: filebuf对象的指针,该指针不起作用。 You will have to read the file into memory.
您将不得不将文件读入内存。 For example a char* and use that in the Blob constructor.
例如,一个char *并在Blob构造函数中使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.