Go to the documentation of this file.
10 #include "../stdafx.h"
11 #include "../zoom_func.h"
12 #include "../settings_type.h"
13 #include "../core/math_func.hpp"
14 #include "../core/mem_func.hpp"
17 #include "../safeguards.h"
26 uint offset = sprite_src->
offset[zoom];
29 const uint8 *src = sprite_src->
data + offset;
33 for (
int y = 0; y < bp->
skip_top; y++) {
37 if (trans == 0 && pixels == 0)
break;
42 const uint8 *src_next = src;
44 for (
int y = 0; y < bp->
height; y++) {
45 uint8 *dst = dst_line;
46 dst_line += bp->
pitch;
49 int width = bp->
width;
55 src_next = src + pixels;
56 if (trans == 0 && pixels == 0)
break;
57 if (width <= 0)
continue;
60 if (skip_left < trans) {
67 if (skip_left < pixels) {
77 if (skip_left != 0)
continue;
82 if (width <= 0 || pixels == 0)
continue;
83 pixels = std::min<uint>(pixels, width);
89 const uint8 *remap = bp->
remap;
94 }
while (--pixels != 0);
104 const uint8 *remap = bp->
remap;
109 }
while (--pixels != 0);
115 dst += pixels; src += pixels;
139 for (
ZoomLevel i = zoom_min; i <= zoom_max; i++) {
151 memset(temp_dst, 0,
sizeof(*temp_dst));
152 byte *dst = temp_dst->
data;
155 for (
ZoomLevel i = zoom_min; i <= zoom_max; i++) {
157 uint offset = dst - temp_dst->
data;
158 temp_dst->
offset[i] = offset;
161 int scaled_height = sprite[i].
height;
162 int scaled_width = sprite[i].
width;
164 for (
int y = 0; y < scaled_height; y++) {
167 uint last_colour = 0;
168 byte *count_dst =
nullptr;
173 for (
int x = 0; x < scaled_width; x++) {
174 uint colour = src++->
m;
176 if (last_colour == 0 || colour == 0 || pixels == 255) {
177 if (count_dst !=
nullptr) {
184 if (colour == 0 && trans != 255) {
197 last_colour = colour;
207 if (count_dst !=
nullptr) *count_dst = pixels;
215 uint size = dst - (
byte *)temp_dst;
218 assert(size < memory);
221 Sprite *dest_sprite = (
Sprite *)allocator(
sizeof(*dest_sprite) + size);
227 memcpy(dest_sprite->
data, temp_dst, size);
Sprite * Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override
Convert a sprite from the loader to our own format.
Data stored about a (single) sprite.
@ ST_FONT
A sprite used for fonts.
A reusable buffer that can be used for places that temporary allocate a bit of memory and do that ver...
uint32 offset[ZOOM_LVL_COUNT]
Offsets (from .data) to streams for different zoom levels.
int top
The top offset in the 'dst' in pixels to start drawing.
@ BM_TRANSPARENT
Perform transparency colour remapping.
int skip_left
How much pixels of the source to skip on the left (based on zoom of dst)
BlitterMode
The modes of blitting we can do.
int width
The width in pixels that needs to be drawn to dst.
void * dst
Destination buffer.
uint16 height
Height of the sprite.
int16 x_offs
Number of pixels to shift the sprite to the right.
ZoomLevel
All zoom levels we know.
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override
Draw an image to the screen, given an amount of params defined above.
int pitch
The pitch of the destination buffer.
ClientSettings _settings_client
The current settings for this game.
@ ZOOM_LVL_MAX
Maximum zoom level.
T * Allocate(size_t count)
Get buffer of at least count times T.
static void MemCpyT(T *destination, const T *source, size_t num=1)
Type-safe version of memcpy().
ZoomLevel zoom_max
maximum zoom out level
SpriteLoader::CommonPixel * data
The sprite itself.
const void * sprite
Pointer to the sprite how ever the encoder stored it.
static FBlitter_8bppOptimized iFBlitter_8bppOptimized
Instantiation of the 8bpp optimised blitter factory.
SpriteType type
The sprite type.
@ BM_COLOUR_REMAP
Perform a colour remapping.
Definition of a common pixel in OpenTTD's realm.
Factory for the 8bpp blitter optimised for speed.
@ BM_CRASH_REMAP
Perform a crash remapping.
uint16 width
Width of the sprite.
int16 x_offs
The x-offset of where the sprite will be drawn.
@ BM_BLACK_REMAP
Perform remapping to a completely blackened sprite.
ZoomLevel zoom_min
minimum zoom out level
uint16 width
Width of the sprite.
int left
The left offset in the 'dst' in pixels to start drawing.
byte data[]
Data, all zoomlevels.
int16 y_offs
Number of pixels to shift the sprite downwards.
Structure for passing information from the sprite loader to the blitter.
Parameters related to blitting.
static void MemSetT(T *ptr, byte value, size_t num=1)
Type-safe version of memset().
@ ZOOM_LVL_NORMAL
The normal zoom level.
int height
The height in pixels that needs to be drawn to dst.
int16 y_offs
The y-offset of where the sprite will be drawn.
uint16 height
Height of the sprite.
int skip_top
How much pixels of the source to skip on the top (based on zoom of dst)
Data structure describing a sprite.
const byte * remap
XXX – Temporary storage for remap array.
GUISettings gui
settings related to the GUI