Mercurial > mercurial > hgweb_mover2.cgi
changeset 10:1fda3a06c39b
file name arrange.
author | pyon@macmini |
---|---|
date | Fri, 21 Oct 2011 07:58:23 +0900 |
parents | dfa5cae8c992 |
children | 9b0840b0be7e |
files | include/cache.h include/marksheet.h include/myutils.h makefile src/myframe.cpp |
diffstat | 5 files changed, 48 insertions(+), 119 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/cache.h Fri Oct 21 07:58:23 2011 +0900 @@ -0,0 +1,38 @@ +// Filename : cache.h +// Last Change: 21-Oct-2011. +// +#ifndef __cache__ +#define __cache__ + +class CacheItem +{ +public: + wxString filename; // key + wxString fullpathname; + wxString z, l; + wxBitmap thumbnail; + bool marksheet; +}; + +WX_DECLARE_HASH_MAP( wxString, CacheItem*, wxStringHash, wxStringEqual, CacheHash ); + +class Cache +{ +public: + wxString key; + CacheHash ch; + wxString m_dir; + + bool IsCached( wxString file ); + void UpdateCache(); +}; + +bool Cache::IsCached( wxString file ) +{ + Cache* i = new Cache; + return false; +} + + +#endif // __cache__ +
--- a/include/marksheet.h Thu Oct 20 07:44:56 2011 +0900 +++ b/include/marksheet.h Fri Oct 21 07:58:23 2011 +0900 @@ -1,8 +1,8 @@ // Filename : marksheet.h -// Last Change: 19-Oct-2011. +// Last Change: 21-Oct-2011. // -#ifndef __MARKSHEET__ -#define __MARKSHEET__ +#ifndef __marksheet__ +#define __marksheet__ bool IsBlack( int r, int g, int b ) { @@ -89,5 +89,5 @@ return false; }; -#endif // __MARKSHEET__ +#endif // __marksheet__
--- a/include/myutils.h Thu Oct 20 07:44:56 2011 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -// Filename : myutils.h -// Last Change: 20-Oct-2011. -// -#ifndef __myutils__ -#define __myutils__ - -/********** Marksheet **********/ -bool IsBlack( int r, int g, int b ) -{ - if ( r == 0 && g == 0 && b == 0 ) { - return true; - } - return false; -}; - -wxString GuessHhs( wxString& file ) -{ - wxString hhs; - wxImage img( file, 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; - float max; - float bk; - for ( int c=0; c<10; c++ ) { - max = 0.0; - max_n = -1; - for ( int n=0; n<10; n++ ) { - - 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++; - } - } - - bk = (float)black / area; - if ( max < bk ) { - max = bk; - max_n = n; - } - //wxPuts(wxString::Format(wxT("%d %f"),n,bk)); - black = 0; - } - hhs.Append( wxString::Format( wxT("%d"), max_n ) ); - } - - return hhs; -}; - -bool IsMarksheet( wxString& file, float* brate, long* len ) -{ - wxImage img( file, wxBITMAP_TYPE_JPEG ); - int black = 0; - int x = 2465; - int h = 3500; - unsigned char r, g, b; - - for ( int y=0; y<h; 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++; - } - float z = (float)black / h; - float zmin = 0.095713; - float zmax = 0.108600; - - wxFile f( file ); - long l = f.Length(); - float lmin = 2072393; - float lmax = 2346082; - - *brate = z; - *len = l; - //wxPuts(wxString::Format(wxT("z = %f, len = %d"),z,len)); - if ( zmin < z && z < zmax - && lmin < l && l < lmax ) { - return true; - } - return false; -}; - -/********** Cache **********/ -class Cache -{ -public: - wxString filename; // key - wxString fullpathname; - wxString z, l; - bool marksheet; -}; - -bool IsCached( wxString file ) -{ - Cache* i = new Cache; -}; -#endif // __myutils__ -
--- a/makefile Thu Oct 20 07:44:56 2011 +0900 +++ b/makefile Fri Oct 21 07:58:23 2011 +0900 @@ -1,6 +1,6 @@ # # Makefile for wxWidgets Application -# Last Change: 20-Oct-2011. +# Last Change: 21-Oct-2011. # by Takayuki Mutoh # @@ -102,7 +102,7 @@ -mkdir -p $(OBJDIR) $(CXX) -c $< -o $@ $(CPPFLAGS) -$(OBJDIR)/myframe.o: myframe.cpp myframe.h common.h main.h myutils.h dndfile.h +$(OBJDIR)/myframe.o: myframe.cpp myframe.h common.h main.h marksheet.h dndfile.h cache.h $(CXX) -c $< -o $@ $(CPPFLAGS) $(OBJDIR)/param.o: param.cpp param.h common.h main.h
--- a/src/myframe.cpp Thu Oct 20 07:44:56 2011 +0900 +++ b/src/myframe.cpp Fri Oct 21 07:58:23 2011 +0900 @@ -1,12 +1,13 @@ // Filename : myframe.cpp -// Last Change: 20-Oct-2011. +// Last Change: 21-Oct-2011. // #include "main.h" #include "myframe.h" #include "param.h" #include "dndfile.h" -#include "myutils.h" +#include "marksheet.h" +#include "cache.h" // resources // the application icon (under Windows and OS/2 it is in resources and even @@ -15,8 +16,6 @@ #include "sample.xpm" #endif -WX_DECLARE_HASH_MAP( wxString, Cache*, wxStringHash, wxStringEqual, CacheHash ); - ////////////////////////////////////////////////////////////////////////// // frame constructor MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style ) @@ -169,7 +168,7 @@ this->Centre( wxBOTH ); - CacheHash cache; + Cache cache; } // destructor