簡體   English   中英

使用Magick ++將Montage保存到Blob

[英]Save Montage to Blob with Magick++

我有一個蒙太奇,可以在指定目標路徑后將其保存到磁盤,但是當我嘗試將其保存到Blob時會失敗。

我是否缺少某些設置?

版本:ImageMagick 6.8.2-5 2013-02-05 Q8

機器:Windows 7 x64

編輯 :例外:

Unhandled Exception: System.Runtime.InteropServices.SEHException: External component has thrown an exception.
   at Magick.throwException(_ExceptionInfo* )
   at Magick.writeImages<class std::_List_iterator<class std::_List_val<class Magick::Image,class std::allocator<class Magick::Image> > > >
   (_List_iterator<std::_List_val<Magick::Image\,std::allocator<Magick::Image> > > first_, _List_iterator<std::_List_val<Magick::Image\,std::allocator<Magick::Image
   > > > last_, Blob* blob_, Boolean adjoin_) in d:\dev\projects\ecs\layers\tools\imagemagicknet\include8\magick++\stl.h:line 2562

源圖像

編碼:

   void test()
   {
      list<Magick::Image> sourceImageList;
      Magick::Image image;

      image.read("d:\\imtest\\Montage\\1.jpg");
      sourceImageList.push_back(image);
      image.read("d:\\imtest\\Montage\\2.jpg");
      sourceImageList.push_back(image);
      image.read("d:\\imtest\\Montage\\3.jpg");
      sourceImageList.push_back(image);

      Magick::Color color("rgba(0,0,0,0)");

      Montage montageSettings;
      montageSettings.geometry("100x100-0-0");
      montageSettings.shadow(true);
      montageSettings.backgroundColor(color);
      montageSettings.tile( "3x1" );

      list<Magick::Image> montagelist;
      Magick::montageImages( &montagelist, sourceImageList.begin(), sourceImageList.end(), montageSettings);

      // This will give the expected result
      Magick::writeImages(montagelist.begin(), montagelist.end(), "d:\\imtest\\Montage\\out.png");

      Magick::Blob *b = new Magick::Blob();
      // This will throw an exception mentioned above
      Magick::writeImages(montagelist.begin(), montagelist.end(), b);
      Magick::Image imageFromBlob(*b);
      imageFromBlob.write("d:\\imtest\\Montage\\outBlob.png");

   }

您應該為異常添加try / catch塊,以便捕獲異常並對其進行診斷(例如,將打印異常打印到stderr,以便可以看到“ what”字符串)。 無法診斷未處理的異常。

[Magick :: Exception]中詳細介紹了處理從Magick ++引發的異常的正確方法。 1

暫無
暫無

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

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