Mercurial > mercurial > hgweb_mover.cgi
comparison src/testtune.cpp @ 1:214f2908b8e4
test now.
author | pyon@macmini |
---|---|
date | Thu, 29 Sep 2011 07:47:06 +0900 |
parents | 2344703d786b |
children | 1ea4f7981ff5 |
comparison
equal
deleted
inserted
replaced
0:2344703d786b | 1:214f2908b8e4 |
---|---|
1 #include "wx/utils.h" | 1 #include "wx/utils.h" |
2 #include "wx/string.h" | 2 #include "wx/string.h" |
3 #include "wx/image.h" | |
3 | 4 |
4 bool IsBlack( int r, int g, int b ) | 5 bool IsBlack( int r, int g, int b ) |
5 { | 6 { |
6 if ( r == 255 && g == 255 && b == 255 ) { | 7 if ( r == 0 && g == 0 && b == 0 ) { |
7 return true; | 8 return true; |
8 } | 9 } |
9 return false; | 10 return false; |
10 } | 11 } |
11 | 12 |
12 int GuessHhs( wxString &file ) | 13 wxString GuessHhs( void ) |
13 { | 14 { |
14 //open image file | 15 wxString hhs; |
16 wxImage img( wxT("img/img361.jpg"), wxBITMAP_TYPE_JPEG ); | |
17 int sx = 1800; // start x | |
18 int sy = 315;; // start y | |
19 int bw = 60; // block width | |
20 int bh = 50; // block height | |
21 int area = bw * bh; | |
22 int black = 0; | |
23 int x, y; | |
24 unsigned char r, g, b; | |
15 | 25 |
16 int xoffset = 0; | 26 int max_n = -1; |
17 int yoffset = 0; | 27 float max = 0.0; |
18 int dx = 10; | 28 float bk; |
19 int dy = 10; | 29 for ( int c=0; c<9; c++ ) { |
30 for ( int n=0; n<9; n++ ) { | |
20 | 31 |
21 for ( int i=0; i<10; i++ ) { | 32 for ( x=sx+bw*c; x<sx+bw*(c+1); x++ ) { |
22 for ( int j=0; j<10; j++ ) { | 33 for ( y=sy+bh*n; y<sy+bh*(n+1); y++ ) { |
34 r = img.GetRed( x, y ); | |
35 g = img.GetGreen( x, y ); | |
36 b = img.GetBlue( x, y ); | |
37 if( IsBlack( (int)r, (int)g, (int)b ) ) black++; | |
38 } | |
39 } | |
40 | |
41 bk = (float)black/area; | |
42 if ( max < bk ) { | |
43 max = bk; | |
44 max_n = n; | |
45 } | |
46 wxPuts(wxString::Format(wxT("%f"),bk)); | |
47 black = 0; | |
23 } | 48 } |
49 hhs.Append( wxString::Format( wxT("%1d"), max_n ) ); | |
24 } | 50 } |
25 return 1; | 51 |
52 return hhs; | |
26 } | 53 } |
27 | 54 |
28 int main( int argc, char **argv ) | 55 int main( int argc, char **argv ) |
29 { | 56 { |
30 wxString file; | 57 wxInitAllImageHandlers(); |
31 GuessHhs( file ); | 58 wxString hhs = GuessHhs(); |
32 | 59 |
33 wxPuts(wxT("program end")); | 60 wxPuts(hhs); |
34 } | 61 } |
35 | 62 |