FireBirdLib - Topfield TMS PVR TAP Programming Library
BMP_WriteHeader.c
Go to the documentation of this file.
1
#include <unistd.h>
2
#include "
FBLib_av.h
"
3
#include "
libFireBird.h
"
4
5
void
BMP_WriteHeader
(
int
FileHandle,
int
width,
int
height)
6
{
7
TRACEENTER
();
8
9
struct
BMP_HEAD
head;
10
struct
BMP_INFO
info;
11
dword i, size, rowlength;
12
13
if
(FileHandle <= 0)
14
{
15
TRACEEXIT
();
16
return
;
17
}
18
19
// according to spec.: the rowlength must be a multiple of 4 bytes, if necessary fill up with zero-bytes
20
rowlength = (
width
*3%4==0) ?
width
*3 : ((
width
*3/4)+1)*4;
21
22
size =
sizeof
( head ) +
sizeof
( info ) + rowlength*
height
;
23
24
head.
id
[0] =
'B'
;
25
head.
id
[1] =
'M'
;
26
head.
size_l
=
LE16
( (size & 0xffff) );
27
head.
size_h
=
LE16
( (size >> 16) );
28
i = (
sizeof
( head ) +
sizeof
( info ));
29
head.
offset_l
=
LE16
( i & 0xffff );
30
head.
offset_h
=
LE16
( i >> 16 );
31
32
info.
info_size
=
LE32
( 40 );
33
info.
width
=
LE32
(
width
);
34
info.
height
=
LE32
(
height
);
35
info.
plane
=
LE16
( 1 );
36
info.
bits_per_pixel
=
LE16
( 24 );
37
info.
compress
=
LE32
( 0 );
38
info.
img_size
=
LE32
( rowlength*
height
);
39
info.
x_res
= 0;
40
info.
y_res
= 0;
41
info.
color
= 0;
42
info.
icolor
= 0;
43
44
write(FileHandle, &head,
sizeof
(head));
45
write(FileHandle, &info,
sizeof
(info));
46
47
TRACEEXIT
();
48
}
BMP_WriteHeader
void BMP_WriteHeader(int FileHandle, int width, int height)
Definition:
BMP_WriteHeader.c:5
FBLib_av.h
libFireBird.h
LE32
#define LE32(p)
Definition:
libFireBird.h:164
TRACEEXIT
#define TRACEEXIT()
Definition:
libFireBird.h:1244
TRACEENTER
#define TRACEENTER()
Definition:
libFireBird.h:1243
LE16
#define LE16(p)
Definition:
libFireBird.h:163
BMP_HEAD
Definition:
libFireBird.h:250
BMP_HEAD::offset_h
word offset_h
Definition:
libFireBird.h:256
BMP_HEAD::id
byte id[2]
Definition:
libFireBird.h:251
BMP_HEAD::offset_l
word offset_l
Definition:
libFireBird.h:255
BMP_HEAD::size_h
word size_h
Definition:
libFireBird.h:253
BMP_HEAD::size_l
word size_l
Definition:
libFireBird.h:252
BMP_INFO
Definition:
libFireBird.h:260
BMP_INFO::height
long height
Definition:
libFireBird.h:263
BMP_INFO::compress
long compress
Definition:
libFireBird.h:266
BMP_INFO::plane
word plane
Definition:
libFireBird.h:264
BMP_INFO::img_size
long img_size
Definition:
libFireBird.h:267
BMP_INFO::icolor
long icolor
Definition:
libFireBird.h:271
BMP_INFO::color
long color
Definition:
libFireBird.h:270
BMP_INFO::width
long width
Definition:
libFireBird.h:262
BMP_INFO::bits_per_pixel
word bits_per_pixel
Definition:
libFireBird.h:265
BMP_INFO::info_size
long info_size
Definition:
libFireBird.h:261
BMP_INFO::x_res
long x_res
Definition:
libFireBird.h:268
BMP_INFO::y_res
long y_res
Definition:
libFireBird.h:269
av
BMP_WriteHeader.c
Generated on Fri Apr 29 2022 13:34:00 for FireBirdLib - Topfield TMS PVR TAP Programming Library by
1.9.3