-
Notifications
You must be signed in to change notification settings - Fork 0
/
photonfile.h
97 lines (86 loc) · 2.27 KB
/
photonfile.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef PHOTONFILE_H
#define PHOTONFILE_H
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string.h>
#include <string>
#include <memory>
using namespace std;
#define PBSTR "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
#define PBWIDTH 60
typedef struct {
char header[8];
float bedX;
float bedY;
float bedZ;
int padding0[3];
float layerHeight;
float expTime;
float expBottom;
float offTime;
int bottomLayers;
int resolutionX;
int resolutionY;
int preview0Addr;
int layerDefsAddr;
int nrLayers;
int preview1Addr;
int unknown6;
int projTypeCastMirror;
int padding1[6];
} headerType;
typedef struct {
int resolutionX;
int resolutionY;
int imageAddress;
int dataLength;
int padding[4];
//char* imageData;
vector<unsigned char> imageData; // Much safer than using a char*
} previewType;
typedef struct {
float layerHeight;
float expTime;
float offTime;
int imageAddress;
int dataLength;
int padding[4];
} layerDefType;
typedef struct {
char color;
char tempColor;
} pixelType;
class PhotonFile
{
public:
PhotonFile( FILE *fp );
PhotonFile( string fileName);
~PhotonFile();
headerType getHeader();
void decodeImageFromRaw( unsigned long layer, pixelType (&pixelBuf)[1440][2560]);
void writeFile(string fileName);
void decreasePixel(unsigned long layer);
friend ostream& operator<<(ostream &os, const PhotonFile &ff);
private:
headerType header;
previewType preview1;
previewType preview2;
vector<layerDefType> layerDefs;
vector< vector<unsigned char> > rawData;
pixelType pixelBuf[1440][2560];
FILE *fp=nullptr;
FILE *wp=nullptr;
void readHeader();
void writeHeader();
void readPreview();
void writePreviews();
void readLayerDefs();
void writeLayerDefs();
void readImages();
void writeImages();
void decodeImage( layerDefType *layerDef, FILE *fp, pixelType (&pixelBuf)[1440][2560] );
void encodeImageToRaw( unsigned long layer, pixelType (&pixelBuf)[1440][2560]);
static void printProgress (double percentage);
};
#endif // PHOTONFILE_H