예제 #1
0
파일: ximaenc.cpp 프로젝트: hhg128/DKGL
/**
 * Reads from disk the image in a specific format.
 * - If decoding fails using the specified image format,
 * the function will try the automatic file format recognition.
 *
 * \param filename: file name
 * \param imagetype: file format, see ENUM_CXIMAGE_FORMATS
 * \return true if everything is ok
 */
bool CxImage::Load(const CXCHAR * filename, uint32_t imagetype)
//bool CxImage::Load(const char * filename, uint32_t imagetype)
{
	/*FILE* hFile;	//file handle to read the image
	if ((hFile=fopen(filename,"rb"))==NULL)  return false;
	bool bOK = Decode(hFile,imagetype);
	fclose(hFile);*/

	/* automatic file type recognition */
	bool bOK = false;
	if ( GetTypeIndexFromId(imagetype) ){
		FILE* hFile;	//file handle to read the image

		if ((hFile=CXFopen(filename,CXSTR("rb")))==NULL)  return false;

		bOK = Decode(hFile,imagetype);
		fclose(hFile);
		if (bOK) return bOK;
	}

	char szError[256];
	strcpy(szError,info.szLastError); //save the first error

	// if failed, try automatic recognition of the file...
	FILE* hFile;

	if ((hFile=CXFopen(filename,CXSTR("rb")))==NULL)  return false;

	bOK = Decode(hFile,CXIMAGE_FORMAT_UNKNOWN);
	fclose(hFile);

	if (!bOK && imagetype > 0) strcpy(info.szLastError,szError); //restore the first error

	return bOK;
}
예제 #2
0
파일: ximaenc.cpp 프로젝트: ONLYOFFICE/core
/**
 * Reads from disk the image in a specific format.
 * - If decoding fails using the specified image format,
 * the function will try the automatic file format recognition.
 *
 * \param filename: file name
 * \param imagetype: file format, see ENUM_CXIMAGE_FORMATS
 * \return true if everything is ok
 */
bool CxImage::Load(const TCHAR * filename, uint32_t imagetype)
//bool CxImage::Load(const char * filename, uint32_t imagetype)
{
#ifdef CXIMAGE_DONT_USE_LOAD_SAVE
    return false;
#else
	/*FILE* hFile;	//file handle to read the image
	if ((hFile=fopen(filename,"rb"))==NULL)  return false;
	bool bOK = Decode(hFile,imagetype);
	fclose(hFile);*/

	/* automatic file type recognition */
	bool bOK = false;
	if ( GetTypeIndexFromId(imagetype) ){
		FILE* hFile;	//file handle to read the image

#if defined(_WIN32) || defined (_WIN64)
		if ((hFile=_tfopen(filename,_T("rb")))==NULL)  return false;	// For UNICODE support
#else
    #ifdef UNICODE
        std::string sFileName = NSFile::CUtf8Converter::GetUtf8StringFromUnicode2 (filename, wcslen (filename));
        if ((hFile=fopen(sFileName.c_str(),"rb"))==NULL)  return false;
    #else
            if ((hFile=fopen(filename,"rb"))==NULL)  return false;
    #endif
#endif

		bOK = Decode(hFile,imagetype);
		fclose(hFile);
		if (bOK) return bOK;
	}

	char szError[256];
	strcpy(szError,info.szLastError); //save the first error

	// if failed, try automatic recognition of the file...
	FILE* hFile;

#if defined(_WIN32) || defined (_WIN64)
	if ((hFile=_tfopen(filename,_T("rb")))==NULL)  return false;	// For UNICODE support
#else
    #ifdef UNICODE
        std::string sFileName = NSFile::CUtf8Converter::GetUtf8StringFromUnicode2 (filename, wcslen (filename));
        if ((hFile=fopen(sFileName.c_str(),"rb"))==NULL)  return false;
    #else
        if ((hFile=fopen(filename,"rb"))==NULL)  return false;
    #endif // #ifdef UNICODE
#endif

	bOK = Decode(hFile,CXIMAGE_FORMAT_UNKNOWN);
	fclose(hFile);

	if (!bOK && imagetype > 0) strcpy(info.szLastError,szError); //restore the first error

	return bOK;
#endif // #ifdef CXIMAGE_DONT_USE_LOAD_SAVE
}
예제 #3
0
bool MXImage::Load(const TCHAR * filename, uint32_t imagetype)
{
	bool bOK = false;
	if (GetTypeIndexFromId(imagetype)){
		FILE* hFile;	//file handle to read the image
		if ((hFile = _tfopen(filename, _T("rb"))) == NULL)  return false;	// For UNICODE support
		bOK = Decode(hFile, imagetype);
		fclose(hFile);
		if (bOK) return bOK;
	}
	errInfo = "请查看图片格式是否正确,或者文件是否损坏!";
	return false;
}
예제 #4
0
/**
 * Reads from disk the image in a specific format.
 * - If decoding fails using the specified image format,
 * the function will try the automatic file format recognition.
 *
 * \param filename: file name
 * \param imagetype: file format, see ENUM_CXIMAGE_FORMATS
 * \return true if everything is ok
 */
