source: abuse/trunk/src/imlib/image24.hpp @ 129

Last change on this file since 129 was 129, checked in by Sam Hocevar, 14 years ago
  • Get rid of jmalloc and replace it with standard malloc. Modern operating systems certainly perform a lot better than this custom implementation, and we have superior tools (eg. valgrind) to debug and profile memory usage without interfering with the code itself.
File size: 1.4 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *
5 *  This software was released into the Public Domain. As with most public
6 *  domain software, no warranty is made or implied by Crack dot Com or
7 *  Jonathan Clark.
8 */
9
10#ifndef __IMAGE_24__
11#define __IMAGE_24__
12
13#include "palette.hpp"
14#include "macs.hpp"
15#include "filter.hpp"
16
17class image24
18{
19  int w,h;
20  unsigned char *data;
21public :
22  int width() { return w; }
23  int height() { return h; }
24  image24(unsigned short width, unsigned short height,
25          unsigned char *buffer=NULL);
26  void pixel(short x, short y, unsigned char &r,
27                               unsigned char &g,
28                   unsigned char &b)
29    { CHECK(x>=0 && y>=0 && x<w && y<h);
30      unsigned char *p=data+y*w*3; r=*(p++); g=*(p++); b=*(p++); }
31  void putpixel(short x, short y, unsigned char r,
32                  unsigned char g,
33                      unsigned char b)
34    { CHECK(x>=0 && y>=0 && x<w && y<h);
35      unsigned char *p=data+(y*w+x)*3; *(p++)=r; *(p++)=g; *(p++)=b; }
36  unsigned char *scan_line(short y) { return data+y*w*3; }
37  image *dither(palette *pal);
38  void           clear              (unsigned char r=0, unsigned char g=0,
39                                unsigned char b=0);
40  void add_error(int x, int y, int r_error, int g_error, int b_error, int error_mult);
41  ~image24() { free(data); }
42} ;
43
44
45#endif
46
Note: See TracBrowser for help on using the repository browser.