Пример #1
0
void CImageIORaw::WriteImage(const CImage& image, CNcbiOstream& ostr,
                             size_t /* x */, size_t y,
                             size_t width, size_t height,
                             CImageIO::ECompress)
{
    // write the header
    ostr.write(reinterpret_cast<const char*>(sc_Header), 4);

    // write dimensions
    size_t depth  = image.GetDepth();

    ostr.write(reinterpret_cast<const char*>(&width),  sizeof(size_t));
    ostr.write(reinterpret_cast<const char*>(&height), sizeof(size_t));
    ostr.write(reinterpret_cast<const char*>(&depth),  sizeof(size_t));

    // calculate the bytes per line for our sub-image anf dor the input image
    const size_t input_bpl  = image.GetWidth() * depth;
    const size_t output_bpl = width * depth;

    // write the image data
    const unsigned char* data = image.GetData();
    data += input_bpl * y;
    for (size_t i = 0;  i < height;  ++i, data += input_bpl) {
        ostr.write(reinterpret_cast<const char*>(data), output_bpl);
    }
}
Пример #2
0
void CImageIORaw::WriteImage(const CImage& image, CNcbiOstream& ostr,
                             CImageIO::ECompress)
{
    // write the header
    ostr.write(reinterpret_cast<const char*>(sc_Header), 4);

    // write dimensions
    size_t width  = image.GetWidth();
    size_t height = image.GetHeight();
    size_t depth  = image.GetDepth();

    ostr.write(reinterpret_cast<const char*>(&width),  sizeof(size_t));
    ostr.write(reinterpret_cast<const char*>(&height), sizeof(size_t));
    ostr.write(reinterpret_cast<const char*>(&depth),  sizeof(size_t));

    // write the image data
    ostr.write(reinterpret_cast<const char*>(image.GetData()),
                 width * height * depth);
}