summaryrefslogtreecommitdiff
path: root/src/README
blob: 19b75e7736698db536914d8395a84b651355f1f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
NetSurf bitmap decoding library
===============================

The functions provided by this library allow for the decoding of
Microsoft's BMP and ICO image file formats.

READING BMP FILES
=================

To begin decoding a BMP, the caller should initialise a
'bmp_bitmap_callback_vt' structure with the appropriate values necessary
to handle bitmap images.  Next, a 'bmp_image' structure should be
initialised by calling bmp_create().  This structure should then be
passed to bmp_analyse() along with the BMP data to process and the size
of this data.

Once the analysis has begun, the decoder completes the width and height
variables.

To decode the image, the caller must use bmp_decode() which selects the
proper decoding method based on the BMP info header and assigns the
decoded bitmap image to the 'bitmap' member of the 'bmp_image'
structure.  The bitmap image is stored with 4 bytes-per-pixel in RGBA
format.

It should be noted that bmp_finalise() should always be called, even if
the image was never decoded.  It is also the responsibility of the
caller to free 'bmp_data'.

READING ICO FILES
=================

To begin decoding an ICO, the caller should initialise a
'bmp_bitmap_callback_vt' structure with the appropriate values necessary
to handle bitmap images.  Next, an 'ico_collection' structure should be
initialised by calling ico_create().  This structure should then be
passed to ico_analyse() along with the ICO data to process and the size
of this data.

Once the analysis has begun, the decoder completes the width and height
variables.  Because ICO collections contain multiple bitmap images, the
width and height will contain the values of the largest available image.

The caller then obtains a BMP from the ICO collection by calling
ico_find() with the requested width and height.

To decode the image, the caller must use bmp_decode() which selects the
proper decoding method based on the BMP info header and assigns the
decoded bitmap image to the 'bitmap' member of the 'bmp_image'
structure.  The bitmap image is stored with 4 bytes-per-pixel in RGBA
format.

It should be noted that ico_finalise() should always be called, even if
no images were decoded.  Because ico_finalise() calls bmp_finalise() for
each bitmap within the collection, the caller is not required to perform
this function.  However, it is the responsibility of the caller to free
'ico_data'.