示例#1
0
void FceuGraphics::Draw(uint8_t *XBuf, int nesw, int nesh)
{
	Clear();

	uint32_t* texture = MapPixels();
	pcpal* pcpalette = Palette;

	for(int i = 0; i != nesw * nesh; i ++)
	{
		texture[i] = ((pcpalette[XBuf[i]].r) << 24) | ((pcpalette[XBuf[i]].g) << 16) | (pcpalette[XBuf[i]].b << 8) | 0xFF;
	}

	UnmapPixels();

	Draw();
}
示例#2
0
WError WImage::SaveToStream(WFile* file, std::ostream& outputStream) {
	if (!Valid())
		return WError(W_NOTVALID);

	outputStream.write((char*)&m_width, sizeof(m_width));
	outputStream.write((char*)&m_height, sizeof(m_height));
	outputStream.write((char*)&m_numComponents, sizeof(m_numComponents));
	outputStream.write((char*)&m_componentSize, sizeof(m_componentSize));
	outputStream.write((char*)&m_format, sizeof(m_format));

	void* pixels;
	WError err = MapPixels(&pixels, true);
	if (err) {
		outputStream.write((char*)pixels, m_width * m_height * m_numComponents * m_componentSize);
		UnmapPixels();
	}

	return err;
}