コード例 #1
0
	//! returns a pixel
	ColourValue CImage::getPixel(UINT32 x, UINT32 y) const
	{
		ColourValue c;
		if (x >= Size.Width || y >= Size.Height)
			return c;
		
		switch (Format)
		{
		case ECF_A1R5G5B5:
			c.setAsARGB(A1R5G5B5toA8R8G8B8(((UINT16*)Data)[y*Size.Width + x]));
			return c; //A1R5G5B5toA8R8G8B8(((UINT16*)Data)[y*Size.Width + x]);
		case ECF_R5G6B5:
			c.setAsARGB(R5G6B5toA8R8G8B8(((UINT16*)Data)[y*Size.Width + x]));
			return c;//R5G6B5toA8R8G8B8(((UINT16*)Data)[y*Size.Width + x]);
		case ECF_A8R8G8B8:
			c.setAsARGB(((UINT32*)Data)[y*Size.Width + x]);
			return c;// ((UINT32*)Data)[y*Size.Width + x];
		case ECF_R8G8B8:
		{
			UINT8* p = Data + (y * 3)*Size.Width + (x * 3);
			c.setAlpha(255);
			c.setRed(p[0]);
			c.setBlue(p[1]);
			c.setGreen(p[2]);
			return c;
		}
#ifndef _DEBUG
		default:
			break;
#endif
		}

		return ColourValue(0);
	}
コード例 #2
0
void CColorConverter::convert_A1R5G5B5toA8R8G8B8(const void* sP, s32 sN, void* dP)
{
	u16* sB = (u16*)sP;
	u32* dB = (u32*)dP;

	for (s32 x = 0; x < sN; ++x)
		*dB++ = A1R5G5B5toA8R8G8B8(*sB++);
}
コード例 #3
0
ファイル: CNullDriver.cpp プロジェクト: ChangerR/dream
//! Creates an boolean alpha channel of the texture based of an color key position.
void CNullDriver::makeColorKeyTexture(ITexture* texture,
					position2d<s32> colorKeyPixelPos,
					bool zeroTexels) const
{
	if (!texture)
		return;

	if (texture->getColorFormat() != ECF_A1R5G5B5 &&
		texture->getColorFormat() != ECF_A8R8G8B8 )
	{
		Printer::log("Error: Unsupported texture color format for making color key channel.", ELL_ERROR);
		return;
	}

	SColor colorKey;

	if (texture->getColorFormat() == ECF_A1R5G5B5)
	{
		u16 *p = (u16*)texture->lock(ETLM_READ_ONLY);

		if (!p)
		{
			Printer::log("Could not lock texture for making color key channel.", ELL_ERROR);
			return;
		}

		u32 pitch = texture->getPitch() / 2;

		const u16 key16Bit = 0x7fff & p[colorKeyPixelPos.Y*pitch + colorKeyPixelPos.X];

		colorKey = A1R5G5B5toA8R8G8B8(key16Bit);
	}
	else
	{
		u32 *p = (u32*)texture->lock(ETLM_READ_ONLY);

		if (!p)
		{
			Printer::log("Could not lock texture for making color key channel.", ELL_ERROR);
			return;
		}

		u32 pitch = texture->getPitch() / 4;
		colorKey = 0x00ffffff & p[colorKeyPixelPos.Y*pitch + colorKeyPixelPos.X];
	}

	texture->unlock();
	makeColorKeyTexture(texture, colorKey, zeroTexels);
}
コード例 #4
0
ファイル: CD3D9Texture.cpp プロジェクト: Lumirion/pseuwow
void CD3D9Texture::copy16BitMipMap(char* src, char* tgt,
				   s32 width, s32 height,
				   s32 pitchsrc, s32 pitchtgt) const
{
	for (s32 y=0; y<height; ++y)
	{
		for (s32 x=0; x<width; ++x)
		{
			u32 a=0, r=0, g=0, b=0;

			for (s32 dy=0; dy<2; ++dy)
			{
				const s32 tgy = (y*2)+dy;
				for (s32 dx=0; dx<2; ++dx)
				{
					const s32 tgx = (x*2)+dx;

					SColor c;
					if (ColorFormat == ECF_A1R5G5B5)
						c = A1R5G5B5toA8R8G8B8(*(u16*)(&src[(tgx*2)+(tgy*pitchsrc)]));
					else
						c = R5G6B5toA8R8G8B8(*(u16*)(&src[(tgx*2)+(tgy*pitchsrc)]));

					a += c.getAlpha();
					r += c.getRed();
					g += c.getGreen();
					b += c.getBlue();
				}
			}

			a /= 4;
			r /= 4;
			g /= 4;
			b /= 4;

			u16 c;
			if (ColorFormat == ECF_A1R5G5B5)
				c = RGBA16(r,g,b,a);
			else
				c = A8R8G8B8toR5G6B5(SColor(a,r,g,b).color);
			*(u16*)(&tgt[(x*2)+(y*pitchtgt)]) = c;
		}
	}
}
コード例 #5
0
ファイル: SImage.cpp プロジェクト: AwkwardDev/pseuwow
//! returns a pixel
SColor SImage::getPixel(u32 x, u32 y) const
{
	if (x >= (u32)Size.Width || y >= (u32)Size.Height)
		return SColor(0);

	switch(Format)
	{
	case ECF_A1R5G5B5:
		return A1R5G5B5toA8R8G8B8(((u16*)Data)[y*Size.Width + x]);
	case ECF_R5G6B5:
		return R5G6B5toA8R8G8B8(((u16*)Data)[y*Size.Width + x]);
	case ECF_A8R8G8B8:
		return ((u32*)Data)[y*Size.Width + x];
	case ECF_R8G8B8:
		{
			u8* p = &((u8*)Data)[(y*3)*Size.Width + (x*3)];
			return SColor(255,p[0],p[1],p[2]);
		}
	}

	return SColor(0);
}