Files
@ r14681:3d2babfe4327
Branch filter:
Location: cpp/openttd-patchpack/source/src/blitter/8bpp_simple.cpp - annotation
r14681:3d2babfe4327
2.2 KiB
text/x-c
(svn r19273) -Codechange: Return station joining error message when error is detected.
r6872:f40beb7256a6 r6872:f40beb7256a6 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r9111:983de9c5a848 r6872:f40beb7256a6 r6861:5c500910beb5 r8123:dde0a9a84019 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6878:61440e99046f r6878:61440e99046f r6861:5c500910beb5 r6861:5c500910beb5 r6878:61440e99046f r6878:61440e99046f r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r11085:c87a330fb4c2 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r11085:c87a330fb4c2 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r11085:c87a330fb4c2 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r11085:c87a330fb4c2 r6861:5c500910beb5 r6861:5c500910beb5 r11085:c87a330fb4c2 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r14551:d7dc2b623893 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 r6861:5c500910beb5 | /* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file 8bpp_simple.cpp Implementation of the simple 8 bpp blitter. */
#include "../stdafx.h"
#include "../zoom_func.h"
#include "8bpp_simple.hpp"
static FBlitter_8bppSimple iFBlitter_8bppSimple;
void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
{
const uint8 *src, *src_line;
uint8 *dst, *dst_line;
/* Find where to start reading in the source sprite */
src_line = (const uint8 *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom);
dst_line = (uint8 *)bp->dst + bp->top * bp->pitch + bp->left;
for (int y = 0; y < bp->height; y++) {
dst = dst_line;
dst_line += bp->pitch;
src = src_line;
src_line += bp->sprite_width * ScaleByZoom(1, zoom);
for (int x = 0; x < bp->width; x++) {
uint colour = 0;
switch (mode) {
case BM_COLOUR_REMAP:
colour = bp->remap[*src];
break;
case BM_TRANSPARENT:
if (*src != 0) colour = bp->remap[*dst];
break;
default:
colour = *src;
break;
}
if (colour != 0) *dst = colour;
dst++;
src += ScaleByZoom(1, zoom);
}
}
}
Sprite *Blitter_8bppSimple::Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator)
{
Sprite *dest_sprite;
dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width);
dest_sprite->height = sprite->height;
dest_sprite->width = sprite->width;
dest_sprite->x_offs = sprite->x_offs;
dest_sprite->y_offs = sprite->y_offs;
/* Copy over only the 'remap' channel, as that is what we care about in 8bpp */
for (int i = 0; i < sprite->height * sprite->width; i++) {
dest_sprite->data[i] = sprite->data[i].m;
}
return dest_sprite;
}
|