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
98
99
100
101
|
#include <bitset>
#include <debug.h>
#include <PNGImage.h>
#include <BMPImage.h>
#include <HashTable.h>
#include <zlib.h>
#include <cstdint>
#include <cstring>
#include <iostream>
using std::cout, std::endl;
int main(int argc, char* argv[])
{
// uint8_t poly = 0b10011;
// uint32_t data = 0b11010110110000;
// uint32_t ones = 0b11111;
// char dashes[15];
// memset(dashes, '-', 14);
// dashes[14] = 0;
// for(int i = 9; i >= 0; i--)
// {
// uint32_t shiftedPoly = poly << i;
// cout << std::bitset<14>(data) << endl << std::bitset<14>(shiftedPoly) << endl << dashes << endl;
// bool greater = false;
// for(int j = 4; j >= 0; j++)
// {
// if(data & (0b1 << (j+i)))
// {
// greater = true;
// break;
// }
// else if (shiftedPoly & (0b1 << (j+i)))
// break;
// }
// if(greater)
// data ^= shiftedPoly;
// }
// cout << std::bitset<5>(data) << endl;
// return 0;
if(argc < 4)
{
cout << "usage: " << argv[0] << " <in file> <tmpfile> <outfile>" << endl;
return 1;
}
// TehImage::ZLib encoder;
// TehImage::ZLib decoder;
// const int inSize = 1000;
// uint8_t in[inSize];
// for(int i = 0; i < 10; i++)
// {
// for(int j = 0; j < 100; j++)
// {
// in[i*100+j] = i;
// }
// }
// const int encodedSize = 1024;
// uint8_t encoded[encodedSize];
// int compressedSize = encoder.encodeData(in, inSize, encoded, encodedSize);
// // for(int i = 0; i < compressedSize; i++)
// // {
// // cout << std::bitset<8>(encoded[i]) << endl;
// // }
// uint8_t out[inSize];
// int decodedSize = decoder.decodeData(encoded, encodedSize, out, inSize);
// cout << ((memcmp(in, out, inSize) == 0)?"Pass":"Fail") << ", Size: " << compressedSize << endl;
// // for(int i = 0; i < inSize; i++)
// // {
// // cout << 0 + in[i] << " " << 0 + out[i] << endl;
// // }
// return 0;
std::string infile = argv[1];
std::string tmpfile = argv[2];
std::string outfile = argv[3];
TehImage::BMPImage bmp;
bmp.readFromFile(infile);
TehImage::PNGImage png(bmp);
png.writeToFile(tmpfile);
TehImage::PNGImage png2;
png2.readFromFile(tmpfile);
TehImage::BMPImage bmp2(png2);
bmp.writeToFile(outfile);
}
|