Пример #1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
Color4f::Color4f(const Color4ub& other)
{
    m_rgba[0] = static_cast<float>(other.r())/255.0f;
    m_rgba[1] = static_cast<float>(other.g())/255.0f;
    m_rgba[2] = static_cast<float>(other.b())/255.0f;
    m_rgba[3] = static_cast<float>(other.a())/255.0f;
}
//--------------------------------------------------------------------------------------------------
/// Set the color value of a specific pixel
/// 
/// \warning Pixel position (0,0) is in the lower left corner of the image.
//--------------------------------------------------------------------------------------------------
void TextureImage::setPixel(uint x, uint y, const Color4ub& clr)
{
    CVF_TIGHT_ASSERT(x < m_width);
    CVF_TIGHT_ASSERT(y < m_height);

    const uint idx = 4*(y*m_width + x);
    m_dataRgba[idx]     = clr.r();
    m_dataRgba[idx + 1] = clr.g(); 
    m_dataRgba[idx + 2] = clr.b(); 
    m_dataRgba[idx + 3] = clr.a(); 
}
Пример #3
0
//--------------------------------------------------------------------------------------------------
/// Set the color value of a specific pixel
/// 
/// \warning Pixel position (0,0) is in the lower left corner of the image.
//--------------------------------------------------------------------------------------------------
void TextureImage::setPixel(uint x, uint y, const Color4ub& clr)
{
    CVF_TIGHT_ASSERT(x < m_width);
    CVF_TIGHT_ASSERT(y < m_height);

    ubyte* rgbaThisPixel = &m_dataRgba[4*(y*m_width + x)];
    rgbaThisPixel[0] = clr.r();
    rgbaThisPixel[1] = clr.g(); 
    rgbaThisPixel[2] = clr.b(); 
    rgbaThisPixel[3] = clr.a(); 
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void TextureImage::fill(const Color4ub& clr)
{
    size_t numBytes = m_dataRgba.size();

    size_t i;
    for (i = 0; i < numBytes; i += 4)
    {
        m_dataRgba[i]     = clr.r();
        m_dataRgba[i + 1] = clr.g();
        m_dataRgba[i + 2] = clr.b();
        m_dataRgba[i + 3] = clr.a();
    }
}