0
더 복잡한/구조화 된 유형에 boost :: iostreams를 사용할 수 있습니까? 더 복잡한/구조화 된 형식에 대해 boost :: stream을 사용하면 chars가 발생합니까?
는 내가하고 싶은 것은 이미지를 스트리밍하는 것입니다 그러나 그들은 폭, 높이, 색상, 같은 몇 가지 주석을 가져야한다 ... 내 첫번째 생각은 문자 또는 WCHAR 대신 구조체를 사용하는 것입니다namespace io = boost::iostreams;
struct SingleImageStream{
unsigned int width;
unsigned int height;
unsigned char colordepth;
unsigned char* frame;
};
class SingleImageSource {
public:
typedef struct SingleImageStream char_type;
typedef io::source_tag category;
std::streamsize read(struct SingleImageStream* s, std::streamsize n)
{
char* frame = new char[640*480];
std::fill(frame, frame + sizeof(frame), 0);
s->width = 640;
s->height = 480;
std::copy(frame, frame + sizeof(frame), s->frame);
return -1;
}
};
class SingleImageSink {
public:
typedef struct SingleImageStream char_type;
typedef io::sink_tag category;
std::streamsize write(const struct SingleImageStream* s, std::streamsize n)
{
std::cout << "Frame width : " << s->width << " frame height : " << s->height << std::endl;
return n;
}
};
내 문제는 어떻게 소스와 싱크를 연결할 수 있습니까?
들으