axle OS
x86_32 UNIX-like hobby OS
src
user
programs
jpeg.h
1
#ifndef _NANOJPEG_H
2
#define _NANOJPEG_H
3
4
// nj_result_t: Result codes for njDecode().
5
typedef
enum
_nj_result {
6
NJ_OK = 0,
// no error, decoding successful
7
NJ_NO_JPEG,
// not a JPEG file
8
NJ_UNSUPPORTED,
// unsupported format
9
NJ_OUT_OF_MEM,
// out of memory
10
NJ_INTERNAL_ERR,
// internal error
11
NJ_SYNTAX_ERROR,
// syntax error
12
__NJ_FINISHED,
// used internally, will never be reported
13
} nj_result_t;
14
15
// njInit: Initialize NanoJPEG.
16
// For safety reasons, this should be called at least one time before using
17
// using any of the other NanoJPEG functions.
18
void
njInit(
void
);
19
20
// njDecode: Decode a JPEG image.
21
// Decodes a memory dump of a JPEG file into internal buffers.
22
// Parameters:
23
// jpeg = The pointer to the memory dump.
24
// size = The size of the JPEG file.
25
// Return value: The error code in case of failure, or NJ_OK (zero) on success.
26
nj_result_t njDecode(
const
void
* jpeg,
const
int
size
);
27
28
// njGetWidth: Return the width (in pixels) of the most recently decoded
29
// image. If njDecode() failed, the result of njGetWidth() is undefined.
30
int
njGetWidth(
void
);
31
32
// njGetHeight: Return the height (in pixels) of the most recently decoded
33
// image. If njDecode() failed, the result of njGetHeight() is undefined.
34
int
njGetHeight(
void
);
35
36
// njIsColor: Return 1 if the most recently decoded image is a color image
37
// (RGB) or 0 if it is a grayscale image. If njDecode() failed, the result
38
// of njGetWidth() is undefined.
39
int
njIsColor(
void
);
40
41
// njGetImage: Returns the decoded image data.
42
// Returns a pointer to the most recently image. The memory layout it byte-
43
// oriented, top-down, without any padding between lines. Pixels of color
44
// images will be stored as three consecutive bytes for the red, green and
45
// blue channels. This data format is thus compatible with the PGM or PPM
46
// file formats and the OpenGL texture formats GL_LUMINANCE8 or GL_RGB8.
47
// If njDecode() failed, the result of njGetImage() is undefined.
48
unsigned
char
* njGetImage(
void
);
49
50
// njGetImageSize: Returns the size (in bytes) of the image data returned
51
// by njGetImage(). If njDecode() failed, the result of njGetImageSize() is
52
// undefined.
53
int
njGetImageSize(
void
);
54
55
// njDone: Uninitialize NanoJPEG.
56
// Resets NanoJPEG's internal state and frees all memory that has been
57
// allocated at run-time by NanoJPEG. It is still possible to decode another
58
// image after a njDone() call.
59
void
njDone(
void
);
60
61
#endif//_NANOJPEG_H
size
Definition:
size.h:4
Generated by
1.8.14