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 | #include "config.h" |
---|
11 | |
---|
12 | #include "image.hpp" |
---|
13 | |
---|
14 | /* image-24.cpp : a 24-bit implementation of the image class */ |
---|
15 | |
---|
16 | // |
---|
17 | // Constructor |
---|
18 | // |
---|
19 | image::image( short width, short height, unsigned char *page_buffer, short create_descriptor ) |
---|
20 | { |
---|
21 | w = width; |
---|
22 | h = height; |
---|
23 | |
---|
24 | if( create_descriptor || page_buffer ) |
---|
25 | { |
---|
26 | if( create_descriptor == 2 ) |
---|
27 | { |
---|
28 | special = new image_descriptor( width, height, 1, ( page_buffer != NULL ) ); |
---|
29 | } |
---|
30 | else |
---|
31 | { |
---|
32 | special = new image_descriptor( width, height, 0, ( page_buffer != NULL ) ); |
---|
33 | } |
---|
34 | } |
---|
35 | else |
---|
36 | { |
---|
37 | special = NULL; |
---|
38 | } |
---|
39 | |
---|
40 | make_page( width, height, page_buffer ); |
---|
41 | image_list.add_end( (linked_node *)this ); |
---|
42 | } |
---|
43 | |
---|
44 | // |
---|
45 | // Constructor |
---|
46 | // |
---|
47 | image::image( spec_entry *e, bFILE *fp ) |
---|
48 | { |
---|
49 | short ii; |
---|
50 | |
---|
51 | fp->seek( e->offset, 0 ); |
---|
52 | w = fp->read_short(); |
---|
53 | h = fp->read_short(); |
---|
54 | special = NULL; |
---|
55 | make_page( w, h, NULL ); |
---|
56 | |
---|
57 | for( ii = 0; ii < h; ii++ ) |
---|
58 | { |
---|
59 | fp->read( scan_line( ii ), w ); |
---|
60 | } |
---|
61 | |
---|
62 | image_list.add_end( (linked_node *)this ); |
---|
63 | } |
---|
64 | |
---|
65 | // |
---|
66 | // Constructor |
---|
67 | // |
---|
68 | image::image( bFILE *fp ) |
---|
69 | { |
---|
70 | short ii; |
---|
71 | |
---|
72 | w = fp->read_short(); |
---|
73 | h = fp->read_short(); |
---|
74 | special = NULL; |
---|
75 | make_page( w, h, NULL ); |
---|
76 | |
---|
77 | for( ii = 0; ii < h; ii++ ) |
---|
78 | { |
---|
79 | fp->read( scan_line( ii ), w ); |
---|
80 | } |
---|
81 | |
---|
82 | image_list.add_end( (linked_node *)this ); |
---|
83 | } |
---|
84 | |
---|
85 | // |
---|
86 | // Destructor |
---|
87 | // |
---|
88 | image::~image() |
---|
89 | { |
---|
90 | image_list.unlink( (linked_node *)this ); |
---|
91 | delete_page(); |
---|
92 | if( special ) |
---|
93 | { |
---|
94 | delete special; |
---|
95 | } |
---|
96 | } |
---|
97 | |
---|
98 | // |
---|
99 | // total_pixels |
---|
100 | // |
---|
101 | long image::total_pixels( unsigned char background ) |
---|
102 | { |
---|
103 | short ii, jj; |
---|
104 | long count; |
---|
105 | unsigned char *c; |
---|
106 | |
---|
107 | count = 0; |
---|
108 | for( ii = height() - 1; ii >= 0; ii-- ) |
---|
109 | { |
---|
110 | c = scan_line( ii ); |
---|
111 | for( jj = width() - 1; j >= 0; jj--, c++ ) |
---|
112 | { |
---|
113 | if( *c != background ) |
---|
114 | { |
---|
115 | count++; |
---|
116 | } |
---|
117 | } |
---|
118 | } |
---|
119 | |
---|
120 | return count; |
---|
121 | } |
---|
122 | |
---|
123 | // |
---|
124 | // clear |
---|
125 | // |
---|
126 | void image::clear( short color ) |
---|
127 | { |
---|
128 | |
---|
129 | } |
---|
130 | |
---|