閉じる

boost 1.68と GIL

このバージョンから io周りが大きく書き換わって、ビルドエラーになっちゃう。
幸い古いコードも残されているので「#include <boost/gil/extension/io/jpeg_io.hpp>」だったのを「#include <boost/gil/extension/io/jpeg/old.hpp>」に書き換えることで一時的にはしのげる。*1
最終的には最新のコードに合わせて書き直しを行う必要があるだろうな。
numeric周りもビルドできなくなっているので頭が痛い。

とりあえず最低限の jpegファイル読み書き。*2

6949.cpp
#include <boost/gil/extension/io/jpeg.hpp>
#include <fstream> // std::ifstream
#include <iostream>// std::ios

int main()
{
try{
boost::gil::rgb8_image_t image;
{
std::ifstream stream("image_16450.jpg", std::ios::binary);
boost::gil::image_read_settings<boost::gil::jpeg_tag> read_settings;
read_image(stream, image, read_settings);
printf("%lldx%lld\n", image.width(), image.height());
}
{
std::ofstream stream("output.jpg", std::ios::binary);
write_view(stream, const_view(image), boost::gil::jpeg_tag());
}
} catch(std::exception const& e){
std::cerr << e.what() << std::endl;
}
return 0;
}
6949.Makefile
OBJS=6949.o
TARGET=6949
DEPEND=.depend

CXXFLAGS=
LDFLAGS=-ljpeg -lstdc++

all: $(TARGET)

$(TARGET) : $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS)

clean:
@rm -f $(TARGET) $(OBJS) $(DEPEND)

dep:
@$(CC) $(CXXFLAGS) $(CPPFLAGS) -MM *.cpp >$(DEPEND)

-include $(DEPEND)

*1 ちなみに jpeg_io_private.hppに依存するようなコードはさすがに即時書き直しになる。

*2 std::stringstreamを使えばメモリ上のも OKと。

コメントを残す

メールアドレスが公開されることはありません。必須項目には印がついています *

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)