12 #include "../stdafx.h" 13 #include "../zoom_func.h" 14 #include "../settings_type.h" 15 #include "../core/math_func.hpp" 16 #include "../core/mem_func.hpp" 19 #include "../safeguards.h" 28 uint offset = sprite_src->
offset[zoom];
31 const uint8 *src = sprite_src->
data + offset;
35 for (
int y = 0; y < bp->
skip_top; y++) {
39 if (trans == 0 && pixels == 0)
break;
44 const uint8 *src_next = src;
46 for (
int y = 0; y < bp->
height; y++) {
47 uint8 *dst = dst_line;
48 dst_line += bp->
pitch;
51 int width = bp->
width;
57 src_next = src + pixels;
58 if (trans == 0 && pixels == 0)
break;
59 if (width <= 0)
continue;
62 if (skip_left < trans) {
69 if (skip_left < pixels) {
79 if (skip_left != 0)
continue;
84 if (width <= 0 || pixels == 0)
continue;
85 pixels = min<uint>(pixels, (uint)width);
91 const uint8 *remap = bp->
remap;
96 }
while (--pixels != 0);
106 const uint8 *remap = bp->
remap;
111 }
while (--pixels != 0);
117 dst += pixels; src += pixels;
141 for (
ZoomLevel i = zoom_min; i <= zoom_max; i++) {
153 memset(temp_dst, 0,
sizeof(*temp_dst));
154 byte *dst = temp_dst->
data;
157 for (
ZoomLevel i = zoom_min; i <= zoom_max; i++) {
159 uint offset = dst - temp_dst->
data;
160 temp_dst->
offset[i] = offset;
163 int scaled_height = sprite[i].
height;
164 int scaled_width = sprite[i].
width;
166 for (
int y = 0; y < scaled_height; y++) {
169 uint last_colour = 0;
170 byte *count_dst = NULL;
175 for (
int x = 0; x < scaled_width; x++) {
176 uint colour = src++->
m;
178 if (last_colour == 0 || colour == 0 || pixels == 255) {
179 if (count_dst != NULL) {
186 if (colour == 0 && trans != 255) {
199 last_colour = colour;
209 if (count_dst != NULL) *count_dst = pixels;
217 uint size = dst - (byte *)temp_dst;
220 assert(size < memory);
223 Sprite *dest_sprite = (
Sprite *)allocator(
sizeof(*dest_sprite) + size);
229 memcpy(dest_sprite->
data, temp_dst, size);
int left
The left offset in the 'dst' in pixels to start drawing.
ZoomLevelByte zoom_max
maximum zoom out level
int height
The height in pixels that needs to be drawn to dst.
Perform transparency colour remapping.
int skip_top
How much pixels of the source to skip on the top (based on zoom of dst)
Data structure describing a sprite.
byte data[]
Data, all zoomlevels.
int width
The width in pixels that needs to be drawn to dst.
int skip_left
How much pixels of the source to skip on the left (based on zoom of dst)
uint32 offset[ZOOM_LVL_COUNT]
Offsets (from .data) to streams for different zoom levels.
Definition of a common pixel in OpenTTD's realm.
SpriteType type
The sprite type.
int16 y_offs
Number of pixels to shift the sprite downwards.
Parameters related to blitting.
ClientSettings _settings_client
The current settings for this game.
int pitch
The pitch of the destination buffer.
T * Allocate(size_t count)
Get buffer of at least count times T.
int16 x_offs
The x-offset of where the sprite will be drawn.
SpriteLoader::CommonPixel * data
The sprite itself.
Perform a crash remapping.
A reusable buffer that can be used for places that temporary allocate a bit of memory and do that ver...
Structure for passing information from the sprite loader to the blitter.
Perform remapping to a completely blackened sprite.
uint16 height
Height of the sprite.
static void MemCpyT(T *destination, const T *source, size_t num=1)
Type-safe version of memcpy().
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
Draw an image to the screen, given an amount of params defined above.
ZoomLevelByte zoom_min
minimum zoom out level
uint16 width
Width of the sprite.
ZoomLevel
All zoom levels we know.
uint16 width
Width of the sprite.
int top
The top offset in the 'dst' in pixels to start drawing.
GUISettings gui
settings related to the GUI
const byte * remap
XXX – Temporary storage for remap array.
const void * sprite
Pointer to the sprite how ever the encoder stored it.
Perform a colour remapping.
static FBlitter_8bppOptimized iFBlitter_8bppOptimized
Instantiation of the 8bpp optimised blitter factory.
Data stored about a (single) sprite.
uint16 height
Height of the sprite.
Factory for the 8bpp blitter optimised for speed.
int16 x_offs
Number of pixels to shift the sprite to the right.
void * dst
Destination buffer.
int16 y_offs
The y-offset of where the sprite will be drawn.
Sprite * Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
Convert a sprite from the loader to our own format.
BlitterMode
The modes of blitting we can do.
An optimized 8 bpp blitter.
static void MemSetT(T *ptr, byte value, size_t num=1)
Type-safe version of memset().