mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
For bug 46717
This commit is contained in:
@ -421,7 +421,7 @@ void CBgraFrame::put_Palette(BYTE* pDataColors, const int& colors)
|
||||
memcpy(m_pPalette, pDataColors, colors * 4);
|
||||
}
|
||||
|
||||
bool CBgraFrame::OpenFile(const std::wstring& strFileName, unsigned int nFileType)
|
||||
bool CBgraFrame::OpenFile(const std::wstring& strFileName, unsigned int nFileType, const bool& bIsOrientationRemove)
|
||||
{
|
||||
m_nFileType = nFileType;
|
||||
|
||||
@ -448,6 +448,13 @@ bool CBgraFrame::OpenFile(const std::wstring& strFileName, unsigned int nFileTyp
|
||||
if (!img->Decode(oFile.GetFileNative(), m_nFileType))
|
||||
return false;
|
||||
|
||||
#if CXIMAGE_SUPPORT_EXIF
|
||||
#if CXIMAGE_SUPPORT_TRANSFORMATION
|
||||
if (bIsOrientationRemove)
|
||||
img->RotateExif(0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
CxImage* imgResample = NULL;
|
||||
|
||||
if (false)
|
||||
@ -653,3 +660,61 @@ void CBgraFrame::FromImage(IGrObject* pGrObject, bool bIsCopy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CBgraFrame::RemoveOrientation(const std::wstring& strFileName)
|
||||
{
|
||||
CImageFileFormatChecker checker(strFileName);
|
||||
__ENUM_CXIMAGE_FORMATS imageType = checker.eFileType;
|
||||
|
||||
switch (imageType)
|
||||
{
|
||||
case _CXIMAGE_FORMAT_JPG:
|
||||
case _CXIMAGE_FORMAT_PNG:
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
if (!oFile.OpenFile(strFileName))
|
||||
return false;
|
||||
|
||||
CxImage* img = new CxImage();
|
||||
if (!img->Decode(oFile.GetFileNative(), imageType))
|
||||
{
|
||||
delete img;
|
||||
return false;
|
||||
}
|
||||
|
||||
#if CXIMAGE_SUPPORT_EXIF
|
||||
#if CXIMAGE_SUPPORT_TRANSFORMATION
|
||||
int32_t orientation = img->GetExifInfo()->Orientation;
|
||||
|
||||
switch (orientation)
|
||||
{
|
||||
case 3:
|
||||
case 6:
|
||||
case 8:
|
||||
case 5:
|
||||
{
|
||||
delete img;
|
||||
oFile.CloseFile();
|
||||
|
||||
CBgraFrame oFrame;
|
||||
oFrame.OpenFile(strFileName, imageType, true);
|
||||
|
||||
NSFile::CFileBinary::Remove(strFileName);
|
||||
oFrame.SaveFile(strFileName, imageType);
|
||||
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ public:
|
||||
|
||||
void SetJpegQuality(const double& value);
|
||||
|
||||
bool OpenFile(const std::wstring& strFileName, unsigned int nFileType = 0); //0 - detect
|
||||
bool OpenFile(const std::wstring& strFileName, unsigned int nFileType = 0, const bool& bIsOrientationRemove = false);
|
||||
|
||||
bool SaveFile(const std::wstring& strFileName, unsigned int nFileType);
|
||||
bool Decode(BYTE* pBuffer, int nSize, unsigned int nFileType = 0);
|
||||
@ -99,6 +99,8 @@ public:
|
||||
bool ReColorPatternImage(const std::wstring& strFileName, unsigned int rgbColorBack, unsigned int rgbColorFore);
|
||||
|
||||
void FromImage(IGrObject* pGraphics, bool bIsCopy = true);
|
||||
|
||||
static bool RemoveOrientation(const std::wstring& sFile);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user