I'm now using StreamImage instead. Is this the correct way to decode an image into memory that I control? I can stream from a blob to a file easily enough (error handling and resource cleanup omitted):
Code: Select all
std::vector<uint8> inputData;
char* outputFile = "C:\\Users\\atomic\\Desktop\\img_test.raw";
ImageInfo* imReadInfo = AcquireImageInfo();
SetImageInfoBlob(imReadInfo, inputData.data(), inputData.size());
ImageInfo* imWriteInfo = AcquireImageInfo();
StreamInfo* strInfo = AcquireStreamInfo(imWriteInfo, exInfo);
SetStreamInfoMap(strInfo, "RGBA");
SetStreamInfoStorageType(strInfo, FloatPixel);
OpenStream(imWriteInfo, strInfo, outputFile, exInfo);
Image* imImage = StreamImage(imReadInfo, strInfo, exInfo);
but the moment I switch the output file to a blob it explodes
Code: Select all
std::vector<uint8> inputData;
std::vector<uint32> outputData;
ImageInfo* imReadInfo = AcquireImageInfo();
SetImageInfoBlob(imReadInfo, inputData.data(), inputData.size());
ImageInfo* imWriteInfo = AcquireImageInfo();
outputData.reserve(256 * 256 * 4 * 4);
SetImageInfoBlob(imWriteInfo, outputData.data(), outputData.size());
StreamInfo* strInfo = AcquireStreamInfo(imWriteInfo, exInfo);
SetStreamInfoMap(strInfo, "RGBA");
SetStreamInfoStorageType(strInfo, FloatPixel);
OpenStream(imWriteInfo, strInfo, "", exInfo);
Image* imImage = StreamImage(imReadInfo, strInfo, exInfo);
How do I tell StreamImage to write to my memory buffer? Currently, I think it's assuming the blob is Magick owned memory and tries to realloc, causing the crash.