source: abuse/trunk/src/imlib/timage.h @ 532

Last change on this file since 532 was 532, checked in by Sam Hocevar, 11 years ago

imlib: reimplement trans_image::put_scan_line so that it uses the
common template for all blitting functions.

  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *  Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
5 *
6 *  This software was released into the Public Domain. As with most public
7 *  domain software, no warranty is made or implied by Crack dot Com or
8 *  Jonathan Clark.
9 */
10
11#ifndef __TIMAGE_HPP__
12#define __TIMAGE_HPP__
13
14#include "image.h"
15#include "palette.h"
16#include "filter.h"
17
18/*  Data is stored in the following format:
19 *
20 *   uint8_t skip;       // transparent pixel count
21 *   uint8_t size;       // solid pixel count
22 *   uint8_t data[size]; // solid pixel values
23 *   ...
24 *   (no scan line wraps allowed, there can be a last skip value)
25 */
26
27class trans_image // transparent image
28{
29public:
30    trans_image(image *im, char const *name);
31    ~trans_image();
32
33    inline vec2i Size() { return m_size; }
34    inline uint8_t *Data() { return m_data; }
35
36    image *ToImage();
37
38    void PutImage(image *screen, int x, int y); // always transparent
39    void PutRemap(image *screen, int x, int y, uint8_t *remap);
40    void PutDoubleRemap(image *screen, int x, int y,
41                        uint8_t *remap, uint8_t *remap2);
42    void PutFade(image *screen, int x, int y, int amount, int total_frames,
43                 color_filter *f, palette *pal);
44    void PutFadeTint(image *screen, int x, int y, int amount, int total_frames,
45                     uint8_t *tint, color_filter *f, palette *pal);
46    void PutColor(image *screen, int x, int y, uint8_t color);
47    void PutFilled(image *screen, int x, int y, uint8_t color);
48    void PutPredator(image *screen, int x, int y);
49    void PutBlend(image *screen, int x, int y, image *blend, int bx, int by,
50                  int blend_amount, color_filter *f, palette *pal);
51    void PutScanLine(image *screen, int x, int y, int line);
52
53    size_t MemUsage();
54
55private:
56    uint8_t *ClipToLine(image *screen, int x1, int y1, int x2, int y2,
57                        int x, int &y, int &ysteps);
58
59    enum PutMode { NORMAL, REMAP, REMAP2, FADE, FADE_TINT, COLOR,
60                   FILLED, PREDATOR, BLEND, SCANLINE };
61    template<int N>
62    void PutImageGeneric(image *dest, int x, int y, uint8_t color,
63                         image *blend, int bx, int by,
64                         uint8_t *map1, uint8_t *map2, int amount,
65                         int total_frames, uint8_t *tint,
66                         color_filter *f, palette *pal);
67
68    vec2i m_size;
69    uint8_t *m_data;
70};
71
72#endif
73
Note: See TracBrowser for help on using the repository browser.