Commit 90a0d602 authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander Trofimov

Исправлен баг с чтением картинок Jpeg2000.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@64181 954022d7-b5bf-4e40-9824-e11837661b57
parent 0ae1a5b1
......@@ -6,7 +6,7 @@
QT -= core gui
VERSION = 1.0.0.2
VERSION = 1.0.0.3
TARGET = PdfReader
TEMPLATE = lib
......
......@@ -93,7 +93,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;NOMINMAX</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<DisableSpecificWarnings>4267;4018;4244;4005;</DisableSpecificWarnings>
<AdditionalIncludeDirectories>..\DesktopEditor\agg-2.4\include;..\DesktopEditor\freetype-2.5.2\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
......
......@@ -98,7 +98,7 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\..\DesktopEditor\freetype-2.5.2\include;..\..\DesktopEditor\agg-2.4\include;..\..\DesktopEditor\cximage\zlib</AdditionalIncludeDirectories>
</ClCompile>
......@@ -131,7 +131,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\..\DesktopEditor\freetype-2.5.2\include;..\..\DesktopEditor\agg-2.4\include;..\..\DesktopEditor\cximage\zlib</AdditionalIncludeDirectories>
</ClCompile>
......
......@@ -9,11 +9,11 @@
#ifdef _DEBUG
#pragma comment(lib, "../x64/Debug/PdfReader.lib")
#pragma comment(lib, "../../DesktopEditor/Qt_build/graphics/project/debug/graphics.lib")
#pragma comment(lib, "../../SDK/lib/win_64/DEBUG/graphics.lib")
#pragma comment(lib, "../../PdfWriter/x64/Debug/PdfWriter.lib")
#else
#pragma comment(lib, "../x64/Release/PdfReader.lib")
#pragma comment(lib, "../../DesktopEditor/Qt_build/graphics/project/release/graphics.lib")
#pragma comment(lib, "../../SDK/lib/win_64/graphics.lib")
#pragma comment(lib, "../../PdfWriter/x64/Release/PdfWriter.lib")
#endif
......
......@@ -6,6 +6,8 @@
#include "../../DesktopEditor/raster/BgraFrame.h"
#include "../../DesktopEditor/raster/ImageFileFormatChecker.h"
#include "../../DesktopEditor/raster/Jp2/J2kFile.h"
namespace PdfReader
{
JPXStream::JPXStream(Stream *pStream) :
......@@ -26,12 +28,12 @@ namespace PdfReader
{
m_pStream->Reset();
// »нициализаци¤
// Инизиализация
m_lCurPos = 0;
m_lBufferSize = 0;
m_pSourceBuffer = NULL;
// оздаем темповый файл, в который сбрасываем картинку
// Создаем темповый файл, в который сбрасываем картинку
FILE *pTempFile = NULL;
std::wstring wsTempFile = L"";
......@@ -70,44 +72,38 @@ namespace PdfReader
fclose(pTempFile);
}
CBgraFrame oFrame;
if (!oFrame.OpenFile(wsTempFile, _CXIMAGE_FORMAT_JP2))
BYTE* pBufferPointer;
int nHeight = 0;
int nWidth = 0;
int nComponentsCount = 0;
Jpeg2000::CJ2kFile oJ2;
if (!oJ2.Open(&pBufferPointer, nComponentsCount, nWidth, nHeight, wsTempFile, std::wstring(L"")) || !pBufferPointer)
{
NSFile::CFileBinary::Remove(wsTempFile);
return;
}
int nHeight = oFrame.get_Height();
int nWidth = oFrame.get_Width();
int nStride = oFrame.get_Stride();
BYTE* pBufferPointer = oFrame.get_Data();
m_lBufferSize = 3 * nWidth * nHeight;
m_lBufferSize = nWidth * nHeight * nComponentsCount;
m_pSourceBuffer = (unsigned char*)MemUtilsMalloc(m_lBufferSize);
if (!m_pSourceBuffer)
{
delete[] pBufferPointer;
NSFile::CFileBinary::Remove(wsTempFile);
m_lBufferSize = 0;
return;
}
int nStride = nWidth * nComponentsCount;
unsigned char* pDst = m_pSourceBuffer;
for (int nY = 0; nY < nHeight; nY++)
{
unsigned char* pSrc = pBufferPointer + nWidth * 4 * (nHeight - nY - 1);
for (int nX = 0; nX < nWidth; nX++)
{
pDst[0] = pSrc[2];
pDst[1] = pSrc[1];
pDst[2] = pSrc[0];
pDst += 3;
pSrc += 4;
}
unsigned char* pSrc = pBufferPointer + nStride * (nHeight - 1 - nY);
::memcpy(pDst, pSrc, nStride);
pDst += nStride;
}
delete[] pBufferPointer;
NSFile::CFileBinary::Remove(wsTempFile);
}
......
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