2012-06-30 27 views
1

我已經配置我的環境,讓我可以加載適當製作的.png文件到這樣定義的圖片:如何使用boost ::吉加載任何典型的PNG文件

 boost::gil::rgb8_image_t input; 

但怎麼辦我加載任何典型類型的png文件(例如,由GIMP或MS Paint生成)。我認爲它需要boost :: gil :: any_image,但我不知道我需要配置它的類型。

我已經試過:

 typedef boost::mpl::vector< 
      boost::mpl::rgba8_planar_image_t, 
      boost::mpl::rgba8_image_t, 
      boost::mpl::rgb8_planar_image_t, 
      boost::mpl::rgb8_image_t, 
      boost::mpl::gray8_image_t 
     > my_img_types; 
     boost::mpl::any_image<my_img_types> input; 
     boost::gil::png_read_image(ipath, input); 

但是這不加載由MS創建的文件畫圖或GIMP。

+0

顯然,Windows 7上的MS Paint在用於保存編輯後的灰度png時,會保存一個PNG像素類型4的文件,其中http://www.w3.org/TR/PNG-Chunks.html表示「每個像素是一個灰度樣本,然後是一個alpha樣本。「 但我看不到從boost :: gil使用的圖像類型 - 沒有graya8_image_t或graya8_planar_image_t。 – codeshot

回答

4

您是否嘗試過使用功能的家庭png_read_and_convert_ *

例如:

boost::gil::rgb8_image_t input; 
boost::gil::png_read_and_convert_image(ipath, input); 

你會失去原來的類型圖像的這種方式,但如果你想爲你的代碼的固定式操縱這可能是一個好方法。

相關問題