簡體   English   中英

如何使用imagemagick Magick ++將圖像以gif格式寫入blob

[英]how to write images as gif to blob using imagemagick Magick++

  vector<Magick::Image> frames;
int delay = 20;
for(auto iter=taskList.begin(); iter != taskList.end(); ++iter){
/* hide some codes here*/
  frames.push_back(*img);
}
// write images to file, works fine
Magick::writeImages(frames.begin(), frames.end(), "xxx.gif");
Magick::Blob tmpBlob;
// write images to blob, I then decode the data in blob,  
// and write this blob to yyy.gif. The gif file only contains the first frame image.
Magick::writeImages(frames.begin(), frames.end(), &tmpBlob, true);
// the length is far too small 
LOG_DEBUG("blob data length: %d", tmpBlob.length());
// read from the blob into a imagelist, and print the size of the list
// the size is 1 
vector<Magick::Image> image_list;
Magick::readImages(&image_list, tmpBlob);
LOG_DEBUG("new frames length: %d", image_list.size());

嗨,我嘗試使用ImageMagick(version 7.0.3)Magick ++ STL.h writeImages函數將圖像列表寫入Blob時遇到問題。 它無法正常工作,似乎只有一幀寫入了Blob。 但是使用相同的圖像列表,將它們寫入gif文件就可以了。 有人可以幫我嗎?

問題解決了。 我失敗的原因是我沒有執行img-> magick(“ GIF”),這導致無法正確寫入Blob。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM