Debian Codegraph @

xo/lpicture.h

raw
1 /* lpicture.h -*- C++ -*-
2 $Id: lpicture.h,v 1.2 1997/10/18 04:57:37 elf Exp $
3
4 written by Marc Singer
5 3 Jun 1997
6
7 This file is part of the project XO. See the file README for
8 more information.
9
10 Copyright (C) 1997 Marc Singer
11
12 This program is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation; either version 2 of the
15 License, or (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 in a file called COPYING along with this program; if not, write to
24 the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
25 02139, USA.
26
27 -----------
28 DESCRIPTION
29 -----------
30
31 Helper structures and procedures for working with pictures. The
32 primary motivation for this stuff is to allow us to handle varying
33 formats without putting them into a windowing system specific data
34 structure.
35
36 */
37
38 #if !defined (__LPICTURE_H__)
39 # define __LPICTURE_H__
40
41 /* ----- Includes */
42
43 #include "memory.h"
44
45
46 /* ----- Class */
47
48 typedef struct {
49 unsigned8 rgbBlue;
50 unsigned8 rgbGreen;
51 unsigned8 rgbRed;
52 unsigned8 rgbReserved;
53 } RGBQUAD; // MS Windows palette structure
54
55 class LPicture {
56 protected:
57 void _calc_stride (void) {
58 m_cbStride = (((m_width*m_depth)/8 + 3)& ~0x3); }
59
60 public:
61 int m_width;
62 int m_height;
63 int m_depth; // Depth of image, probably 1, 8, 16, or 24
64 bool m_fNonNormal; // Normal is top-down scanline order
65 int m_cColors; // Number of colors in the palette, 0 for none
66 int m_cbStride; // Width of one scanline
67
68 void* m_pvMap; // Location where file is mapped into memory
69 int m_cbMap; // Length of mapping
70 int m_fh; // File handle used in mapping
71
72 void* m_pv; // Pointer to the bits
73 int m_cb; // Size of region holding the bitmap
74
75 RGBQUAD* m_rgRGB; // Pointer to palette, if there is one
76
77 bool read (const char* szPath);
78
79 LPicture () {
80 zero (); }
81 ~LPicture () {
82 release_this (); }
83 void release_mmap (void);
84 void release_this (void);
85 void zero (void) {
86 memset (this, 0, sizeof (*this)); }
87
88 };
89
90
91
92
93 #endif /* __LPICTURE_H__ */