bool CxImage::Load(const TCHAR * filename, DWORD imagetype)
//bool CxImage::Load(const char * filename, DWORD imagetype)
{
	/*FILE* hFile;	//file handle to read the image
	if ((hFile=fopen(filename,"rb"))==NULL)  return false;
	bool bOK = Decode(hFile,imagetype);
	fclose(hFile);*/

	/* automatic file type recognition */
	bool bOK = false;
	if ( GetTypeIndexFromId(imagetype) ){
		FILE* hFile;	//file handle to read the image

#ifdef WIN32
		if ((hFile=_tfopen(filename,_T("rb")))==NULL)  return false;	// For UNICODE support
#else
		if ((hFile=fopen(filename,"rb"))==NULL)  return false;
#endif

		bOK = Decode(hFile,imagetype);
		fclose(hFile);
		if (bOK) return bOK;
	}

	char szError[256];
	strcpy(szError,info.szLastError); //save the first error

	// if failed, try automatic recognition of the file...
	FILE* hFile;

#ifdef WIN32
	if ((hFile=_tfopen(filename,_T("rb")))==NULL)  return false;	// For UNICODE support
#else
	if ((hFile=fopen(filename,"rb"))==NULL)  return false;
#endif

	bOK = Decode(hFile,CXIMAGE_FORMAT_UNKNOWN);
	fclose(hFile);

	if (!bOK && imagetype > 0) strcpy(info.szLastError,szError); //restore the first error

	return bOK;
}
예제 #5
0
파일: ximaenc.cpp 프로젝트: sd-eblana/bawx
bool CxImage::Load(const char * filename, DWORD imagetype)
#endif
//bool CxImage::Load(const char * filename, DWORD imagetype)
{
	/*FILE* hFile;	//file handle to read the image
	if ((hFile=fopen(filename,"rb"))==NULL)  return false;
	bool bOK = Decode(hFile,imagetype);
	fclose(hFile);*/

#ifdef XBMC
	int iWidthSave = iWidth;
	int iHeightSave = iHeight;
#endif

	/* automatic file type recognition */
	bool bOK = false;
	if ( GetTypeIndexFromId(imagetype) ){
		FILE* hFile;	//file handle to read the image

#ifdef WIN32
		if ((hFile=_tfopen(filename,_T("rb")))==NULL)  return false;	// For UNICODE support
#else
		if ((hFile=fopen(filename,"rb"))==NULL)  return false;
#endif

#ifdef XBMC
      bOK = Decode(hFile,imagetype,iWidth,iHeight);
		  if (imagetype != CXIMAGE_FORMAT_JPG)
		  {
			  iWidth = GetWidth();
			  iHeight = GetHeight();
		  }
#else
		  bOK = Decode(hFile,imagetype);
#endif
		fclose(hFile);
		
		if (bOK) return bOK;
	}
	
	char szError[256];
	strcpy(szError,info.szLastError); //save the first error

	// if failed, try automatic recognition of the file...
	FILE* hFile;

#ifdef WIN32
	if ((hFile=_tfopen(filename,_T("rb")))==NULL)  return false;	// For UNICODE support
#else
	if ((hFile=fopen(filename,"rb"))==NULL)  return false;
#endif

#ifdef XBMC
    bOK = Decode(hFile,CXIMAGE_FORMAT_UNKNOWN,iWidth,iHeight);
	if (imagetype != CXIMAGE_FORMAT_JPG)
	{
		iWidth = GetWidth();
	  	iHeight = GetHeight();
	}
#else
	bOK = Decode(hFile,CXIMAGE_FORMAT_UNKNOWN);
#endif
	fclose(hFile);

	if (!bOK && imagetype > 0) strcpy(info.szLastError,szError); //restore the first error

	return bOK;
}