-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
111 lines (91 loc) · 3.46 KB
/
main.cpp
File metadata and controls
111 lines (91 loc) · 3.46 KB
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
102
103
104
105
106
107
108
109
110
111
/**
* @file main.cpp
* Contains code to test your Quadtree implementation.
*/
#include <iostream>
#include "png.h"
#include "quadtree.h"
using std::cout;
using std::endl;
int main()
{
PNG imgIn, imgOut, cMas, cMasOut, lePup, lePupOut, lucky;
// lePup.readFromFile("puppy.png");
//
// // test constructor, decompress
// Quadtree pupTree(lePup, 64);
// Quadtree * pup = new Quadtree();
// pup = &pupTree;
// Quadtree lePope;
// lePope = pupTree;
// // cout << "lePope.pruneSize(0) = " << lePope.pruneSize(0) << endl;
// // cout << "lePope.pruneSize(100) = " << lePope.pruneSize(100) << endl;
// // cout << "lePope.pruneSize(1000) = " << lePope.pruneSize(1000) << endl;
// // cout << "lePope.pruneSize(100000) = " << lePope.pruneSize(100000) << endl;
// // cout << "lePope.idealPrune(1000) = " << lePope.idealPrune(1000) << endl;
// // cout << "lePope.idealPrune(10000) = " << lePope.idealPrune(10000) << endl;
// // // cout << "lePope.idealPrune(0) = " << lePope.idealPrune(0) << endl;
// // cout << "lePope.idealPrune(100000) = "<< lePope.idealPrune(100000) << endl;
// pup->clockwiseRotate();
// lePupOut = pup->decompress();
// lePupOut.writeToFile("puppyOut.png");
//
//
// lucky = lePope.decompress();
// lucky.writeToFile("lePup.png");
//
// cMas.readFromFile("cmas.png");
// Quadtree cTree(cMas, 4);
// Quadtree cOutTree(cTree);
// cMasOut = cOutTree.decompress();
// cMasOut.writeToFile("cMasOut.png");
// PNG imgIn, imgOut;
imgIn.readFromFile("in.png");
// test constructor, decompress
Quadtree halfTree(imgIn, 128);
imgOut = halfTree.decompress();
imgOut.writeToFile("outHalf.png");
// now for the real tests
Quadtree fullTree;
fullTree.buildTree(imgIn, 256);
cout << "MY FILE" << endl;
// you may want to experiment with different commands in this section
// test pruneSize and idealPrune (slow in valgrind, so you may want to
// comment these out when doing most of your testing for memory leaks)
cout << "fullTree.pruneSize(0) = " << fullTree.pruneSize(0) << endl;
cout << "fullTree.pruneSize(100) = " << fullTree.pruneSize(100) << endl;
cout << "fullTree.pruneSize(1000) = " << fullTree.pruneSize(1000) << endl;
cout << "fullTree.pruneSize(100000) = " << fullTree.pruneSize(100000) << endl;
cout << "fullTree.idealPrune(1000) = " << fullTree.idealPrune(1000) << endl;
// cout << "checking the big one" << endl;
cout << "fullTree.idealPrune(10000) = " << fullTree.idealPrune(10000) << endl;
// Test some creation/deletion functions
Quadtree fullTree2;
fullTree2 = fullTree;
imgOut = fullTree2.decompress();
imgOut.writeToFile("outCopy.png");
// test clockwiseRotate
fullTree.clockwiseRotate();
imgOut = fullTree.decompress();
imgOut.writeToFile("outRotated.png");
// test prune
fullTree = fullTree2;
fullTree.prune(1000);
imgOut = fullTree.decompress();
imgOut.writeToFile("outPruned.png");
// test several functions in succession
Quadtree fullTree3(fullTree2);
fullTree3.clockwiseRotate();
fullTree3.prune(10000);
fullTree3.clockwiseRotate();
fullTree3.clockwiseRotate();
fullTree3.clockwiseRotate();
imgOut = fullTree3.decompress();
imgOut.writeToFile("outEtc.png");
// ensure that printTree still works
Quadtree tinyTree(imgIn, 32);
cout << "Printing tinyTree:\n";
tinyTree.prune(100);
tinyTree.printTree();
return 0;
}