source: golgotha/src/i4/image/image.hh @ 608

Last change on this file since 608 was 80, checked in by Sam Hocevar, 15 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 4.1 KB
Line 
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#ifndef __I4IMAGE_HPP_
10#define __I4IMAGE_HPP_
11
12
13class i4_pal;
14class i4_rect_list_class;
15class i4_draw_context_class;
16
17#include "arch.hh"
18
19
20class i4_image_class
21
22public:
23  const i4_pal *pal;
24  // raw data,
25  // depends on pal.pal->source.pixel_depth==(I4_32BIT,I4_16BIT,I4_8BIT,I4_4BIT,I4_2BIT)
26  void *data; 
27  int w, h, bpl;
28  i4_bool dont_free_data;
29 
30  const i4_pal *get_pal() { return pal; }
31  void set_pal(const i4_pal *which) { pal=which; }
32
33
34  w16 width() { return w; }
35  virtual w16 height() { return h; }
36
37  // these do color conversion to & from 32bit
38  virtual i4_color get_pixel(i4_coord x, i4_coord y)                                  = 0;
39  virtual void put_pixel(i4_coord x, i4_coord y, w32 color)                           = 0;
40
41  // put pixel does clipping and window offset moving and then calls put_pixel(x,y,c)
42  void put_pixel(i4_coord x, i4_coord y, w32 color, i4_draw_context_class &context);
43 
44  w32  get_pixel(i4_coord x, i4_coord y,  i4_draw_context_class &context);
45
46  virtual void xor_bar(i4_coord x1, i4_coord y1,
47                       i4_coord x2, i4_coord y2,
48                       i4_color xor_color, i4_draw_context_class &context);
49
50  virtual void bar(i4_coord x1,    i4_coord y1,
51                   i4_coord x2,    i4_coord y2,
52                   i4_color color, i4_draw_context_class &context);
53
54  virtual void line(i4_coord x1, i4_coord y1,
55                    i4_coord x2, i4_coord y2,
56                    i4_color color, i4_draw_context_class &context);
57
58  void add_single_dirty(i4_coord x1, i4_coord y1, i4_coord x2,
59                        i4_coord y2, i4_draw_context_class &context);
60 
61  void add_dirty(i4_coord x1, i4_coord y1, i4_coord x2,
62                 i4_coord y2, i4_draw_context_class &context);
63
64 
65  //{ put_part :
66  //  put_part transfers a rectanguar image of yourself to location x,y on image 'to'
67  virtual void put_part(i4_image_class *to,
68                        i4_coord x,  i4_coord y,                             
69                        i4_coord x1, i4_coord y1, i4_coord x2, i4_coord y2,
70                        i4_draw_context_class &context);
71
72  virtual void put_part_trans(i4_image_class *to,
73                              i4_coord x,  i4_coord y,                                 
74                              i4_coord x1, i4_coord y1, i4_coord x2, i4_coord y2,
75                              i4_color trans_color, i4_draw_context_class &context);
76
77  // copy is not expanded by the image template, it needs to be implemented per image
78  virtual i4_image_class *copy();
79
80  // Non-virtual functions, these are implemented as a convience
81  // not as a primative to be derived from
82  void put_image(i4_image_class *to, i4_coord x, i4_coord y, i4_draw_context_class &context)
83  { put_part(to,x,y,0,0,width()-1,height()-1,context); }
84
85  void put_image_trans(i4_image_class *to,
86                       i4_coord x, i4_coord y, i4_color trans_color,
87                       i4_draw_context_class &context)
88  { put_part_trans(to,x,y,0,0,width()-1,height()-1,trans_color,context); }
89
90  virtual void clear(i4_color color, i4_draw_context_class &context)
91  { bar(0,0,width()-1,height()-1,color,context); }
92
93  virtual void rectangle(i4_coord x1, i4_coord y1, i4_coord x2, i4_coord y2, i4_color color,
94                         i4_draw_context_class &context);
95
96  i4_image_class() { dont_free_data=i4_F; }
97  virtual ~i4_image_class() { ; }
98};
99
100i4_image_class *i4_create_image(int width, int height, const i4_pal *pal);
101
102i4_image_class *i4_create_image(int width, int height,
103                                const i4_pal *pal,
104                                void *data,
105                                int bytes_per_line);
106
107#endif
Note: See TracBrowser for help on using the repository browser.