Skip to content

Commit

Permalink
make export format default to PNG
Browse files Browse the repository at this point in the history
  • Loading branch information
victimofleisure committed Aug 2, 2023
1 parent 6fb2409 commit eba7c0d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
10 changes: 4 additions & 6 deletions trunk/TripLightDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,10 @@ void CTripLightDoc::Dump(CDumpContext& dc) const
BOOL CTripLightDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
LPCTSTR pszExt = PathFindExtension(lpszPathName);
if (pszExt != NULL) { // if extension found
if (!_tcsicmp(pszExt, SNAPSHOT_FILE_EXT)) { // if extension matches
CTripLightView *pView = STATIC_DOWNCAST(CTripLightView, theApp.GetMain()->GetActiveView());
pView->LoadSnapshot(lpszPathName);
return FALSE;
}
if (pszExt != NULL && !_tcsicmp(pszExt, SNAPSHOT_FILE_EXT)) { // if file extension is snapshot
CTripLightView *pView = STATIC_DOWNCAST(CTripLightView, theApp.GetMain()->GetActiveView());
pView->LoadSnapshot(lpszPathName);
return FALSE;
}
CIniFile file;
file.Open(lpszPathName, CFile::modeRead);
Expand Down
22 changes: 15 additions & 7 deletions trunk/TripLightView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
02 15apr23 move modulation period to header
03 16apr23 seed with system time, not tick count
04 02aug23 restore snapshot support
05 02aug23 export PNG format by default
TripLight view
Expand Down Expand Up @@ -48,8 +49,10 @@ IMPLEMENT_DYNCREATE(CTripLightView, CView)
/////////////////////////////////////////////////////////////////////////////
// CTripLightView construction/destruction

#define BMP_EXT _T(".bmp")
#define BMP_FILTER _T("Bitmap Files (*.bmp)|*.bmp|All Files (*.*)|*.*||")
#define BMP_FILE_EXT _T(".bmp")
#define PNG_FILE_EXT _T(".png")
#define EXPORT_FILTER _T("PNG Files (*.png)|*.png|Bitmap Files (*.bmp)|*.bmp|All Files (*.*)|*.*||")
#define SNAPSHOT_FILTER _T("TripLight Snapshots (*.tripsnap)|*.tripsnap|All Files (*.*)|*.*||")

const LPCTSTR CTripLightView::m_arrNoteName[OCTAVE] = {
_T("C"), _T("Db"), _T("D"), _T("Eb"), _T("E"), _T("F"),
Expand All @@ -61,8 +64,6 @@ const LPCTSTR CTripLightView::m_arrNoteName[OCTAVE] = {
#define EXPORT_MIDI_ONLY 0
#define DUMP_MIDI_TEXT 0

#define SNAPSHOT_FILTER _T("TripLight Snapshots (*.tripsnap)|*.tripsnap|All Files (*.*)|*.*||")

CTripLightView::CTripLightView()
{
m_bPause = false;
Expand Down Expand Up @@ -1188,11 +1189,18 @@ LRESULT CTripLightView::OnMappingChange(WPARAM wParam, LPARAM lParam)
void CTripLightView::OnFileExport()
{
CPause pause(*this);
CFileDialog fd(false, BMP_EXT, GetDefaultFileName(), OFN_OVERWRITEPROMPT, BMP_FILTER);
CFileDialog fd(false, PNG_FILE_EXT, GetDefaultFileName(), OFN_OVERWRITEPROMPT, EXPORT_FILTER);
if (fd.DoModal() == IDOK) {
CWaitCursor wc;
if (!ExportBitmap(fd.GetPathName(), GetExportSize()))
AfxThrowResourceException();
CString sFileName(fd.GetFileName());
LPCTSTR pszExt = PathFindExtension(sFileName);
if (pszExt != NULL && !_tcsicmp(pszExt, PNG_FILE_EXT)) { // if file extension is PNG
if (!ExportPNG(fd.GetPathName(), GetExportSize()))
AfxThrowResourceException();
} else { // assume bitmap
if (!ExportBitmap(fd.GetPathName(), GetExportSize()))
AfxThrowResourceException();
}
}
}

Expand Down

0 comments on commit eba7c0d

Please sign in to comment.