2 // "$Id: Fl_XBM_Image.cxx 7903 2010-11-28 21:06:39Z matt $"
4 // Fl_XBM_Image routines.
6 // Copyright 1997-2010 by Bill Spitzak and others.
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
29 // Fl_XBM_Image::Fl_XBM_Image() - Load an XBM file.
33 // Include necessary header files...
37 #include <FL/Fl_XBM_Image.H>
40 #include <FL/fl_utf8.h>
44 // 'Fl_XBM_Image::Fl_XBM_Image()' - Load an XBM file.
48 The constructor loads the named XBM file from the given name filename.
49 <P>The destructor free all memory and server resources that are used by
52 Fl_XBM_Image::Fl_XBM_Image(const char *name
) : Fl_Bitmap((const char *)0,0,0) {
56 if ((f
= fl_fopen(name
, "rb")) == NULL
) return;
60 int wh
[2]; // width and height
62 for (i
= 0; i
<2; i
++) {
64 if (!fgets(buffer
,1024,f
)) {
68 int r
= sscanf(buffer
,"#define %s %d",junk
,&wh
[i
]);
73 // skip to data array:
75 if (!fgets(buffer
,1024,f
)) {
79 if (!strncmp(buffer
,"static ",7)) break;
86 int n
= ((wh
[0]+7)/8)*wh
[1];
90 for (i
= 0, ptr
= (uchar
*)array
; i
< n
;) {
91 if (!fgets(buffer
,1024,f
)) {
95 const char *a
= buffer
;
98 if (sscanf(a
," 0x%x",&t
)>0) {
102 while (*a
&& *a
++ != ',');
111 // End of "$Id: Fl_XBM_Image.cxx 7903 2010-11-28 21:06:39Z matt $".