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

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

imlib: merge almost all trans_image blit methods into one large template
function and refactor them for size.

  • 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  skip amount, data size, data  // no scan line wraps allowed
21
22*/
23
24
25class trans_image       // transpernet image
26{
27public:
28  trans_image(image *im, char const *name);  // name has no meaning if MEM_CHECK is off
29
30  inline vec2i Size() { return m_size; }
31  uint8_t *Data() { return m_data; }
32
33  void PutImage(image *screen, int x, int y); // always transparent
34  void PutRemap(image *screen, int x, int y, uint8_t *remap);
35  void PutDoubleRemap(image *screen, int x, int y,
36                      uint8_t *remap, uint8_t *remap2);
37  void PutFade(image *screen, int x, int y, int amount, int total_frames,
38               color_filter *f, palette *pal);
39  void PutFadeTint(image *screen, int x, int y, int amount, int total_frames,
40                   uint8_t *tint, color_filter *f, palette *pal);
41  void PutColor(image *screen, int x, int y, uint8_t color);
42  void PutFilled(image *screen, int x, int y, uint8_t color);
43  void PutPredator(image *screen, int x, int y);
44  void PutBlend(image *screen, int x, int y, image *blend, int bx, int by,
45                int blend_amount, color_filter *f, palette *pal);
46
47  // if screen x & y offset already calculated save a mul
48  // and no clipping, but fast use this
49  void put_image_offseted(image *screen, uint8_t *s_off);
50
51  void put_scan_line(image *screen, int x, int y, int line);   // always transparent
52  size_t MemUsage();
53  image *make_image();
54  ~trans_image();
55
56private:
57  uint8_t *ClipToLine(image *screen, int x1, int y1, int x2, int y2,
58                      int x, int &y, int &ysteps);
59
60  enum PutMode { NORMAL, REMAP, DOUBLE_REMAP, FADE, FADE_TINT, COLOR,
61                 FILLED, PREDATOR, BLEND };
62  template<int N>
63  void PutImageGeneric(image *dest, int x, int y, uint8_t color,
64                       image *blend, int bx, int by,
65                       uint8_t *map1, uint8_t *map2, int amount,
66                       int total_frames, uint8_t *tint,
67                       color_filter *f, palette *pal);
68
69  vec2i m_size;
70  uint8_t *m_data;
71};
72
73#endif
74
Note: See TracBrowser for help on using the repository browser.