Beispiel #1
0
void PLTFile::build() {
	/* For all layers, copy one whole row of pixels into the row buffer.
	 * The row picked for each layer corresponds to the color index we want.
	 * We don't care about the other rows, as they belong to other color indices. */
	byte rows[4 * 256 * kLayerMAX];
	getColorRows(rows, _colors);

	const uint32 pixels = _width * _height;
	const uint8 *image  = _dataImage;
	const uint8 *layer  = _dataLayers;
	      byte  *dst    = _surface->getData();

	/* Now terate over all pixels, each time copying the correct BGRA values
	 * for the pixel's intensity into the final image. */
	for (uint32 i = 0; i < pixels; i++, image++, layer++, dst += 4)
		memcpy(dst, rows + (*layer * 4 * 256) + (*image * 4), 4);
}
Beispiel #2
0
void PLTImage::create(const PLTFile &parent) {
	_mipMaps.push_back(new MipMap);

	_mipMaps[0]->width  = parent._width;
	_mipMaps[0]->height = parent._height;
	_mipMaps[0]->size   = _mipMaps[0]->width * _mipMaps[0]->height * 4;
	_mipMaps[0]->data   = new byte[_mipMaps[0]->size];

	byte rows[4 * 256 * PLTFile::kLayerMAX];
	getColorRows(parent, rows);

	uint32 pixels = parent._width * parent._height;
	const byte *image = parent._dataImage;
	const byte *layer = parent._dataLayers;
	      byte *dst   = _mipMaps[0]->data;

	for (uint32 i = 0; i < pixels; i++, image++, layer++, dst += 4)
		memcpy(dst, rows + (*layer * 4 * 256) + (*image * 4), 4);
}