コード例 #1
0
bool GLTextureRectangle::set( Array2DReadView< uint8x2 > srcData,
    GLImageFormat srcFormat,
    const Vector2i& dstOffset )
{
    if( srcFormat != GLImageFormat::RG )
    {
        return false;
    }
    if( !srcData.packed() )
    {
        return false;
    }
    const GLPixelType srcType = GLPixelType::UNSIGNED_BYTE;
    return set2D( srcData.pointer(), srcData.size(), srcFormat, srcType,
                 dstOffset );
}
コード例 #2
0
bool GLTextureRectangle::set( Array2DReadView< Vector4f > srcData,
    GLImageFormat srcFormat,
    const Vector2i& dstOffset )
{
    if( srcFormat != GLImageFormat::RGBA && srcFormat != GLImageFormat::BGRA )
    {
        return false;
    }
    if( !srcData.packed() )
    {
        return false;
    }
    const GLPixelType srcType = GLPixelType::FLOAT;
    return set2D( srcData.pointer(), srcData.size(), srcFormat, srcType,
                 dstOffset );
}
コード例 #3
0
// static
bool PNGIO::write( const std::string& filename,
    Array2DReadView< uint16_t > image )
{
    // TODO: use BitPacking::byteSwap16 on the buffer once it supports a
    // destination.
    Array2D< uint16_t > tmpImage( image.size() );
    libcgt::core::arrayutils::map( image, tmpImage.writeView(),
        [&] ( uint16_t z )
        {
            return byteSwap16( z );
        }
    );

    const uint8_t* srcPointer = reinterpret_cast< const uint8_t* >(
        tmpImage.pointer() );
    unsigned int errVal = lodepng::encode(
        filename, srcPointer, image.width(), image.height(), LCT_GREY, 16U );
    bool succeeded = ( errVal == 0 );
    return succeeded;
}
コード例 #4
0
// static
bool PNGIO::write( const std::string& filename,
    Array2DReadView< uint8x4 > image )
{
    Array2D< uint8x4 > tmpImage;
    const uint8_t* srcPointer;

    if( !image.packed() )
    {
        tmpImage.resize( image.size() );
        copy< uint8x4 >( image, tmpImage );
        srcPointer = reinterpret_cast< const uint8_t* >( tmpImage.pointer() );
    }
    else
    {
        srcPointer = reinterpret_cast< const uint8_t* >( image.pointer() );
    }

    unsigned int errVal = lodepng::encode(
        filename, srcPointer, image.width(), image.height(), LCT_RGBA );
    bool succeeded = ( errVal == 0 );
    return succeeded;
}