From 7eec1902ef89206ee6915ab9abcab43fcbe1c19d Mon Sep 17 00:00:00 2001 From: "Ivan.Shulga" Date: Fri, 22 Nov 2013 13:45:26 +0000 Subject: [PATCH] git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@52470 954022d7-b5bf-4e40-9824-e11837661b57 --- ASCImageStudio3/ASCImageFile3/ImageFile3.h | 129 +++------------------ ASCImageStudio3/ASCImageFile3/stdafx.h | 24 ++-- 2 files changed, 34 insertions(+), 119 deletions(-) diff --git a/ASCImageStudio3/ASCImageFile3/ImageFile3.h b/ASCImageStudio3/ASCImageFile3/ImageFile3.h index 6ea4cf4e1e..48bbecf147 100644 --- a/ASCImageStudio3/ASCImageFile3/ImageFile3.h +++ b/ASCImageStudio3/ASCImageFile3/ImageFile3.h @@ -124,7 +124,7 @@ protected: CGdiPlusInit m_oGdiPlusInit; Bitmap* m_bitmap; - ImageVideoFile::IImageVideoFile4 *m_pImageVideoFile; + int m_nMultipagedFormat; // 0 - Tiff, 1 - GIF или APNG double m_dAnimationDuration; //в миллисекундах long m_nAnimationWidth; @@ -180,7 +180,7 @@ protected: // setup default values m_bitmap = 0; - m_pImageVideoFile = NULL; + m_nMultipagedFormat = 0; m_dAnimationDuration = 1000; m_nAnimationWidth = -1; @@ -214,7 +214,6 @@ protected: } ~ImageFile3() { - RELEASEINTERFACE(m_pImageVideoFile); // delete existing memory ClearBitmap(); @@ -1198,6 +1197,7 @@ protected: else if( eFileType ==_ImageFileFormats::c_RawFotos) { +#ifndef NO_RAW_CHECKER const TCHAR * settingsXML = _T(" \ \ "); @@ -1205,19 +1205,30 @@ protected: ImageStudio::IO::Raw oRenderRaw; bLoading = oRenderRaw.FromFile( sFilePath, nFormat, &oImage, settingsXML); bVerFlip = !(bVerFlip); +#else + bLoading = FALSE; +#endif } else if( eFileType ==_ImageFileFormats::c_Sfw) { + #ifndef NO_SWF_CHECKER ImageStudio::IO::Sfw oRenderSfw; bLoading = oRenderSfw.FromFile( sFilePath, nFormat, &oImage ); bVerFlip = !(bVerFlip); +#else + bLoading = FALSE; +#endif } else if( eFileType ==_ImageFileFormats::c_Swf) { +#ifndef NO_SWF_CHECKER ImageStudio::IO::Swf oRenderSwf; bLoading = oRenderSwf.FromFile( sFilePath, nFormat, &oImage ); +#else + bLoading = FALSE; +#endif } else if( eFileType ==_ImageFileFormats::c_Svm) @@ -1676,83 +1687,8 @@ protected: } VARIANT_BOOL SaveImageAsAnimated(BSTR Path, LONG Format, void** Image, BOOL bArrayOrInterface = TRUE) { - m_nMultipagedFormat = 1; - - RELEASEINTERFACE( m_pImageVideoFile ); - ::CoCreateInstance( __uuidof(ImageVideoFile::CImageVideoFile3), NULL, CLSCTX_INPROC, __uuidof(ImageVideoFile::IImageVideoFile4), (void**)&m_pImageVideoFile ); - if ( !m_pImageVideoFile ) - return VARIANT_FALSE; - - //через VideoFormat выставляется Width, Height, ColorSpace - MediaFormat::IAVSVideoFormat *piVideoFormat = NULL; - CoCreateInstance(MediaFormat::CLSID_CAVSVideoFormat, NULL, CLSCTX_ALL, MediaFormat::IID_IAVSVideoFormat, (void**)&piVideoFormat); - if ( NULL == piVideoFormat ) - { - RELEASEINTERFACE( m_pImageVideoFile ); - return VARIANT_FALSE; - } - - //выставляем тип, по умолчанию - GIF - if( IMAGEFORMAT_PNG == Format ) - m_pImageVideoFile->put_FileType( 2 );//тип APNG - else - m_pImageVideoFile->put_FileType( 1 );//тип GIF - - //Width, Height выставляется через IAVSVideoFormat - //Duration - через свойство IAVSUncompressedVideoFrame - MediaCore::IAVSUncompressedVideoFrame* piVideoFrame = NULL; - ((IUnknown*)*Image)->QueryInterface( __uuidof(MediaCore::IAVSUncompressedVideoFrame), (void**)&piVideoFrame ); - if( NULL != piVideoFrame ) - { - //выставляем duration - piVideoFrame->put_Duration( m_dAnimationDuration ); - - //если не заданы m_nAnimationWidth или m_nAnimationHeight, то берем по первому фрейму - if( -1 == m_nAnimationWidth || -1 == m_nAnimationHeight ) - { - piVideoFrame->get_Width( &m_nAnimationWidth ); - piVideoFrame->get_Height( &m_nAnimationHeight ); - } - - //ColorSpace - CSP_BGR - без прозрачности - //CSP_BGRA - с прозрачностью, но в gif прозрачным станет черные цвет - if( IMAGEFORMAT_PNG == Format || true == m_bAnimationGifWithAlpha ) - piVideoFormat->put_ColorSpace( CSP_BGRA ); - else - piVideoFormat->put_ColorSpace( CSP_BGR ); - //выставляем width, height - piVideoFormat->put_Width( m_nAnimationWidth ); - piVideoFormat->put_Height( m_nAnimationHeight ); - piVideoFormat->put_AspectRatioX( m_nAnimationWidth ); - piVideoFormat->put_AspectRatioY( m_nAnimationHeight ); - - m_pImageVideoFile->put_videoFormat( piVideoFormat ); - } - RELEASEINTERFACE( piVideoFrame ); - RELEASEINTERFACE( piVideoFormat ); - - // Создаем файл - HRESULT hRes = m_pImageVideoFile->CreateVideoFile( Path ); - if( SUCCEEDED( hRes ) ) - { - // Пишем первый фрейм - hRes = m_pImageVideoFile->WriteVideo((IUnknown*) *Image); - // Если файл одностраничный закрываем его - if ( VARIANT_FALSE == m_TiffMultipaged ) - { - if( SUCCEEDED( hRes ) ) - hRes = m_pImageVideoFile->CloseFile(); - else - m_pImageVideoFile->CloseFile();//чтобы CloseFile не перекрыл предыдущий hRes - RELEASEINTERFACE( m_pImageVideoFile ); - m_nAnimationWidth = -1; - m_nAnimationHeight = -1; - } - } - if( SUCCEEDED( hRes ) ) - return VARIANT_TRUE; - else - return VARIANT_FALSE; + return S_OK; + } VARIANT_BOOL SaveImageAsFrame(void** Image, VARIANT_BOOL LastFrame, BOOL bArrayOrInterface = TRUE) { @@ -1880,37 +1816,8 @@ protected: // all ok return Success; } - else if ( 1 == m_nMultipagedFormat ) - { - if ( !m_pImageVideoFile ) - return VARIANT_FALSE; - - MediaCore::IAVSUncompressedVideoFrame* piVideoFrame = NULL; - ((IUnknown*)*Image)->QueryInterface( __uuidof(MediaCore::IAVSUncompressedVideoFrame), (void**)&piVideoFrame ); - if( NULL != piVideoFrame ) - { - //выставляем duration - piVideoFrame->put_Duration( m_dAnimationDuration ); - RELEASEINTERFACE( piVideoFrame ); - } - - HRESULT hRes = m_pImageVideoFile->WriteVideo((IUnknown*) *Image); - if ( VARIANT_FALSE != LastFrame ) - { - if( SUCCEEDED( hRes ) ) - hRes = m_pImageVideoFile->CloseFile(); - else - m_pImageVideoFile->CloseFile();//чтобы CloseFile не перекрыл предыдущий hRes - RELEASEINTERFACE( m_pImageVideoFile ); - m_nAnimationWidth = -1; - m_nAnimationHeight = -1; - } - if( SUCCEEDED(hRes) ) - return VARIANT_TRUE; - else - return VARIANT_FALSE; - } - return VARIANT_FALSE; + return S_OK; + } VARIANT_BOOL SaveImageAsPicture(void** Image, IPictureDisp** Picture, BOOL bArrayOrInterface = TRUE) { diff --git a/ASCImageStudio3/ASCImageFile3/stdafx.h b/ASCImageStudio3/ASCImageFile3/stdafx.h index 589987525e..e1499804d8 100644 --- a/ASCImageStudio3/ASCImageFile3/stdafx.h +++ b/ASCImageStudio3/ASCImageFile3/stdafx.h @@ -47,12 +47,20 @@ using namespace ATL; -#include "../../AVSVideoStudio3/Common/VideoFileInterface.h" +#define NO_RAW_CHECKER +#define NO_SWF_CHECKER + +#include "../../Common/VideoFileInterface.h" + +#import "../../Redist/ASCMediaCore3.dll" named_guids rename_namespace("MediaCore"), exclude("tagRECT") +#import "../../Redist/ASCMediaFormatSettings3.dll" named_guids rename_namespace("MediaFormat"), exclude("tagRECT") +#import "../../Redist/ASCGraphics.dll" named_guids rename_namespace("AVSGraphics") +#ifndef NO_SWF_CHECKER +#import "../../Redist/ASCSWFFile3.dll" named_guids rename_namespace("SWF") +#endif + +#ifndef NO_RAW_CHECKER +#import "../../Redist/ASCImageRaw3.dll" named_guids rename_namespace("ImageRaw") +#endif +#import "../../Redist/ASCImageJpeg2000.dll" named_guids rename_namespace("Jpeg2000") -#import "../../../../AVS/Redist/AVSMediaCore3.dll" named_guids rename_namespace("MediaCore"), exclude("tagRECT") -#import "../../../../AVS/Redist/AVSMediaFormatSettings3.dll" named_guids rename_namespace("MediaFormat"), exclude("tagRECT") -#import "../../../../AVS/Redist/AVSImageRaw3.dll" named_guids rename_namespace("ImageRaw") -#import "../../../../AVS/Redist/AVSImageJpeg2000.dll" named_guids rename_namespace("Jpeg2000") -#import "../../../../AVS/Redist/AVSImageVideoFile3.dll" named_guids rename_namespace("ImageVideoFile"), raw_interfaces_only exclude("IAVSVideoFileTemplate") -#import "../../../../AVS/Redist/AVSGraphics.dll" named_guids rename_namespace("AVSGraphics") -#import "../../../../AVS/Redist/AVSSWFFile3.dll" named_guids rename_namespace("SWF")