void applyCustomFilter(PLBmp & theBitmap, const std::string & theFilterName, const VectorOfFloat & theFilterparams) { asl::Ptr<PLFilter> myPaintLibFilter = y60::PaintLibFilterFactory::get().createFilter(theFilterName, theFilterparams); if (myPaintLibFilter) { theBitmap.ApplyFilter(*myPaintLibFilter); } else { ImageFilter myFilter = ImageFilter(getEnumFromString(theFilterName, ImageFilterStrings)); applyCustomFilter(theBitmap, myFilter, theFilterparams); } }
void CTisDialog::SaveTis(int how) { CString filepath; CString newname; CString tmpstr; int fhandle; int res; if(readonly) { MessageBox("You opened it read only!","Warning",MB_ICONEXCLAMATION|MB_OK); return; } res=OFN_HIDEREADONLY|OFN_ENABLESIZING|OFN_EXPLORER; CMyFileDialog m_getfiledlg(FALSE, how?"tis":"bmp", makeitemname(how?".tis":".bmp",0), res, ImageFilter(how?2:3) ); restart: if( m_getfiledlg.DoModal() == IDOK ) { filepath=m_getfiledlg.GetPathName(); filepath.MakeLower(); newname=m_getfiledlg.GetFileTitle(); if(newname.GetLength()>8 || newname.GetLength()<1 || newname.Find(" ",0)!=-1) { tmpstr.Format("The resource name '%s' is bad, it should be 8 characters long and without spaces.",newname); MessageBox(tmpstr,"Warning",MB_ICONEXCLAMATION|MB_OK); goto restart; } if(newname!=itemname && file_exists(filepath) ) { res=MessageBox("Do you want to overwrite "+newname+"?","Warning",MB_ICONQUESTION|MB_YESNO); if(res==IDNO) goto restart; } fhandle=open(filepath+".tmp", O_BINARY|O_RDWR|O_CREAT|O_TRUNC,S_IREAD|S_IWRITE); if(fhandle<1) { MessageBox("Can't write file!","Error",MB_ICONSTOP|MB_OK); goto restart; } if(how) { if (m_pvr) { //res=the_mos.WritePvrToFile(fhandle,m_minx,m_miny,m_maxx,m_maxy); MessageBox("Operation not supported!","Error",MB_ICONSTOP|MB_OK); goto restart; } else { res=the_mos.WriteTisToFile(fhandle,m_minx,m_miny,m_maxx,m_maxy); } } else res=the_mos.WriteTisToBmpFile(fhandle,m_minx,m_miny,m_maxx,m_maxy); close(fhandle); switch(res) { case 0: unlink(filepath); rename(filepath+".tmp",filepath); MessageBox("Image exported","Tile editor",MB_OK); break; //saved successfully case -2: MessageBox("Error while writing file!","Error",MB_ICONSTOP|MB_OK); break; case -3: MessageBox("Not enough memory.","Error",MB_ICONSTOP|MB_OK); break; default: MessageBox("Unhandled error!","Error",MB_ICONSTOP|MB_OK); } } }