コード例 #1
0
ファイル: image.cpp プロジェクト: Anastaciaa/otclient-1
void Image::overwriteMask(const Color& maskedColor, const Color& insideColor, const Color& outsideColor)
{
    assert(m_bpp == 4);

    for(int p=0;p<getPixelCount();p++) {
        uint8& r = m_pixels[p*4 + 0];
        uint8& g = m_pixels[p*4 + 1];
        uint8& b = m_pixels[p*4 + 2];
        uint8& a = m_pixels[p*4 + 3];

        Color pixelColor(r,g,b,a);
        Color writeColor = (pixelColor == maskedColor) ? insideColor : outsideColor;

        r = writeColor.r();
        g = writeColor.g();
        b = writeColor.b();
        a = writeColor.a();
    }
}
コード例 #2
0
ファイル: texture.hpp プロジェクト: pviswanathan/DynamO
	/*! \brief Copy the contents of the texture to a floating point array.

	  This will automatically resize the passed array to fit the
	  entire contents of the texture in.
	 */
	inline void writeto(std::vector<uint8_t>& data, GLint lvl = 0)
	{
	  data.resize(4 * getPixelCount(lvl));
	  
	  bind(0);

	  GLenum type;
	  switch (components())
	    {
	    case 1: type = GL_R; break;
	    case 2: type = GL_RG; break;
	    case 3: type = GL_RGB; break;
	    case 4: type = GL_RGBA; break;
	    default:
	      M_throw() << "Too many components!";
	    }

	  glGetTexImage(_texType, lvl, type, GL_UNSIGNED_BYTE, &data[0]);
	}