-
Notifications
You must be signed in to change notification settings - Fork 21
/
romdecoderhistogram.cpp
34 lines (27 loc) · 1.01 KB
/
romdecoderhistogram.cpp
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
#include "romdecoderhistogram.h"
RomDecoderHistogram::RomDecoderHistogram() {}
//This returns a text preview.
QString RomDecoderHistogram::preview(MaskRomTool *m){
QString ascii="# Count of colors in bit samples.\n"
"# You probably want to render it in Matlab or GNUPlot.\n"
"# \n"
"# Value Reds Greens Blues\n";
//Force the updates, even when there's no histogram to see.
m->updateThresholdHistogram(true);
for(int i=0; i<256; i++){
int red=(int) m->reds[i];
int green=(int) m->greens[i];
int blue=(int) m->blues[i];
ascii.append(QString::asprintf(" %3d %5d %5d %5d\n",
i,
red, green, blue)
);
}
return ascii;
}
//Exports the preview to a file.
void RomDecoderHistogram::writeFile(MaskRomTool *m, QString filename){
QFile fout(filename);
fout.open(QIODevice::WriteOnly);
fout.write(preview(m).toUtf8());
}