Exemple #1
0
/**< ContextMenu save image */
void ImagePanel::OnCmenuSave(wxCommandEvent& event)
{
	static const wxString EXTS[] =
	{
		_T("bmp"),
		_T("jpg"),
		_T("png"),
		_T("tif")
	};
	// choose images file's name
	wxFileDialog dlgFile(this, _("Save Image"),
	                     _T(""), _T(""),
	                     _T("Bitmap|*.bmp|JPEG|*.jpg;*.jpeg|PNG|*.png|TIFF|*.tif;*.tiff"),
	                     wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
	dlgFile.SetFilterIndex(2);	// png
	if(dlgFile.ShowModal() != wxID_OK)
		return;
	// extention
	int iExt = dlgFile.GetFilterIndex();
	// path modify
	wxFileName fln(dlgFile.GetPath());
	fln.ClearExt();
	fln.SetExt(EXTS[iExt]);
	wxString strFile = fln.GetFullPath();
	m_img.SaveFile(strFile);
}
FileId TokenDatabase::GetFilenameId(const wxString& filename)
{
    wxFileName fln(filename);
    fln.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_CASE);
    const wxString& normFile = fln.GetFullPath(wxPATH_UNIX);
    std::vector<int> id = m_pFilenames->GetIdSet(normFile);
    if (id.empty())
        return m_pFilenames->Insert(normFile, normFile);
    return id.front();
}
Exemple #3
0
char	*ft_itoa(int n)
{
	int		len[2];
	char	*str;

	len[0] = 0;
	len[1] = 0;
	if (n == 0 || n == -2147483648)
	{
		str = jedoismlloc(n);
		return (str);
	}
	n = ft_calc(n, len);
	if (!(str = malloc(len[0] * sizeof(char) + 1 + len[1])))
		return (NULL);
	fln(str, len);
	while (n)
	{
		str[len[0] - 1 + len[1]] = n % 10 + '0';
		n /= 10;
		len[0]--;
	}
	return (str);
}