-
Notifications
You must be signed in to change notification settings - Fork 12
/
JPEGDecoder.h
76 lines (59 loc) · 1.7 KB
/
JPEGDecoder.h
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
JPEGDecoder.h
JPEG Decoder for Arduino
Public domain, Makoto Kurauchi <http://yushakobo.jp>
*/
#ifndef JPEGDECODER_H
#define JPEGDECODER_H
#include "picojpeg.h"
//#define DEBUG
//------------------------------------------------------------------------------
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
//------------------------------------------------------------------------------
typedef unsigned char uint8;
typedef unsigned int uint;
//------------------------------------------------------------------------------
class JPEGDecoder {
private:
File g_pInFile;
pjpeg_scan_type_t scan_type;
pjpeg_image_info_t image_info;
int is_available;
int mcu_x;
int mcu_y;
uint g_nInFileSize;
uint g_nInFileOfs;
uint row_pitch;
uint decoded_width, decoded_height;
uint row_blocks_per_mcu, col_blocks_per_mcu;
uint8 status;
uint8 reduce;
static uint8 pjpeg_callback(unsigned char* pBuf, unsigned char buf_size, unsigned char *pBytes_actually_read, void *pCallback_data);
uint8 pjpeg_need_bytes_callback(unsigned char* pBuf, unsigned char buf_size, unsigned char *pBytes_actually_read, void *pCallback_data);
int decode_mcu(void);
public:
uint8 *pImage;
JPEGDecoder *thisPtr;
int width;
int height;
int comps;
int MCUSPerRow;
int MCUSPerCol;
pjpeg_scan_type_t scanType;
int MCUWidth;
int MCUHeight;
int MCUx;
int MCUy;
JPEGDecoder();
~JPEGDecoder();
int decode(char* pFilename, unsigned char pReduce);
int available(void);
int read(void);
};
extern JPEGDecoder JpegDec;
#endif // JPEGDECODER_H