Commit 12dee7df authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

JBig2 в PdfWriter

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62533 954022d7-b5bf-4e40-9824-e11837661b57
parent 037a8b9c
...@@ -28,7 +28,7 @@ STDMETHODIMP CASCOfficeDocFile::LoadFromFile(BSTR bsDocFile, BSTR bsDocxFilePath ...@@ -28,7 +28,7 @@ STDMETHODIMP CASCOfficeDocFile::LoadFromFile(BSTR bsDocFile, BSTR bsDocxFilePath
ffCallBack.OnProgressEx = OnProgressExFunc; ffCallBack.OnProgressEx = OnProgressExFunc;
ffCallBack.caller = this; ffCallBack.caller = this;
HRESULT hr = file.LoadFromFile(bsDocFile, bsDocxFilePath, bsXMLOptions,&ffCallBack); HRESULT hr = file.LoadFromFile(bsDocFile, bsDocxFilePath,&ffCallBack);
#ifdef _DEBUG #ifdef _DEBUG
//_CrtDumpMemoryLeaks(); //_CrtDumpMemoryLeaks();
...@@ -52,7 +52,7 @@ STDMETHODIMP CASCOfficeDocFile::SaveToFile (BSTR sDstFileName, BSTR sSrcPath, BS ...@@ -52,7 +52,7 @@ STDMETHODIMP CASCOfficeDocFile::SaveToFile (BSTR sDstFileName, BSTR sSrcPath, BS
ffCallBack.OnProgressEx = OnProgressExFunc; ffCallBack.OnProgressEx = OnProgressExFunc;
ffCallBack.caller = this; ffCallBack.caller = this;
HRESULT hr = file.SaveToFile(sSrcPath, sDstFileName, sXMLOptions, &ffCallBack); HRESULT hr = file.SaveToFile(sSrcPath, sDstFileName, &ffCallBack);
#ifdef _DEBUG #ifdef _DEBUG
//_CrtDumpMemoryLeaks(); //_CrtDumpMemoryLeaks();
......
...@@ -947,7 +947,7 @@ const char* LoadTTFontFromFile2 (Doc pPDF, std::wstring & wsFileName, unsigned ...@@ -947,7 +947,7 @@ const char* LoadTTFontFromFile2 (Doc pPDF, std::wstring & wsFileName, unsigned
// //
// return pImage; // return pImage;
//} //}
ImageDict LoadJbig2ImageFromMem(Doc pPDF, BYTE *pBuffer, unsigned int nWidth, unsigned int nHeight , int unImageCheckSum) ImageDict LoadJbig2ImageFromMem(Doc pPDF, BYTE *pBuffer, unsigned int nWidth, unsigned int nHeight, unsigned int unImageCheckSum)
{ {
ImageDict pImage = NULL; ImageDict pImage = NULL;
...@@ -965,13 +965,29 @@ ImageDict LoadJbig2ImageFromMem(Doc pPDF, BYTE *pBuffer, unsigned int nWidth, un ...@@ -965,13 +965,29 @@ ImageDict LoadJbig2ImageFromMem(Doc pPDF, BYTE *pBuffer, unsigned int nWidth, un
// Записываем во временный файл картинку в формате JBig2 // Записываем во временный файл картинку в формате JBig2
Aggplus::CImage image; Aggplus::CImage image;
image.Create(pBuffer,nWidth, nHeight, 4*nWidth); int BitsPerSample = 3;//alfa отдельно oO ???
image.Create(pBuffer,nWidth, nHeight, - BitsPerSample * nWidth);//+ flip
image.m_bExternalBuffer = true; image.m_bExternalBuffer = true;
image.SaveFile(string2std_string(wsTempFile), 16); image.SaveFile(string2std_string(wsTempFile), 21/*JBig2*/);
image.Destroy(); image.Destroy();
//монохромные с альфой ???
//if ( bAlpha )
//{
// // Создаем темповый файл для записи туда альфа-канала
// if ( 0 == DocGetTempFile( pPDF, &wsTempAlpha ) )
// {
// SetError( pPDF->oMMgr->oError, AVS_OFFICEPDFWRITER_ERROR_FILE_WRITE_ERROR, errno );
// return NULL;
// }
// CEncoderLZW oLZW( pAlphaBuffer, nWidth * nHeight, false );
// oLZW.Encode( wsTempAlpha.GetBuffer() );
//}
pImage = ImageLoadJBig2Image( pPDF->oMMgr, wsTempFile, pPDF->pXref, nWidth, nHeight, unImageCheckSum ); pImage = ImageLoadJBig2Image( pPDF->oMMgr, wsTempFile, pPDF->pXref, nWidth, nHeight, unImageCheckSum );
// Декодирование во Flate картинок в формате JBig2 отключено, из-за того что Acrobat // Декодирование во Flate картинок в формате JBig2 отключено, из-за того что Acrobat
...@@ -1186,7 +1202,6 @@ ImageDict LoadJpegImageFromMem (Doc pPDF, BYTE *pBuffer, unsigned int nWidth, ...@@ -1186,7 +1202,6 @@ ImageDict LoadJpegImageFromMem (Doc pPDF, BYTE *pBuffer, unsigned int nWidth,
if ( !HasDoc( pPDF )) if ( !HasDoc( pPDF ))
return NULL; return NULL;
// Создаем темповый файл для записи туда Jpeg // Создаем темповый файл для записи туда Jpeg
CString wsTempFile, wsTempAlpha; CString wsTempFile, wsTempAlpha;
if ( 0 == DocGetTempFile( pPDF, &wsTempFile ) ) if ( 0 == DocGetTempFile( pPDF, &wsTempFile ) )
...@@ -1207,7 +1222,6 @@ ImageDict LoadJpegImageFromMem (Doc pPDF, BYTE *pBuffer, unsigned int nWidth, ...@@ -1207,7 +1222,6 @@ ImageDict LoadJpegImageFromMem (Doc pPDF, BYTE *pBuffer, unsigned int nWidth,
image.Destroy(); image.Destroy();
if ( bAlpha ) if ( bAlpha )
{ {
// Создаем темповый файл для записи туда альфа-канала // Создаем темповый файл для записи туда альфа-канала
......
...@@ -6813,6 +6813,8 @@ bool CPdfWriterLib::ApplyTileFill() ...@@ -6813,6 +6813,8 @@ bool CPdfWriterLib::ApplyTileFill()
m_bUseImageTextureAlpha = false; m_bUseImageTextureAlpha = false;
//m_bIsWhiteBackImage = true; для теста записи монохрома
if (LoadImageFromInterface(&image, true) == S_OK) if (LoadImageFromInterface(&image, true) == S_OK)
{ {
if (m_pCurrentXObject) if (m_pCurrentXObject)
......
...@@ -2692,6 +2692,8 @@ HRESULT CPdfWriterLib::LoadImageFromInterface (IGrObject *pInterface , bool bAlp ...@@ -2692,6 +2692,8 @@ HRESULT CPdfWriterLib::LoadImageFromInterface (IGrObject *pInterface , bool bAlp
} }
} }
//bBnW = true; для теста записи монохрома
// Проверим нужен ли нам альфа-канал // Проверим нужен ли нам альфа-канал
if ( bAlpha ) if ( bAlpha )
{ {
...@@ -2769,8 +2771,8 @@ HRESULT CPdfWriterLib::LoadImageFromInterface (IGrObject *pInterface , bool bAlp ...@@ -2769,8 +2771,8 @@ HRESULT CPdfWriterLib::LoadImageFromInterface (IGrObject *pInterface , bool bAlp
if ( pOldImage ) if ( pOldImage )
m_pCurrentXObject = pOldImage; m_pCurrentXObject = pOldImage;
//else if ( bBnW ) else if ( bBnW )
// m_pCurrentXObject = LoadJbig2ImageFromInt( m_pDocument, pImage, lWidth, lHeight, unImageCheckSum);// GPL patent m_pCurrentXObject = LoadJbig2ImageFromMem( m_pDocument, pImage, lWidth, lHeight, unImageCheckSum);
else else
{ {
//m_pCurrentXObject = LoadRawImageFromMem ( m_pDocument, pImage, lWidth, lHeight, CSDeviceRGB, 8, bAlpha, pAlpha ); //m_pCurrentXObject = LoadRawImageFromMem ( m_pDocument, pImage, lWidth, lHeight, CSDeviceRGB, 8, bAlpha, pAlpha );
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories=""..\..\..\DesktopEditor\freetype-2.5.2\include"" AdditionalIncludeDirectories=""..\..\..\DesktopEditor\freetype-2.5.2\include""
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_USE_MATH_DEFINES;_USE_XMLLITE_READER_;USE_LITE_READER;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;BUILD_CONFIG_FULL_VERSION;DONT_WRITE_EMBEDDED_FONTS" PreprocessorDefinitions="WIN32;_DEBUG;_LIB;FILTER_FLATE_DECODE_ENABLED;_USE_MATH_DEFINES;_USE_XMLLITE_READER_;USE_LITE_READER;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;BUILD_CONFIG_FULL_VERSION;DONT_WRITE_EMBEDDED_FONTS"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="3" RuntimeLibrary="3"
......
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
//1 //1
//0 //0
//1 //1
//193 //196
#define INTVER 1,0,1,193 #define INTVER 1,0,1,196
#define STRVER "1,0,1,193\0" #define STRVER "1,0,1,196\0"
...@@ -2,16 +2,16 @@ ...@@ -2,16 +2,16 @@
#include "../common/File.h" #include "../common/File.h"
#include "../cximage/CxImage/ximage.h" #include "../cximage/CxImage/ximage.h"
#include "Jp2/J2kFile.h" #include "Jp2/J2kFile.h"
#include "JBig2/JBig2File.h" #include "JBig2/source/JBig2File.h"
bool CBgraFrame::OpenFile(const std::wstring& strFileName, unsigned int nFileType) bool CBgraFrame::OpenFile(const std::wstring& strFileName, unsigned int nFileType)
{ {
if (CXIMAGE_FORMAT_JP2 == nFileType) //if (CXIMAGE_FORMAT_JP2 == nFileType)
{ //{
Jpeg2000::CJ2kFile oJ2; // Jpeg2000::CJ2kFile oJ2;
return oJ2.Open(this, strFileName, std::wstring(L"")); // return oJ2.Open(this, strFileName, std::wstring(L""));
} //}
else //else
{ {
NSFile::CFileBinary oFile; NSFile::CFileBinary oFile;
if (!oFile.OpenFile(strFileName)) if (!oFile.OpenFile(strFileName))
...@@ -29,10 +29,6 @@ bool CBgraFrame::OpenFile(const std::wstring& strFileName, unsigned int nFileTyp ...@@ -29,10 +29,6 @@ bool CBgraFrame::OpenFile(const std::wstring& strFileName, unsigned int nFileTyp
bool CBgraFrame::SaveFile(const std::wstring& strFileName, unsigned int nFileType) bool CBgraFrame::SaveFile(const std::wstring& strFileName, unsigned int nFileType)
{ {
NSFile::CFileBinary oFile;
if (!oFile.CreateFileW(strFileName))
return false;
uint32_t lStride = 4 * m_lWidth; uint32_t lStride = 4 * m_lWidth;
uint32_t lBitsPerPixel = 4; uint32_t lBitsPerPixel = 4;
if (0 != m_lStride) if (0 != m_lStride)
...@@ -41,14 +37,28 @@ bool CBgraFrame::SaveFile(const std::wstring& strFileName, unsigned int nFileTyp ...@@ -41,14 +37,28 @@ bool CBgraFrame::SaveFile(const std::wstring& strFileName, unsigned int nFileTyp
lBitsPerPixel = lStride / m_lWidth; lBitsPerPixel = lStride / m_lWidth;
} }
CxImage img; if (21/*CXIMAGE_FORMAT_JBIG2*/ == nFileType)
if (!img.CreateFromArray(m_pData, m_lWidth, m_lHeight, lBitsPerPixel * 8, lStride, (m_lStride >= 0) ? true : false)) {
return false; CJBig2File jBig2File;
bool res = jBig2File.MemoryToJBig2(m_pData, m_lWidth * m_lHeight * 24, m_lWidth, m_lHeight, strFileName);
if (!img.Encode(oFile.GetFileNative(), nFileType)) return res;
return false; }
else
{
NSFile::CFileBinary oFile;
if (!oFile.CreateFileW(strFileName))
return false;
CxImage img;
if (!img.CreateFromArray(m_pData, m_lWidth, m_lHeight, lBitsPerPixel * 8, lStride, (m_lStride >= 0) ? true : false))
return false;
if (!img.Encode(oFile.GetFileNative(), nFileType))
return false;
oFile.CloseFile(); oFile.CloseFile();
}
return true; return true;
} }
bool CBgraFrame::Resize(const long& nNewWidth, const long& nNewHeight) bool CBgraFrame::Resize(const long& nNewWidth, const long& nNewHeight)
......
...@@ -38,7 +38,7 @@ bool CJBig2File::MemoryToJBig2(unsigned char* pBufferBGRA ,int BufferSize, int n ...@@ -38,7 +38,7 @@ bool CJBig2File::MemoryToJBig2(unsigned char* pBufferBGRA ,int BufferSize, int n
for ( int nY = 0; nY < nHeight; nY++ ) for ( int nY = 0; nY < nHeight; nY++ )
{ {
for ( int nX = 0; nX < nWidth; nX++, pSourceBuffer += 4 ) for ( int nX = 0; nX < nWidth; nX++, pSourceBuffer += 3 )//todooo 3 ? 4
{ {
pixSetRGBPixel( pSource, nX, nY, pSourceBuffer[ 2 ], pSourceBuffer[ 1 ], pSourceBuffer[ 0 ] ); pixSetRGBPixel( pSource, nX, nY, pSourceBuffer[ 2 ], pSourceBuffer[ 1 ], pSourceBuffer[ 0 ] );
} }
......
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