fltk
1.3.5-source
About:
FLTK
(Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X.
Fossies
Dox
:
fltk-1.3.5-source.tar.bz2
("inofficial" and yet experimental doxygen-generated source code documentation)
Fl_XBM_Image.cxx
Go to the documentation of this file.
1
//
2
// "$Id$"
3
//
4
// Fl_XBM_Image routines.
5
//
6
// Copyright 1997-2016 by Bill Spitzak and others.
7
//
8
// This library is free software. Distribution and use rights are outlined in
9
// the file "COPYING" which should have been included with this file. If this
10
// file is missing or damaged, see the license at:
11
//
12
// http://www.fltk.org/COPYING.php
13
//
14
// Please report all bugs and problems on the following page:
15
//
16
// http://www.fltk.org/str.php
17
//
18
// Contents:
19
//
20
// Fl_XBM_Image::Fl_XBM_Image() - Load an XBM file.
21
//
22
23
//
24
// Include necessary header files...
25
//
26
27
#include <
FL/Fl.H
>
28
#include <
FL/Fl_XBM_Image.H
>
29
#include <stdio.h>
30
#include <stdlib.h>
31
#include <
FL/fl_utf8.h
>
32
#include "
flstring.h
"
33
34
//
35
// 'Fl_XBM_Image::Fl_XBM_Image()' - Load an XBM file.
36
//
37
44
Fl_XBM_Image::Fl_XBM_Image
(
const
char
*
name
) :
Fl_Bitmap
((
const
char *)0,0,0) {
45
FILE *
f
;
46
uchar
*ptr;
47
48
if
((
f
=
fl_fopen
(
name
,
"rb"
)) ==
NULL
)
return
;
49
50
char
buffer
[1024];
51
char
junk[1024];
52
int
wh[2];
// width and height
53
int
i;
54
for
(i = 0; i<2; i++) {
55
for
(;;) {
56
if
(!fgets(
buffer
,1024,
f
)) {
57
fclose(
f
);
58
return
;
59
}
60
int
r = sscanf(
buffer
,
"#define %s %d"
,junk,&wh[i]);
61
if
(r >= 2)
break
;
62
}
63
}
64
65
// skip to data array:
66
for
(;;) {
67
if
(!fgets(
buffer
,1024,
f
)) {
68
fclose(
f
);
69
return
;
70
}
71
if
(!strncmp(
buffer
,
"static "
,7))
break
;
72
}
73
74
// Allocate memory...
75
w
(wh[0]);
76
h
(wh[1]);
77
78
int
n = ((wh[0]+7)/8)*wh[1];
79
array
=
new
uchar
[n];
80
81
// read the data:
82
for
(i = 0, ptr = (
uchar
*)
array
; i < n;) {
83
if
(!fgets(
buffer
,1024,
f
)) {
84
fclose(
f
);
85
return
;
86
}
87
const
char
*a =
buffer
;
88
while
(*a && i<n) {
89
unsigned
int
t;
90
if
(sscanf(a,
" 0x%x"
,&t)>0) {
91
*ptr++ = (
uchar
)t;
92
i ++;
93
}
94
while
(*a && *a++ !=
','
) {
/*empty*/
}
95
}
96
}
97
98
fclose(
f
);
99
}
100
101
102
//
103
// End of "$Id$".
104
//
Fl.H
Fl_Bitmap::array
const uchar * array
Definition:
Fl_Bitmap.H:41
NULL
#define NULL
Definition:
forms.H:34
Fl_XBM_Image::Fl_XBM_Image
Fl_XBM_Image(const char *filename)
Definition:
Fl_XBM_Image.cxx:44
fl_fopen
FILE * fl_fopen(const char *f, const char *mode)
Definition:
fl_utf8.cxx:498
buffer
static char * buffer
Definition:
file.cxx:215
Fl_Bitmap
Definition:
Fl_Bitmap.H:33
fl_utf8.h
header for Unicode and UTF-8 character handling
Fl_Image::h
int h() const
Definition:
Fl_Image.H:115
Fl_XBM_Image.H
Fl_Image::w
int w() const
Definition:
Fl_Image.H:111
f
Fl_Box_Draw_F * f
Definition:
fl_boxtype.cxx:285
flstring.h
uchar
unsigned char uchar
Definition:
fl_types.h:30
name
static const char * name
Definition:
Fl_arg.cxx:53
const
#define const
Definition:
zconf.h:226
src
Fl_XBM_Image.cxx
Generated by
1.8.16