IM_TYPE CFormatDetector::ImageFormat(UIC::BaseStreamInput& in) { IM_TYPE fmt; BaseStream::TStatus status; fmt = IT_UNKNOWN; if(IsBMP(in)) fmt = IT_BMP; else if(IsPNG(in)) fmt = IT_PNG; else if(IsJPEG(in)) fmt = IT_JPEG; else if(IsJPEG2000(in)) fmt = IT_JPEG2000; else if(IsDICOM(in)) fmt = IT_DICOM; else if(IsJPEGXR(in)) fmt = IT_JPEGXR; status = in.Seek(0,UIC::BaseStreamInput::Beginning); if(UIC::BaseStreamInput::StatusOk != status) return IT_UNKNOWN; return fmt; } // CFormatDetector::ImageFormat()
BOOL CImage::Load(CString sFileName) { Destroy(); FILE* f = NULL; _TFOPEN_S(f, sFileName.GetBuffer(0), _T("rb")); if(f==NULL) return FALSE; if(IsBitmap(f)) { fclose(f); return LoadBitmapFromBMPFile(sFileName.GetBuffer(0)); } else if(IsPNG(f)) { fclose(f); return LoadBitmapFromPNGFile(sFileName.GetBuffer(0)); } else if(IsJPEG(f)) { fclose(f); return LoadBitmapFromJPEGFile(sFileName.GetBuffer(0)); } fclose(f); return FALSE; }
BOOL CImage::IsImageFile(CString sFileName) { FILE* f = NULL; _TFOPEN_S(f, sFileName.GetBuffer(0), _T("rb")); if(f==NULL) return FALSE; if(IsBitmap(f) || IsPNG(f) || IsJPEG(f)) { fclose(f); return TRUE; } fclose(f); return FALSE; }
static bool IsImage(const char* filename) { return IsJPEG(filename) || IsPNG(filename) || IsPCX(filename) || IsBMP(filename) || IsGIF(filename); }