1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #include "image/image8.hh"
|
---|
10 | #include "memory/malloc.hh"
|
---|
11 | #include "palette/pal.hh"
|
---|
12 |
|
---|
13 | #include <string.h>
|
---|
14 |
|
---|
15 |
|
---|
16 |
|
---|
17 | i4_color i4_image8::get_pixel(i4_coord x, i4_coord y)
|
---|
18 | {
|
---|
19 | return i4_pal_man.convert_to_32(*(typed_data() + bpl*y + x), pal);
|
---|
20 | }
|
---|
21 |
|
---|
22 | void i4_image8::put_pixel(i4_coord x, i4_coord y, w32 color)
|
---|
23 | {
|
---|
24 | *(typed_data() + bpl*y + x)=i4_pal_man.convert_32_to(color, &pal->source);
|
---|
25 | }
|
---|
26 |
|
---|
27 |
|
---|
28 | i4_image8::i4_image8(w16 _w, w16 _h, const i4_pal *_pal)
|
---|
29 | {
|
---|
30 | w=_w;
|
---|
31 | h=_h;
|
---|
32 | bpl=_w;
|
---|
33 | set_pal(_pal);
|
---|
34 | data=i4_malloc(w*h,"");
|
---|
35 | }
|
---|
36 |
|
---|
37 | i4_image8::i4_image8(w16 _w, w16 _h, const i4_pal *_pal,
|
---|
38 | void *_data, int _bpl)
|
---|
39 | {
|
---|
40 | data=_data;
|
---|
41 | bpl=_bpl;
|
---|
42 | pal=_pal;
|
---|
43 | w=_w;
|
---|
44 | h=_h;
|
---|
45 |
|
---|
46 | dont_free_data=i4_T;
|
---|
47 | }
|
---|
48 |
|
---|
49 |
|
---|
50 | i4_image8::~i4_image8()
|
---|
51 | {
|
---|
52 | if (!dont_free_data)
|
---|
53 | i4_free(data);
|
---|
54 | }
|
---|
55 |
|
---|
56 |
|
---|
57 | i4_image_class *i4_image8::copy()
|
---|
58 | {
|
---|
59 | i4_image_class *im=i4_create_image(width(), height(), pal);
|
---|
60 |
|
---|
61 |
|
---|
62 | for (int y=0; y<h; y++)
|
---|
63 | memcpy(((w8 *)im->data) + y*im->bpl,
|
---|
64 | ((w8 *)data) + y*bpl,
|
---|
65 | w);
|
---|
66 |
|
---|
67 | return im;
|
---|
68 | }
|
---|