image.hh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. #ifndef __I4IMAGE_HPP_
  9. #define __I4IMAGE_HPP_
  10. class i4_pal;
  11. class i4_rect_list_class;
  12. class i4_draw_context_class;
  13. #include "arch.hh"
  14. class i4_image_class
  15. {
  16. public:
  17. const i4_pal *pal;
  18. // raw data,
  19. // depends on pal.pal->source.pixel_depth==(I4_32BIT,I4_16BIT,I4_8BIT,I4_4BIT,I4_2BIT)
  20. void *data;
  21. int w, h, bpl;
  22. i4_bool dont_free_data;
  23. const i4_pal *get_pal() { return pal; }
  24. void set_pal(const i4_pal *which) { pal=which; }
  25. w16 width() { return w; }
  26. virtual w16 height() { return h; }
  27. // these do color conversion to & from 32bit
  28. virtual i4_color get_pixel(i4_coord x, i4_coord y) = 0;
  29. virtual void put_pixel(i4_coord x, i4_coord y, w32 color) = 0;
  30. // put pixel does clipping and window offset moving and then calls put_pixel(x,y,c)
  31. void put_pixel(i4_coord x, i4_coord y, w32 color, i4_draw_context_class &context);
  32. w32 get_pixel(i4_coord x, i4_coord y, i4_draw_context_class &context);
  33. virtual void xor_bar(i4_coord x1, i4_coord y1,
  34. i4_coord x2, i4_coord y2,
  35. i4_color xor_color, i4_draw_context_class &context);
  36. virtual void bar(i4_coord x1, i4_coord y1,
  37. i4_coord x2, i4_coord y2,
  38. i4_color color, i4_draw_context_class &context);
  39. virtual void line(i4_coord x1, i4_coord y1,
  40. i4_coord x2, i4_coord y2,
  41. i4_color color, i4_draw_context_class &context);
  42. void add_single_dirty(i4_coord x1, i4_coord y1, i4_coord x2,
  43. i4_coord y2, i4_draw_context_class &context);
  44. void add_dirty(i4_coord x1, i4_coord y1, i4_coord x2,
  45. i4_coord y2, i4_draw_context_class &context);
  46. //{ put_part :
  47. // put_part transfers a rectanguar image of yourself to location x,y on image 'to'
  48. virtual void put_part(i4_image_class *to,
  49. i4_coord x, i4_coord y,
  50. i4_coord x1, i4_coord y1, i4_coord x2, i4_coord y2,
  51. i4_draw_context_class &context);
  52. virtual void put_part_trans(i4_image_class *to,
  53. i4_coord x, i4_coord y,
  54. i4_coord x1, i4_coord y1, i4_coord x2, i4_coord y2,
  55. i4_color trans_color, i4_draw_context_class &context);
  56. // copy is not expanded by the image template, it needs to be implemented per image
  57. virtual i4_image_class *copy();
  58. // Non-virtual functions, these are implemented as a convience
  59. // not as a primative to be derived from
  60. void put_image(i4_image_class *to, i4_coord x, i4_coord y, i4_draw_context_class &context)
  61. { put_part(to,x,y,0,0,width()-1,height()-1,context); }
  62. void put_image_trans(i4_image_class *to,
  63. i4_coord x, i4_coord y, i4_color trans_color,
  64. i4_draw_context_class &context)
  65. { put_part_trans(to,x,y,0,0,width()-1,height()-1,trans_color,context); }
  66. virtual void clear(i4_color color, i4_draw_context_class &context)
  67. { bar(0,0,width()-1,height()-1,color,context); }
  68. virtual void rectangle(i4_coord x1, i4_coord y1, i4_coord x2, i4_coord y2, i4_color color,
  69. i4_draw_context_class &context);
  70. i4_image_class() { dont_free_data=i4_F; }
  71. virtual ~i4_image_class() { ; }
  72. };
  73. i4_image_class *i4_create_image(int width, int height, const i4_pal *pal);
  74. i4_image_class *i4_create_image(int width, int height,
  75. const i4_pal *pal,
  76. void *data,
  77. int bytes_per_line);
  78. #endif