-
Notifications
You must be signed in to change notification settings - Fork 3
/
ioimage.h
60 lines (50 loc) · 2.43 KB
/
ioimage.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
/**
*@author Wanlei Zhao
*@version 1.0
*All rights reserved by Wanlei Zhao
*
*Anyone receive this code should not redistribute it to other people
*without permission of the author
*
*This code should only be used for non-commercial purpose
**/
#ifndef IOIMAGE_H
#define IOIMAGE_H
#include <iostream>
#include <fstream>
extern "C"
{
#include "./include/jpeglib.h"
#include <png.h>
}
using namespace std;
class IOImage
{
static const int PNG_BYTES_TO_CHECK = 8;
public:
IOImage();
static char *read_pgm(const char *fn, int &width, int &height,int *MaxVal);
static int write_pgm(const char *fn, const int w, const int h, const float* data, const unsigned char maxval,
const char* comment_string, const int channel);
static int write_pgm(const char *fn, const int w, const int h, const unsigned char*data, const unsigned char maxval,
const char* comment_string, const int channel);
static char *read_bmp(const char *fn, int &width, int &height,int *maxVal,const int channel);
static void write_bmp(const char *fn, const int w,const int h, const float*data,const int channel);
static void write_bmp(const char *fn, const int w, const int h, const unsigned char *body,const int channel);
static char *decmp_bmp(char *pbuffer, const int w, const int h, int *maxVal);
static char *read_jpg(const char *srcfn,int &w, int &h, int *MaxVal, const int channel);
static void write_jpg(const char *srcfn, const unsigned char *data, const int w,
const int h,const int ch, const int quality);
static void write_jpg(const char *srcfn, const float *data,const int w,
const int h, const int ch, const int quality);
static char *read_ppm(const char *srcfn, int &w, int &h, int *MaxVal, const int channel);
static void write_ppm(const char *srcfn, const unsigned char *data,const int w, const int h, const int ch);
static void write_ppm(const char *srcfn, const float *data,const int w, const int h, const int ch);
static char *read_png(const char *srcfn, int &w, int &h, int *maxVal, const int channel);
static void write_png(const char* srcfn, const int width, const int height, const char *data, const int ch);
static void write_png(const char* srcfn, const int width, const int height, const float *data, const int ch);
static void test();
static void testbmp();
virtual ~IOImage();
};
#endif