annotate src/image.hh @ 1178:97b68213b58e

Added a limit for PNG image size
author Jorge Arellano Cid <jcid@dillo.org>
date Fri, 19 Jun 2009 13:11:36 -0400
parents 4d3828de8290
children f77f7973534e
rev   line source
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1 #ifndef __IMAGE_HH__
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
2 #define __IMAGE_HH__
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
3
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
4 // The DilloImage data-structure and methods
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
5
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
6
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
7 #ifdef __cplusplus
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
8 extern "C" {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
9 #endif /* __cplusplus */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
10
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
11
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
12 #include "bitvec.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
13 #include "url.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
14
1178
97b68213b58e Added a limit for PNG image size
Jorge Arellano Cid <jcid@dillo.org>
parents: 1084
diff changeset
15 /*
97b68213b58e Added a limit for PNG image size
Jorge Arellano Cid <jcid@dillo.org>
parents: 1084
diff changeset
16 * Defines
97b68213b58e Added a limit for PNG image size
Jorge Arellano Cid <jcid@dillo.org>
parents: 1084
diff changeset
17 */
97b68213b58e Added a limit for PNG image size
Jorge Arellano Cid <jcid@dillo.org>
parents: 1084
diff changeset
18
97b68213b58e Added a limit for PNG image size
Jorge Arellano Cid <jcid@dillo.org>
parents: 1084
diff changeset
19 /* Arbitrary maximum for image size (to avoid image size-crafting attacks). */
97b68213b58e Added a limit for PNG image size
Jorge Arellano Cid <jcid@dillo.org>
parents: 1084
diff changeset
20 #define IMAGE_MAX_W 6000
97b68213b58e Added a limit for PNG image size
Jorge Arellano Cid <jcid@dillo.org>
parents: 1084
diff changeset
21 #define IMAGE_MAX_H 6000
97b68213b58e Added a limit for PNG image size
Jorge Arellano Cid <jcid@dillo.org>
parents: 1084
diff changeset
22
97b68213b58e Added a limit for PNG image size
Jorge Arellano Cid <jcid@dillo.org>
parents: 1084
diff changeset
23
97b68213b58e Added a limit for PNG image size
Jorge Arellano Cid <jcid@dillo.org>
parents: 1084
diff changeset
24 /*
97b68213b58e Added a limit for PNG image size
Jorge Arellano Cid <jcid@dillo.org>
parents: 1084
diff changeset
25 * Types
97b68213b58e Added a limit for PNG image size
Jorge Arellano Cid <jcid@dillo.org>
parents: 1084
diff changeset
26 */
97b68213b58e Added a limit for PNG image size
Jorge Arellano Cid <jcid@dillo.org>
parents: 1084
diff changeset
27
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
28 typedef struct _DilloImage DilloImage;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
29
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
30 typedef enum {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
31 DILLO_IMG_TYPE_INDEXED,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
32 DILLO_IMG_TYPE_RGB,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
33 DILLO_IMG_TYPE_GRAY,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
34 DILLO_IMG_TYPE_NOTSET /* Initial value */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
35 } DilloImgType;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
36
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
37 /* These will reflect the Image's "state" */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
38 typedef enum {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
39 IMG_Empty, /* Just created the entry */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
40 IMG_SetParms, /* Parameters set */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
41 IMG_SetCmap, /* Color map set */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
42 IMG_Write, /* Feeding the entry */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
43 IMG_Close, /* Whole image got! */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
44 IMG_Abort /* Image transfer aborted */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
45 } ImageState;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
46
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
47 struct _DilloImage {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
48 void *dw;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
49
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
50 /* Parameters as told by image data */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
51 uint_t width;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
52 uint_t height;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
53
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
54 int32_t bg_color; /* Background color */
80
17f7b0db59ca Updated doc/Images.txt
jcid
parents: 0
diff changeset
55 bitvec_t *BitVec; /* Bit vector for decoded rows */
104
ed71c7b5ea92 - Added support for progressive display of progressive jpegs.
jcid
parents: 80
diff changeset
56 uint_t ScanNumber; /* Current decoding scan */
80
17f7b0db59ca Updated doc/Images.txt
jcid
parents: 0
diff changeset
57 ImageState State; /* Processing status */
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
58
80
17f7b0db59ca Updated doc/Images.txt
jcid
parents: 0
diff changeset
59 int RefCount; /* Reference counter */
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
60 };
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
61
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
62
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
63 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
64 * Function prototypes
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
65 */
1084
4d3828de8290 Cleanup in a_Image_new() signature
Jeremy Henty <onepoint@starurchin.org>
parents: 1055
diff changeset
66 DilloImage *a_Image_new(const char *alt_text, int32_t bg_color);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
67 void a_Image_ref(DilloImage *Image);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
68 void a_Image_unref(DilloImage *Image);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
69
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
70 void a_Image_set_parms(DilloImage *Image, void *v_imgbuf, DilloUrl *url,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
71 int version, uint_t width, uint_t height,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
72 DilloImgType type);
708
697145062347 imported patch dicache-cleanup3
Jorge Arellano Cid <jcid@dillo.org>
parents: 703
diff changeset
73 void a_Image_write(DilloImage *Image, uint_t y);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
74 void a_Image_close(DilloImage *Image);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
75
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
76
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
77 #ifdef __cplusplus
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
78 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
79 #endif /* __cplusplus */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
80
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
81 #endif /* __IMAGE_HH__ */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
82