mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62161 954022d7-b5bf-4e40-9824-e11837661b57
61 lines
1.7 KiB
C++
61 lines
1.7 KiB
C++
#include "EmfObjects.h"
|
|
#include "../../../raster/ImageFileFormatChecker.h"
|
|
#include "../../../graphics/Image.h"
|
|
|
|
namespace MetaFile
|
|
{
|
|
CEmfLogBrushEx::CEmfLogBrushEx() : Color(255, 255, 255)
|
|
{
|
|
BrushStyle = BS_SOLID;
|
|
BrushHatch = HS_HORIZONTAL;
|
|
DibPatternPath = L"";
|
|
BrushAlpha = 255;
|
|
DibBuffer = NULL;
|
|
DibWidth = 0;
|
|
DibHeigth = 0;
|
|
}
|
|
CEmfLogBrushEx::~CEmfLogBrushEx()
|
|
{
|
|
if (BS_DIBPATTERN == BrushStyle && L"" != DibPatternPath)
|
|
::_wunlink(DibPatternPath.c_str());
|
|
|
|
if (DibBuffer)
|
|
delete[] DibBuffer;
|
|
}
|
|
void CEmfLogBrushEx::SetDibPattern(unsigned char* pBuffer, unsigned long ulWidth, unsigned long ulHeight)
|
|
{
|
|
DibBuffer = pBuffer;
|
|
DibWidth = ulWidth;
|
|
DibHeigth = ulHeight;
|
|
|
|
if (ulWidth <= 0 || ulHeight <= 0)
|
|
return;
|
|
|
|
unsigned long ulBufferSize = 4 * ulWidth * ulHeight;
|
|
Aggplus::CImage oImage;
|
|
BYTE* pBufferPtr = new BYTE[ulBufferSize];
|
|
oImage.Create(pBufferPtr, ulWidth, ulHeight, 4 * ulWidth);
|
|
|
|
// Ïèøåì äàííûå â pBufferPtr
|
|
for (unsigned long ulIndex = 0; ulIndex < ulBufferSize; ulIndex += 4)
|
|
{
|
|
pBufferPtr[0] = (unsigned char)pBuffer[ulIndex + 0];
|
|
pBufferPtr[1] = (unsigned char)pBuffer[ulIndex + 1];
|
|
pBufferPtr[2] = (unsigned char)pBuffer[ulIndex + 2];
|
|
pBufferPtr[3] = (unsigned char)pBuffer[ulIndex + 3];
|
|
pBufferPtr += 4;
|
|
}
|
|
|
|
FILE *pTempFile = NULL;
|
|
std::wstring wsTempFileName;
|
|
if (!WmfOpenTempFile(&wsTempFileName, &pTempFile, L"wb", L".emf0", NULL))
|
|
return;
|
|
|
|
::fclose(pTempFile);
|
|
|
|
oImage.SaveFile(wsTempFileName, _CXIMAGE_FORMAT_PNG);
|
|
|
|
BrushStyle = BS_DIBPATTERN;
|
|
DibPatternPath = wsTempFileName;
|
|
}
|
|
} |