Esempio n. 1
0
IdTech1Image::IdTech1Image(IByteArray const &data, IByteArray const &palette, Format format)
    : d(new Impl)
{
    Size const rawSize(320, 200);

    if(format == Automatic)
    {
        // Try to guess which format the data uses.
        if(data.size() == rawSize.x * rawSize.y)
        {
            format = RawVGAScreen;
        }
        else
        {
            format = Patch;
        }
    }

    if(format == RawVGAScreen)
    {
        d->nominalSize = rawSize;
        Image::operator = (fromIndexedData(rawSize, data, palette));
    }
    else
    {
        auto const metadata = Patch::loadMetadata(data);
        d->nominalSize = metadata.logicalDimensions;
        d->origin      = metadata.origin;

        Image::operator = (Image::fromMaskedIndexedData(metadata.dimensions,
                                                        Patch::load(data), palette));
    }
}
Esempio n. 2
0
Block::Block(IByteArray const &other)
{
    // Read the other's data directly into our data buffer.
    resize(other.size());
    other.get(0, (dbyte *) data(), other.size());
}
Esempio n. 3
0
FixedByteArray::FixedByteArray(IByteArray const &mainArray)
    : ByteSubArray(mainArray, 0, mainArray.size())
{}
Esempio n. 4
0
ByteSubArray::ByteSubArray(IByteArray const &mainArray, Offset at)
    : _mainArray(nullptr), _constMainArray(&mainArray), _at(at), _size(mainArray.size() - at)
{}