Mercurial > mercurial > hgweb_mover.cgi
changeset 1:214f2908b8e4
test now.
author | pyon@macmini |
---|---|
date | Thu, 29 Sep 2011 07:47:06 +0900 |
parents | 2344703d786b |
children | 1ea4f7981ff5 |
files | TODO src/testtune.cpp |
diffstat | 2 files changed, 41 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/TODO Wed Sep 28 07:41:15 2011 +0900 +++ b/TODO Thu Sep 29 07:47:06 2011 +0900 @@ -1,6 +1,7 @@ =========================================================================== TODO =========================================================================== +* Log : moved time, files, distination --------------------------------------------------------------------------- Memo
--- a/src/testtune.cpp Wed Sep 28 07:41:15 2011 +0900 +++ b/src/testtune.cpp Thu Sep 29 07:47:06 2011 +0900 @@ -1,35 +1,62 @@ #include "wx/utils.h" #include "wx/string.h" +#include "wx/image.h" bool IsBlack( int r, int g, int b ) { - if ( r == 255 && g == 255 && b == 255 ) { + if ( r == 0 && g == 0 && b == 0 ) { return true; } return false; } -int GuessHhs( wxString &file ) +wxString GuessHhs( void ) { - //open image file + wxString hhs; + wxImage img( wxT("img/img361.jpg"), wxBITMAP_TYPE_JPEG ); + int sx = 1800; // start x + int sy = 315;; // start y + int bw = 60; // block width + int bh = 50; // block height + int area = bw * bh; + int black = 0; + int x, y; + unsigned char r, g, b; + + int max_n = -1; + float max = 0.0; + float bk; + for ( int c=0; c<9; c++ ) { + for ( int n=0; n<9; n++ ) { - int xoffset = 0; - int yoffset = 0; - int dx = 10; - int dy = 10; + for ( x=sx+bw*c; x<sx+bw*(c+1); x++ ) { + for ( y=sy+bh*n; y<sy+bh*(n+1); y++ ) { + r = img.GetRed( x, y ); + g = img.GetGreen( x, y ); + b = img.GetBlue( x, y ); + if( IsBlack( (int)r, (int)g, (int)b ) ) black++; + } + } - for ( int i=0; i<10; i++ ) { - for ( int j=0; j<10; j++ ) { + bk = (float)black/area; + if ( max < bk ) { + max = bk; + max_n = n; + } + wxPuts(wxString::Format(wxT("%f"),bk)); + black = 0; } + hhs.Append( wxString::Format( wxT("%1d"), max_n ) ); } - return 1; + + return hhs; } int main( int argc, char **argv ) { - wxString file; - GuessHhs( file ); + wxInitAllImageHandlers(); + wxString hhs = GuessHhs(); - wxPuts(wxT("program end")); + wxPuts(hhs); }