Commit dca6daa1 authored by Ivan.Shulga's avatar Ivan.Shulga Committed by Alexander Trofimov

git-svn-id:...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@52487 954022d7-b5bf-4e40-9824-e11837661b57
parent e2d04e77
#include "stdafx.h" #include "stdafx.h"
#include "ImageFileFormatChecker.h" #include "ImageFileFormatChecker.h"
#include "..\..\..\..\Common\XmlUtils.h" #include "..\..\Common\XmlUtils.h"
#define MIN_SIZE_BUFFER 4096 #define MIN_SIZE_BUFFER 4096
#define MAX_SIZE_BUFFER 102400 #define MAX_SIZE_BUFFER 102400
......
...@@ -5,35 +5,35 @@ ...@@ -5,35 +5,35 @@
#include <Utilities.h> #include <Utilities.h>
#include "../../AVSOfficeStudio/Common/OfficeFileErrorDescription.h" #include "../../Common/OfficeFileErrorDescription.h"
#include <../AVSGraphics/cximage/CxImage/ximage.h> #include <../ASCGraphics/cximage/CxImage/ximage.h>
#include <../AVSGraphics/OfficeSvmFile/OfficeSvmFile.h> #include <../ASCGraphics/OfficeSvmFile/OfficeSvmFile.h>
#ifndef _DEBUG #ifndef _DEBUG
#pragma comment(lib, "..\\AVSGraphics\\cximage\\jasper\\Release\\jasper.lib") #pragma comment(lib, "..\\ASCGraphics\\cximage\\jasper\\Release\\jasper.lib")
#pragma comment(lib, "..\\AVSGraphics\\cximage\\jbig\\Release\\jbig.lib") #pragma comment(lib, "..\\ASCGraphics\\cximage\\jbig\\Release\\jbig.lib")
#pragma comment(lib, "..\\AVSGraphics\\cximage\\jpeg\\Release\\jpeg.lib") #pragma comment(lib, "..\\ASCGraphics\\cximage\\jpeg\\Release\\jpeg.lib")
#pragma comment(lib, "..\\AVSGraphics\\cximage\\mng\\Release\\mng.lib") #pragma comment(lib, "..\\ASCGraphics\\cximage\\mng\\Release\\mng.lib")
#pragma comment(lib, "..\\AVSGraphics\\cximage\\png\\Release\\png.lib") #pragma comment(lib, "..\\ASCGraphics\\cximage\\png\\Release\\png.lib")
#pragma comment(lib, "..\\AVSGraphics\\cximage\\raw\\Release\\libdcr.lib") #pragma comment(lib, "..\\ASCGraphics\\cximage\\raw\\Release\\libdcr.lib")
#pragma comment(lib, "..\\AVSGraphics\\cximage\\tiff\\Release\\tiff.lib") #pragma comment(lib, "..\\ASCGraphics\\cximage\\tiff\\Release\\tiff.lib")
#pragma comment(lib, "..\\AVSGraphics\\cximage\\zlib\\Release\\zlib.lib") #pragma comment(lib, "..\\ASCGraphics\\cximage\\zlib\\Release\\zlib.lib")
#pragma comment(lib, "..\\AVSGraphics\\cximage\\CxImage\\Release\\cximage.lib") #pragma comment(lib, "..\\ASCGraphics\\cximage\\CxImage\\Release\\cximage.lib")
#pragma comment(lib, "..\\AVSGraphics\\OfficeSvmFile\\Release\\OfficeSvmFile.lib") #pragma comment(lib, "..\\ASCGraphics\\OfficeSvmFile\\Release\\OfficeSvmFile.lib")
#else #else
#pragma comment(lib, "..\\AVSGraphics\\cximage\\jasper\\Debug\\jasper.lib") #pragma comment(lib, "..\\ASCGraphics\\cximage\\jasper\\Debug\\jasper.lib")
#pragma comment(lib, "..\\AVSGraphics\\cximage\\jbig\\Debug\\jbig.lib") #pragma comment(lib, "..\\ASCGraphics\\cximage\\jbig\\Debug\\jbig.lib")
#pragma comment(lib, "..\\AVSGraphics\\cximage\\jpeg\\Debug\\jpeg.lib") #pragma comment(lib, "..\\ASCGraphics\\cximage\\jpeg\\Debug\\jpeg.lib")
#pragma comment(lib, "..\\AVSGraphics\\cximage\\mng\\Debug\\mng.lib") #pragma comment(lib, "..\\ASCGraphics\\cximage\\mng\\Debug\\mng.lib")
#pragma comment(lib, "..\\AVSGraphics\\cximage\\png\\Debug\\png.lib") #pragma comment(lib, "..\\ASCGraphics\\cximage\\png\\Debug\\png.lib")
#pragma comment(lib, "..\\AVSGraphics\\cximage\\raw\\Debug\\libdcr.lib") #pragma comment(lib, "..\\ASCGraphics\\cximage\\raw\\Debug\\libdcr.lib")
#pragma comment(lib, "..\\AVSGraphics\\cximage\\tiff\\Debug\\tiff.lib") #pragma comment(lib, "..\\ASCGraphics\\cximage\\tiff\\Debug\\tiff.lib")
#pragma comment(lib, "..\\AVSGraphics\\cximage\\zlib\\Debug\\zlib.lib") #pragma comment(lib, "..\\ASCGraphics\\cximage\\zlib\\Debug\\zlib.lib")
#pragma comment(lib, "..\\AVSGraphics\\cximage\\CxImage\\Debug\\cximage.lib") #pragma comment(lib, "..\\ASCGraphics\\cximage\\CxImage\\Debug\\cximage.lib")
#pragma comment(lib, "..\\AVSGraphics\\OfficeSvmFile\\Debug\\OfficeSvmFile.lib") #pragma comment(lib, "..\\ASCGraphics\\OfficeSvmFile\\Debug\\OfficeSvmFile.lib")
#endif #endif
...@@ -133,7 +133,7 @@ namespace ImageStudio ...@@ -133,7 +133,7 @@ namespace ImageStudio
{ {
Reset(); Reset();
CoCreateInstance( __uuidof(AVSGraphics::CAVSMetafile), NULL, CLSCTX_ALL, __uuidof(AVSGraphics::IAVSMetafile), (void**)(&m_pAVSMetafile) ); CoCreateInstance( __uuidof(AVSGraphics::CASCMetafile), NULL, CLSCTX_ALL, __uuidof(AVSGraphics::IASCMetafile), (void**)(&m_pAVSMetafile) );
if ( NULL == m_pAVSMetafile ) if ( NULL == m_pAVSMetafile )
return false; return false;
...@@ -155,7 +155,7 @@ namespace ImageStudio ...@@ -155,7 +155,7 @@ namespace ImageStudio
m_pAVSMetafile->put_Width( m_lWidth ); m_pAVSMetafile->put_Width( m_lWidth );
m_pAVSMetafile->put_Height( m_lHeight ); m_pAVSMetafile->put_Height( m_lHeight );
HRESULT hr = pImage->raw_DrawOnRenderer( (AVSGraphics::IAVSRenderer *)m_pAVSMetafile, 0, 0, m_lWidth, m_lHeight ); HRESULT hr = pImage->raw_DrawOnRenderer( (AVSGraphics::IASCRenderer *)m_pAVSMetafile, 0, 0, m_lWidth, m_lHeight );
if( FAILED(hr) ) if( FAILED(hr) )
bSuccess = false; bSuccess = false;
} }
...@@ -169,7 +169,7 @@ namespace ImageStudio ...@@ -169,7 +169,7 @@ namespace ImageStudio
{ {
Reset(); Reset();
CoCreateInstance( __uuidof(AVSGraphics::CAVSMetafile), NULL, CLSCTX_ALL, __uuidof(AVSGraphics::IAVSMetafile), (void**)(&m_pAVSMetafile) ); CoCreateInstance( __uuidof(AVSGraphics::CASCMetafile), NULL, CLSCTX_ALL, __uuidof(AVSGraphics::IASCMetafile), (void**)(&m_pAVSMetafile) );
if ( NULL == m_pAVSMetafile ) if ( NULL == m_pAVSMetafile )
return false; return false;
...@@ -191,7 +191,7 @@ namespace ImageStudio ...@@ -191,7 +191,7 @@ namespace ImageStudio
m_pAVSMetafile->put_Width( m_lWidth ); m_pAVSMetafile->put_Width( m_lWidth );
m_pAVSMetafile->put_Height( m_lHeight ); m_pAVSMetafile->put_Height( m_lHeight );
HRESULT hr = pImage->raw_DrawOnRenderer( (AVSGraphics::IAVSRenderer *)m_pAVSMetafile, 0, 0, m_lWidth, m_lHeight ); HRESULT hr = pImage->raw_DrawOnRenderer( (AVSGraphics::IASCRenderer *)m_pAVSMetafile, 0, 0, m_lWidth, m_lHeight );
if( FAILED(hr) ) if( FAILED(hr) )
bSuccess = false; bSuccess = false;
} }
...@@ -207,9 +207,9 @@ namespace ImageStudio ...@@ -207,9 +207,9 @@ namespace ImageStudio
if( !m_pAVSMetafile ) if( !m_pAVSMetafile )
return false; return false;
AVSGraphics::IAVSGraphicsRenderer* pGrRenderer = NULL; AVSGraphics::IASCGraphicsRenderer* pGrRenderer = NULL;
CoCreateInstance(__uuidof( AVSGraphics::CAVSGraphicsRenderer), NULL ,CLSCTX_INPROC_SERVER, __uuidof(AVSGraphics::IAVSGraphicsRenderer), (void **)&pGrRenderer ); CoCreateInstance(__uuidof( AVSGraphics::CASCGraphicsRenderer), NULL ,CLSCTX_INPROC_SERVER, __uuidof(AVSGraphics::IASCGraphicsRenderer), (void **)&pGrRenderer );
if( !pGrRenderer ) if( !pGrRenderer )
return false; return false;
...@@ -234,9 +234,9 @@ namespace ImageStudio ...@@ -234,9 +234,9 @@ namespace ImageStudio
if( !m_pAVSMetafile ) if( !m_pAVSMetafile )
return NULL; return NULL;
AVSGraphics::IAVSGraphicsRenderer* pGrRenderer = NULL; AVSGraphics::IASCGraphicsRenderer* pGrRenderer = NULL;
CoCreateInstance(__uuidof( AVSGraphics::CAVSGraphicsRenderer), NULL ,CLSCTX_INPROC_SERVER, __uuidof(AVSGraphics::IAVSGraphicsRenderer), (void **)&pGrRenderer ); CoCreateInstance(__uuidof( AVSGraphics::CASCGraphicsRenderer), NULL ,CLSCTX_INPROC_SERVER, __uuidof(AVSGraphics::IASCGraphicsRenderer), (void **)&pGrRenderer );
if( !pGrRenderer ) if( !pGrRenderer )
return NULL; return NULL;
...@@ -410,7 +410,7 @@ namespace ImageStudio ...@@ -410,7 +410,7 @@ namespace ImageStudio
return (( 0x1001 == lType ) || ( 0x1002 == lType ) || (0x1004 == lType)); return (( 0x1001 == lType ) || ( 0x1002 == lType ) || (0x1004 == lType));
} }
IMediaFrame* ConvertToBitmap( AVSGraphics::IAVSGraphicsRenderer* pGrRenderer ) IMediaFrame* ConvertToBitmap( AVSGraphics::IASCGraphicsRenderer* pGrRenderer )
{ {
HRESULT hr; HRESULT hr;
...@@ -516,7 +516,7 @@ namespace ImageStudio ...@@ -516,7 +516,7 @@ namespace ImageStudio
private: private:
AVSGraphics::IAVSMetafile *m_pAVSMetafile; AVSGraphics::IASCMetafile *m_pAVSMetafile;
LONG m_lWidth; LONG m_lWidth;
LONG m_lHeight; LONG m_lHeight;
...@@ -4612,42 +4612,7 @@ namespace ImageStudio ...@@ -4612,42 +4612,7 @@ namespace ImageStudio
public: public:
virtual BOOL FromFile(const CString& strFilePath, int& nFormat, ImageStudio::Core::Image* pResultImage, const CString& strSettingXML) virtual BOOL FromFile(const CString& strFilePath, int& nFormat, ImageStudio::Core::Image* pResultImage, const CString& strSettingXML)
{ {
//return FALSE; return FALSE;
BOOL bRetValue = TRUE;
BSTR bsFilePath = strFilePath.AllocSysString();
ImageRaw::IImageRaw3 *pRawFile;
::CoCreateInstance( ImageRaw::CLSID_CImageRaw3, NULL, CLSCTX_INPROC, ImageRaw::IID_IImageRaw3, (void**)&pRawFile );
if ( !pRawFile )
return FALSE;
pRawFile->raw_OpenFile(bsFilePath);
::SysFreeString(bsFilePath);
IUnknown *pResImage = NULL;
BSTR bsSettingXML = strSettingXML.AllocSysString();
if ( !(_tcslen(strSettingXML) > 0) )
pRawFile->raw_GetThumbnailImage( &pResImage );
else
{
pRawFile->raw_ApplyXML( bsSettingXML, 0);
pRawFile->raw_GetPreviewImage( &pResImage );
}
::SysFreeString(bsSettingXML);
bRetValue = pResultImage->FromMediaData( pResImage, TRUE );
pRawFile->raw_CloseFile();
RELEASEINTERFACE(pRawFile);
RELEASEINTERFACE(pResImage);
return bRetValue;
} }
}; };
...@@ -6145,26 +6110,17 @@ namespace ImageStudio ...@@ -6145,26 +6110,17 @@ namespace ImageStudio
class SwfImageFile class SwfImageFile
{ {
private: private:
SWF::ISWFFile3* m_pSwfFile;
SWF::ISWFFileExtractImages* m_pSwfImages;
DWORD m_dwCountImages;
public: public:
SwfImageFile() SwfImageFile()
{ {
m_pSwfFile = NULL;
m_pSwfImages = NULL;
m_dwCountImages = 0;
} }
SwfImageFile( const CString& sFilePath ) SwfImageFile( const CString& sFilePath )
{ {
m_pSwfFile = NULL;
m_pSwfImages = NULL;
m_dwCountImages = 0;
Open( sFilePath );
} }
...@@ -6175,128 +6131,22 @@ namespace ImageStudio ...@@ -6175,128 +6131,22 @@ namespace ImageStudio
void Release() void Release()
{ {
if( m_pSwfImages )
{
m_pSwfImages->Release();
m_pSwfImages = NULL;
}
if( m_pSwfFile )
{
m_pSwfFile->raw_CloseFile();
m_pSwfFile->Release();
m_pSwfFile = NULL;
}
m_dwCountImages = 0;
} }
BOOL Open( const CString& sFilePath ) BOOL Open( const CString& sFilePath )
{ {
Release(); return FALSE;
BOOL bSuccess = FALSE;
SWF::ISWFFile3* pFile = NULL;
::CoCreateInstance( SWF::CLSID_CSWFFile3, NULL, CLSCTX_ALL, SWF::IID_ISWFFile3, (void**)&pFile );
if( pFile )
{
BSTR bsParam = ::SysAllocString( L"SWF_IMAGES" );
if( bsParam )
{
VARIANT vParam;
::memset( &vParam, 0, sizeof(VARIANT) );
pFile->raw_SetAdditionalParam( bsParam, vParam );
BSTR bsFilePath = sFilePath.AllocSysString();
if( bsFilePath )
{
HRESULT hr = pFile->raw_OpenFile( bsFilePath );
if( SUCCEEDED(hr) )
{
SWF::ISWFFileExtractImages* pImages = NULL;
pFile->QueryInterface( SWF::IID_ISWFFileExtractImages, (void**)&pImages );
if( pImages )
{
unsigned int nCountImages = 0;
pImages->raw_GetImagesCount( &nCountImages );
if( nCountImages > 0 )
{
m_pSwfFile = pFile;
m_pSwfImages = pImages;
m_dwCountImages = nCountImages;
bSuccess = TRUE;
}
if( !bSuccess )
pImages->Release();
}
if( !bSuccess )
pFile->raw_CloseFile();
}
::SysFreeString( bsFilePath );
}
::SysFreeString( bsParam );
}
if( !bSuccess )
pFile->Release();
}
return bSuccess;
} }
IMediaFrame* GetImage( DWORD nImage ) const IMediaFrame* GetImage( DWORD nImage ) const
{ {
if( nImage >= m_dwCountImages ) return NULL;
return NULL;
if( !m_pSwfImages )
return NULL;
IMediaFrame* pResultFrame = NULL;
SWF::SWFImageDataType eImageType = SWF::SWFImageUnknown;
IUnknown* pDataImage = NULL;
m_pSwfImages->raw_GetImageData( nImage, &eImageType, &pDataImage );
if( pDataImage )
{
MediaCore::IAVSMediaData* pMediaData = NULL;
pDataImage->QueryInterface( MediaCore::IID_IAVSMediaData, (void**)&pMediaData );
if( pMediaData )
{
BYTE* pBuffer = NULL;
long lDataSize = 0;
pMediaData->get_Buffer( &pBuffer );
pMediaData->get_DataSize( &lDataSize );
pResultFrame = CreateImageFromBuffer( pBuffer, lDataSize );
pMediaData->Release();
}
pDataImage->Release();
}
return pResultFrame;
} }
IMediaFrame* GetFirstValidImage() const IMediaFrame* GetFirstValidImage() const
{ {
for( DWORD i = 0; i < m_dwCountImages; ++i )
{
IMediaFrame* pFrame = GetImage( i );
if( pFrame )
return pFrame;
}
return NULL; return NULL;
} }
...@@ -6304,40 +6154,14 @@ namespace ImageStudio ...@@ -6304,40 +6154,14 @@ namespace ImageStudio
DWORD GetCountImages() const DWORD GetCountImages() const
{ {
return m_dwCountImages; return 0;
} }
private: private:
IMediaFrame* CreateImageFromBuffer( BYTE* pBuffer, long lBufSize ) const IMediaFrame* CreateImageFromBuffer( BYTE* pBuffer, long lBufSize ) const
{ {
if( !pBuffer || lBufSize <= 0 ) return NULL;
return NULL;
IStream* pStream = NULL;
::CreateStreamOnHGlobal( NULL, FALSE, &pStream );
if( !pStream )
return NULL;
ULONG lWritten = 0;
HRESULT hr = pStream->Write( pBuffer, lBufSize, &lWritten );
if( FAILED(hr) || lWritten != lBufSize )
{
pStream->Release();
return NULL;
}
LARGE_INTEGER lStartPos;
lStartPos.QuadPart = 0;
pStream->Seek( lStartPos, 0, 0 );
IMediaFrame* pResultFrame = Utils::CreateBgraFrameFromGdiplusImage( pStream );
pStream->Release();
return pResultFrame;
} }
}; };
...@@ -6345,15 +6169,7 @@ namespace ImageStudio ...@@ -6345,15 +6169,7 @@ namespace ImageStudio
public: public:
virtual BOOL FromFile(const CString& strFilePath, int& nFormat, ImageStudio::Core::Image* pResultImage, int nFrame = 0 ) virtual BOOL FromFile(const CString& strFilePath, int& nFormat, ImageStudio::Core::Image* pResultImage, int nFrame = 0 )
{ {
SwfImageFile pFile( strFilePath ); return FALSE;
IMediaFrame* pImage = pFile.GetImage( nFrame );
BOOL bRetValue = pResultImage->FromMediaData( (IUnknown *)pImage, FALSE );
RELEASEINTERFACE( pImage );
return bRetValue;
} }
virtual BOOL ToFile(ImageStudio::Core::Image* pSourceImage, const CString& strFilePath, int nFormat) virtual BOOL ToFile(ImageStudio::Core::Image* pSourceImage, const CString& strFilePath, int nFormat)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment