source: abuse/trunk/src/imlib/image-24.cpp @ 2

Last change on this file since 2 was 2, checked in by Sam Hocevar, 18 years ago
  • imported original 0.7.0 tarball
File size: 1.7 KB
RevLine 
[2]1/* image-24.cpp : a 24-bit implementation of the image class */
2
3#include "image.hpp"
4
5//
6// Constructor
7//
8image::image( short width, short height, unsigned char *page_buffer, short create_descriptor )
9{
10        w = width;
11        h = height;
12
13        if( create_descriptor || page_buffer )
14        {
15                if( create_descriptor == 2 )
16                {
17                        special = new image_descriptor( width, height, 1, ( page_buffer != NULL ) );
18                }
19                else
20                {
21                        special = new image_descriptor( width, height, 0, ( page_buffer != NULL ) );
22                }
23        }
24        else
25        {
26                special = NULL;
27        }
28
29        make_page( width, height, page_buffer );
30        image_list.add_end( (linked_node *)this );
31}
32
33//
34// Constructor
35//
36image::image( spec_entry *e, bFILE *fp )
37{
38        short ii;
39
40        fp->seek( e->offset, 0 );
41        w = fp->read_short();
42        h = fp->read_short();
43        special = NULL;
44        make_page( w, h, NULL );
45
46        for( ii = 0; ii < h; ii++ )
47        {
48                fp->read( scan_line( ii ), w );
49        }
50
51        image_list.add_end( (linked_node *)this );
52}
53
54//
55// Constructor
56//
57image::image( bFILE *fp )
58{
59        short ii;
60
61        w = fp->read_short();
62        h = fp->read_short();
63        special = NULL;
64        make_page( w, h, NULL );
65
66        for( ii = 0; ii < h; ii++ )
67        {
68                fp->read( scan_line( ii ), w );
69        }
70
71        image_list.add_end( (linked_node *)this );
72}
73
74//
75// Destructor
76//
77image::~image()
78{
79        image_list.unlink( (linked_node *)this );
80        delete_page();
81        if( special )
82        {
83                delete special;
84        }
85}
86
87//
88// total_pixels
89//
90long image::total_pixels( unsigned char background )
91{
92        short ii, jj;
93        long count;
94        unsigned char *c;
95
96        count = 0;
97        for( ii = height() - 1; ii >= 0; ii-- )
98        {
99                c = scan_line( ii );
100                for( jj = width() - 1; j >= 0; jj--, c++ )
101                {
102                        if( *c != background )
103                        {
104                                count++;
105                        }
106                }
107        }
108
109        return count;
110}
111
112//
113// clear
114//
115void image::clear( short color )
116{
117       
118}
119
Note: See TracBrowser for help on using the repository browser.