Mercurial > mercurial > hgweb_golang.cgi
changeset 60:058fb0a2cda8
fix eraline.
author | pyon@macmini |
---|---|
date | Fri, 14 Aug 2020 03:31:29 +0900 |
parents | 48e46bfe97fa |
children | 49656dc40069 |
files | src/kaigo/horori/Readme.txt src/kaigo/horori/eraline/Makefile src/kaigo/horori/eraline/sample.ico src/kaigo/horori/eraline/sample.rc src/kaigo/horori/eraline/src/eraline.cpp src/kaigo/horori/eraline/src/geraline.cpp src/kaigo/horori/horori.fbp src/kaigo/horori/release.bat |
diffstat | 3 files changed, 105 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/src/kaigo/horori/eraline/Makefile Wed Aug 12 19:57:58 2020 +0900 +++ b/src/kaigo/horori/eraline/Makefile Fri Aug 14 03:31:29 2020 +0900 @@ -1,5 +1,5 @@ # Makefile for wxWidgets Console Application -# Last Change: 2020-08-06 木 15:46:13. +# Last Change: 2020-08-13 木 09:30:01. # by Takayuki Mutoh # @@ -12,6 +12,7 @@ ARCH = 64 vpath %.cpp ./src vpath %.h ./include +OBJDIR = ./obj # For Microsoft Windows ifdef COMSPEC @@ -50,6 +51,8 @@ @echo "" @echo "=> $(GEXECUTABLE) <=" $(CXX) $^ -o $@ $(LIBS) + strip $(GEXECUTABLE) + ./$(GEXECUTABLE) $(OBJDIR)/main.o: main.cpp main.h geraline.h @echo "" @@ -74,6 +77,8 @@ clean: rm -f $(PROGNAME) $(PROGNAME).exe + rm -f $(GPROGNAME) $(GPROGNAME).exe + rm -f $(OBJDIR)/* .PHONY: all clean
--- a/src/kaigo/horori/eraline/src/eraline.cpp Wed Aug 12 19:57:58 2020 +0900 +++ b/src/kaigo/horori/eraline/src/eraline.cpp Fri Aug 14 03:31:29 2020 +0900 @@ -1,8 +1,9 @@ /* eraline.cpp - * Last Change: 2020-08-12 水 16:58:21. + * Last Change: 2020-08-13 木 11:03:06. * by T.Mutoh * - * > eraline y d in.jpg out.jpg + * > eraline y d in.tif out.tif + * > eraline -v x d in.tif out.tif */ #include "wx/wxprec.h" @@ -10,36 +11,19 @@ #include <wx/app.h> #include <wx/cmdline.h> -static const wxCmdLineEntryDesc cmdLineDesc[] = -{ - {wxCMD_LINE_SWITCH, "h", "help", "show this help message", - wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP}, - {wxCMD_LINE_SWITCH, "d", "dummy", "a dummy switch", - wxCMD_LINE_VAL_NONE, 0}, - {wxCMD_LINE_SWITCH, "s", "secret", "a secret switch", - wxCMD_LINE_VAL_NONE, wxCMD_LINE_HIDDEN}, +wxString inimg; +wxString outimg; + +static const wxCmdLineEntryDesc cmdLineDesc[] = { + {wxCMD_LINE_SWITCH, "h", "help", "show this help message", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP}, + {wxCMD_LINE_SWITCH, "d", "dummy", "a dummy switch", wxCMD_LINE_VAL_NONE, 0}, + {wxCMD_LINE_SWITCH, "v", "vertical", "a secret switch", wxCMD_LINE_VAL_NONE, wxCMD_LINE_HIDDEN}, // ... your other command line options here... wxCMD_LINE_DESC_END }; -int main(int argc, char **argv) -{ - wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "program"); - - wxInitializer initializer; - if (!initializer) { - fprintf(stderr, "Failed to initialize the wxWidgets library, aborting."); - return -1; - } - - int y = wxAtoi(argv[1]); - int d = wxAtoi(argv[2]); - wxString inimg = argv[3]; - wxString outimg = argv[4]; - - wxImage::AddHandler(new wxTIFFHandler ); - +void h1(int y) { wxImage img(inimg, wxBITMAP_TYPE_TIFF); int r, g, b; @@ -70,7 +54,73 @@ img.SetOption(wxIMAGE_OPTION_TIFF_COMPRESSION, 5); img.SetOption(wxIMAGE_OPTION_TIFF_BITSPERSAMPLE, 1); img.SaveFile(outimg); +} + +void v1(int x) { + wxImage img(inimg, wxBITMAP_TYPE_TIFF); + + int r, g, b; + for (int y = 0; y < img.GetHeight(); y++) { + r = (int)img.GetRed(x, y) + (int)img.GetRed(x - 1, y) + (int)img.GetRed(x + 1, y); + g = (int)img.GetGreen(x, y) + (int)img.GetGreen(x - 1, y) + (int)img.GetGreen(x + 1, y); + b = (int)img.GetBlue(x, y) + (int)img.GetBlue(x - 1, y) + (int)img.GetBlue(x + 1, y); + img.SetRGB(x, y, (unsigned char)(r / 3), (unsigned char)(g / 3), (unsigned char)(b / 3)); + } + + img.SetOption(wxIMAGE_OPTION_TIFF_COMPRESSION, 5); + img.SetOption(wxIMAGE_OPTION_TIFF_BITSPERSAMPLE, 1); + img.SaveFile(outimg); +} + +int main(int argc, char **argv) { + wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "program"); + + wxInitializer initializer; + if (!initializer) { + fprintf(stderr, "Failed to initialize the wxWidgets library, aborting."); + return -1; + } + + wxCmdLineParser parser(cmdLineDesc, argc, argv); + + wxImage::AddHandler(new wxTIFFHandler ); + + /* + switch (parser.Parse()) { + case -1: + // help was given, terminating + wxPuts("help"); + break; + + case 0: + // everything is ok; proceed + if (parser.Found("d")) { + wxPrintf("Dummy switch was given...\n"); + } + if (parser.Found("v")) { + wxPrintf("Vertical switch was given... %s\n", argv[0]); + int t = wxAtoi(argv[2]); + int d = wxAtoi(argv[3]); + inimg = argv[4]; + outimg = argv[5]; + //v1(t); + } + break; + + default: + wxPrintf("??? switch was given... \n"); + break; + } + */ + + int t = wxAtoi(argv[1]); + int d = wxAtoi(argv[2]); + inimg = argv[3]; + outimg = argv[4]; + + h1(t); return 0; } +
--- a/src/kaigo/horori/eraline/src/geraline.cpp Wed Aug 12 19:57:58 2020 +0900 +++ b/src/kaigo/horori/eraline/src/geraline.cpp Fri Aug 14 03:31:29 2020 +0900 @@ -1,9 +1,11 @@ // Filename : geraline.cpp -// Last Change: 2020-08-12 水 17:18:40. +// Last Change: 2020-08-13 木 13:30:21. // #include <wx/dir.h> #include <wx/msgdlg.h> #include <wx/textfile.h> +#include <wx/filename.h> +#include <wx/datetime.h> #include "geraline.h" #define GRID_SZ 9 @@ -78,9 +80,13 @@ wxVector<wxVariant> data; while (cont) { + wxFileName fname(path + wxFILE_SEP_PATH + file); + wxString sz = wxString::Format(wxT("%s KB"), (fname.GetSize() / 1024).ToString()); + wxString dt = fname.GetModificationTime().Format(wxT("%Y-%m-%d %H:%M:%S")); + data.push_back(wxVariant(file)); - data.push_back(wxVariant(wxEmptyString)); - data.push_back(wxVariant(wxEmptyString)); + data.push_back(wxVariant(sz)); + data.push_back(wxVariant(dt)); m_dataViewListCtrl->AppendItem(data); data.clear(); n++; @@ -102,20 +108,25 @@ } wxString cmd, infile, outfile; - wxString y = wxString::Format(wxT("%d"), m_spinCtrlY->GetValue()); wxTextFile textfile; wxString batchfile = outdir + wxFILE_SEP_PATH + wxT("a.bat"); + textfile.Create(batchfile); + + textfile.AddLine(wxT("SET INDIR=") + indir); + textfile.AddLine(wxT("SET OUTDIR=") + outdir); + textfile.AddLine(wxT("SET ERALINE=") + wxGetCwd() + wxFILE_SEP_PATH + wxT("eraline.exe")); // > eraline.exe y h in.tif out.tif for (int r = 0; r < m_dataViewListCtrl->GetItemCount(); r++) { - infile = indir + wxFILE_SEP_PATH + m_dataViewListCtrl->GetTextValue(r, 0); - outfile = outdir + wxFILE_SEP_PATH + m_dataViewListCtrl->GetTextValue(r, 0); - cmd = wxT("eraline.exe ") + y + wxT(" 1 ") + infile + " " + outfile; + cmd = wxString::Format(wxT("%%ERALINE%% %d %d %%INDIR%%%s %%OUTDIR%%%s"), + m_spinCtrlY->GetValue(), 1, + wxFILE_SEP_PATH + m_dataViewListCtrl->GetTextValue(r, 0), + wxFILE_SEP_PATH + m_dataViewListCtrl->GetTextValue(r, 0) + ); textfile.AddLine(cmd); } - textfile.Create(batchfile); wxCSConv cust(wxT("cp932")); textfile.Write(wxTextFileType_Dos, cust); textfile.Close(); @@ -198,9 +209,9 @@ gbSizer->Add(m_dirPickerInDir, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALL|wxALIGN_CENTER_VERTICAL, 5); m_dataViewListCtrl = new wxDataViewListCtrl(this, wxID_ANY, wxDefaultPosition, wxSize(THUMB_W, 500), wxDV_ROW_LINES|wxDV_SINGLE); - m_dataViewListColumnName = m_dataViewListCtrl->AppendTextColumn(wxT("Name"), wxDATAVIEW_CELL_INERT, 120, static_cast<wxAlignment>(wxALIGN_LEFT), wxDATAVIEW_COL_RESIZABLE); - m_dataViewListColumnSize = m_dataViewListCtrl->AppendTextColumn(wxT("Size"), wxDATAVIEW_CELL_INERT, -1, static_cast<wxAlignment>(wxALIGN_RIGHT), wxDATAVIEW_COL_RESIZABLE); - m_dataViewListColumnTime = m_dataViewListCtrl->AppendTextColumn(wxT("Time"), wxDATAVIEW_CELL_INERT, -1, static_cast<wxAlignment>(wxALIGN_CENTER), wxDATAVIEW_COL_RESIZABLE); + m_dataViewListColumnName = m_dataViewListCtrl->AppendTextColumn(wxT(" Name"), wxDATAVIEW_CELL_INERT, 180, static_cast<wxAlignment>(wxALIGN_LEFT), wxDATAVIEW_COL_RESIZABLE); + m_dataViewListColumnSize = m_dataViewListCtrl->AppendTextColumn(wxT("Size "), wxDATAVIEW_CELL_INERT, 80, static_cast<wxAlignment>(wxALIGN_RIGHT), wxDATAVIEW_COL_RESIZABLE); + m_dataViewListColumnTime = m_dataViewListCtrl->AppendTextColumn(wxT("Time"), wxDATAVIEW_CELL_INERT, -1, static_cast<wxAlignment>(wxALIGN_CENTER), wxDATAVIEW_COL_RESIZABLE); gbSizer->Add(m_dataViewListCtrl, wxGBPosition(1, 1), wxGBSpan(1, 1), wxALL|wxEXPAND, 5); m_bitmapThumb = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(THUMB_W, THUMB_H), 0);