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

открытие картинок формата WindowsHD Photo https://ru.wikipedia.org/wiki/JPEG_XR

ТОЛЬКО для windows систем, работа по unix/linux ЗАПРЕЩЕНА

открытие будет только по наличию в системе длл - windowcodecs.dll (net 3.5)

файл для теста Удивительная история рождения MS-Dos.docx

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@57778 954022d7-b5bf-4e40-9824-e11837661b57
parent b5aba0d2
......@@ -78,7 +78,7 @@
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="false"
AdditionalDependencies="graydither.lib Msimg32.lib"
AdditionalDependencies="graydither.lib Msimg32.lib Windowscodecs.lib"
OutputFile="$(OutDir)/ASCImageFile3.dll"
LinkIncremental="2"
AdditionalLibraryDirectories="Libs"
......@@ -178,7 +178,7 @@
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="false"
AdditionalDependencies="graydither.lib Msimg32.lib"
AdditionalDependencies="graydither.lib Msimg32.lib Windowscodecs.lib"
OutputFile="$(OutDir)/ASCImageFile3.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="Libs"
......
......@@ -1155,6 +1155,12 @@ protected:
ImageStudio::IO::Tga oReaderTga;
bLoading = oReaderTga.FromFile( sFilePath, nFormat, &oImage );
}
else
if( eFileType ==_ImageFileFormats::c_Wdp)
{
ImageStudio::IO::Wdp oReaderWdp;
bLoading = oReaderWdp.FromFile( sFilePath, nFormat, &oImage );
}
else
if( eFileType ==_ImageFileFormats::c_Pcx)
{
......
......@@ -52,10 +52,10 @@ using namespace ATL;
#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")
#import "../../Redist/ASCImageJpeg2000.dll" named_guids rename_namespace("Jpeg2000")
#import "../../Redist/ASCMediaCore3.dll" named_guids rename_namespace("MediaCore"), exclude("tagRECT") raw_interfaces_only
#import "../../Redist/ASCMediaFormatSettings3.dll" named_guids rename_namespace("MediaFormat"), exclude("tagRECT") raw_interfaces_only
#import "../../Redist/ASCGraphics.dll" named_guids rename_namespace("AVSGraphics") raw_interfaces_only
#import "../../Redist/ASCImageJpeg2000.dll" named_guids rename_namespace("Jpeg2000") raw_interfaces_only
#ifndef NO_SWF_CHECKER
#import "../../Redist/ASCSWFFile3.dll" named_guids rename_namespace("SWF")
......
......@@ -2,6 +2,6 @@
//3
//4
//0
//83
#define INTVER 3,4,0,83
#define STRVER "3,4,0,83\0"
//90
#define INTVER 3,4,0,90
#define STRVER "3,4,0,90\0"
......@@ -78,7 +78,7 @@
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="true"
AdditionalDependencies=" Msimg32.lib"
AdditionalDependencies=" Msimg32.lib Windowscodecs.lib"
OutputFile="$(OutDir)/ASCImageStudio3.dll"
LinkIncremental="2"
AdditionalLibraryDirectories="../Common/libs/Debug"
......@@ -186,7 +186,7 @@
Name="VCLinkerTool"
RegisterOutput="true"
IgnoreImportLibrary="true"
AdditionalDependencies=" Msimg32.lib"
AdditionalDependencies=" Msimg32.lib Windowscodecs.lib"
OutputFile="$(OutDir)/ASCImageStudio3.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\Common\libs\Release\"
......
......@@ -2,6 +2,6 @@
//3
//4
//0
//82
#define INTVER 3,4,0,82
#define STRVER "3,4,0,82\0"
//84
#define INTVER 3,4,0,84
#define STRVER "3,4,0,84\0"
......@@ -23,7 +23,8 @@ enum _ImageFileFormats
c_Swf,
c_Wbz,
c_Wbc,
c_Svm
c_Svm,
c_Wdp
};
struct _ImageFileExtension
......@@ -87,7 +88,10 @@ static _ImageFileExtension tableSupportImageFormats[] =
{_T("wbz"), c_Wbz},
{_T("wbc"), c_Wbc},
{_T("svm"), c_Svm},
{_T("mj2"), c_Jpeg2000}
{_T("mj2"), c_Jpeg2000},
{_T("wdp"), c_Wdp},
{_T("hdp"), c_Wdp},
{_T("jxr"), c_Wdp}
};
......
......@@ -37,6 +37,8 @@
#endif
#include "Wincodec.h"
namespace ImageStudio
{
......@@ -1385,6 +1387,78 @@ namespace ImageStudio
return Utils::ToFile(pSourceImage, strFilePath, nFormat, TRUE, _T("image/gif"), NULL);
}
};
#define DIB_WIDTHBYTES(bits) ((((bits) + 31)>>5)<<2)
class Wdp
{
public:
virtual BOOL FromFile(const CString& strFilePath, int& nFormat, ImageStudio::Core::Image* pResultImage)
{
IWICImagingFactory *m_pIWICFactory = NULL;
HRESULT hr = CoCreateInstance(CLSID_WICImagingFactory,NULL,CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&m_pIWICFactory));
if (hr || m_pIWICFactory ==NULL) return FALSE;
IWICBitmapDecoder *pDecoder = NULL;
hr = m_pIWICFactory->CreateDecoderFromFilename(strFilePath, &CLSID_WICWmpDecoder,GENERIC_READ,WICDecodeMetadataCacheOnDemand,&pDecoder);
IWICBitmapFrameDecode *pFrame = NULL;
if (SUCCEEDED(hr && pDecoder))
{
hr = pDecoder->GetFrame(0, &pFrame);
pDecoder->Release();
}
UINT Width =0, Height =0;
IWICFormatConverter *m_pConvertedFrame = NULL;
if (pFrame)
{
m_pIWICFactory->CreateFormatConverter(&m_pConvertedFrame);
m_pConvertedFrame->Initialize(
pFrame, // Source frame to convert
GUID_WICPixelFormat32bppBGR, // The desired pixel format
WICBitmapDitherTypeNone, // The desired dither pattern
NULL, // The desired palette
0.f, // The desired alpha threshold
WICBitmapPaletteTypeCustom // Palette translation type
);
pFrame->GetSize(&Width, &Height);
pFrame->Release();
}
IMediaFrame* pMediaFrame = NULL;
if (m_pConvertedFrame)
{
BYTE* pPixels = NULL;
pMediaFrame = CreateFrame( Width, Height, CSP_BGRA | CSP_VFLIP, &pPixels);
if( pFrame &&pPixels)
{
UINT nStride = DIB_WIDTHBYTES(Width * 32);
UINT nImage = nStride * Height;
m_pConvertedFrame->CopyPixels(NULL,nStride,nImage,pPixels);
}
m_pConvertedFrame->Release();
}
m_pIWICFactory->Release();
BOOL bRetValue = pResultImage->FromMediaData( (IUnknown *)pMediaFrame, FALSE );
RELEASEINTERFACE( pMediaFrame );
return bRetValue;
}
virtual BOOL ToFile(ImageStudio::Core::Image* pSourceImage, const CString& strFilePath, int nFormat)
{
return FALSE;
}
};
class Jpeg
{
public:
......@@ -1410,8 +1484,17 @@ namespace ImageStudio
if( !pFile )
return FALSE;
BOOL bSuccess = SaveToFile( pFile, pSourceImage->GetBuffer(), pSourceImage->GetWidth(), pSourceImage->GetHeight(), pSourceImage->GetWidth() * 4, nQuality );
BYTE *pPixels = pSourceImage->GetBuffer();
BOOL bSuccess = FALSE;
if (pPixels)
{
bSuccess = SaveToFile( pFile, pSourceImage->GetBuffer(), pSourceImage->GetWidth(), pSourceImage->GetHeight(), pSourceImage->GetWidth() * 4, nQuality/*,SubSampling */);
}
else
{
bSuccess = SaveToFile( pFile, pSourceImage->GetMediaData().GetMediaData(FALSE), nQuality/*,SubSampling*/ );
}
fclose(pFile);
return bSuccess;
......@@ -7145,16 +7228,16 @@ namespace ImageStudio
int G = 128 - 100 * U - 208 * V;
int B = 128 + 516 * U;
dst[0] = IntToByte( (Y + B) >> 8 );
dst[1] = IntToByte( (Y + G) >> 8 );
dst[2] = IntToByte( (Y + R) >> 8 );
dst[0] = _IntToByte( (Y + B) >> 8 );
dst[1] = _IntToByte( (Y + G) >> 8 );
dst[2] = _IntToByte( (Y + R) >> 8 );
dst[3] = 255;
Y = (int(src[3]) - 16) * 298;
dst[4] = IntToByte( (Y + B) >> 8 );
dst[5] = IntToByte( (Y + G) >> 8 );
dst[6] = IntToByte( (Y + R) >> 8 );
dst[4] = _IntToByte( (Y + B) >> 8 );
dst[5] = _IntToByte( (Y + G) >> 8 );
dst[6] = _IntToByte( (Y + R) >> 8 );
dst[7] = 255;
//
......@@ -7166,16 +7249,16 @@ namespace ImageStudio
G = 128 - 100 * U - 208 * V;
B = 128 + 516 * U;
dst[0 + nWidth * 4] = IntToByte( (Y + B) >> 8 );
dst[1 + nWidth * 4] = IntToByte( (Y + G) >> 8 );
dst[2 + nWidth * 4] = IntToByte( (Y + R) >> 8 );
dst[0 + nWidth * 4] = _IntToByte( (Y + B) >> 8 );
dst[1 + nWidth * 4] = _IntToByte( (Y + G) >> 8 );
dst[2 + nWidth * 4] = _IntToByte( (Y + R) >> 8 );
dst[3 + nWidth * 4] = 255;
Y = (int(src[3 + offset]) - 16) * 298;
dst[4 + nWidth * 4] = IntToByte( (Y + B) >> 8 );
dst[5 + nWidth * 4] = IntToByte( (Y + G) >> 8 );
dst[6 + nWidth * 4] = IntToByte( (Y + R) >> 8 );
dst[4 + nWidth * 4] = _IntToByte( (Y + B) >> 8 );
dst[5 + nWidth * 4] = _IntToByte( (Y + G) >> 8 );
dst[6 + nWidth * 4] = _IntToByte( (Y + R) >> 8 );
dst[7 + nWidth * 4] = 255;
}
}
......@@ -7205,16 +7288,16 @@ namespace ImageStudio
int G = 128 - 100 * U - 208 * V;
int B = 128 + 516 * U;
dst[0] = IntToByte( (Y + B) >> 8 );
dst[1] = IntToByte( (Y + G) >> 8 );
dst[2] = IntToByte( (Y + R) >> 8 );
dst[0] = _IntToByte( (Y + B) >> 8 );
dst[1] = _IntToByte( (Y + G) >> 8 );
dst[2] = _IntToByte( (Y + R) >> 8 );
dst[3] = 255;
Y = (int(src[3]) - 16) * 298;
dst[4] = IntToByte( (Y + B) >> 8 );
dst[5] = IntToByte( (Y + G) >> 8 );
dst[6] = IntToByte( (Y + R) >> 8 );
dst[4] = _IntToByte( (Y + B) >> 8 );
dst[5] = _IntToByte( (Y + G) >> 8 );
dst[6] = _IntToByte( (Y + R) >> 8 );
dst[7] = 255;
}
}
......@@ -7245,30 +7328,30 @@ namespace ImageStudio
int G = 128 - 100 * U - 208 * V;
int B = 128 + 516 * U;
dst[0] = IntToByte( (Y + B) >> 8 );
dst[1] = IntToByte( (Y + G) >> 8 );
dst[2] = IntToByte( (Y + R) >> 8 );
dst[0] = _IntToByte( (Y + B) >> 8 );
dst[1] = _IntToByte( (Y + G) >> 8 );
dst[2] = _IntToByte( (Y + R) >> 8 );
dst[3] = 255;
Y = (int(pY[1]) - 16) * 298;
dst[4] = IntToByte( (Y + B) >> 8 );
dst[5] = IntToByte( (Y + G) >> 8 );
dst[6] = IntToByte( (Y + R) >> 8 );
dst[4] = _IntToByte( (Y + B) >> 8 );
dst[5] = _IntToByte( (Y + G) >> 8 );
dst[6] = _IntToByte( (Y + R) >> 8 );
dst[7] = 255;
Y = (int(pY[0 + nWidth]) - 16) * 298;
dst[0 + nWidth * 4] = IntToByte( (Y + B) >> 8 );
dst[1 + nWidth * 4] = IntToByte( (Y + G) >> 8 );
dst[2 + nWidth * 4] = IntToByte( (Y + R) >> 8 );
dst[0 + nWidth * 4] = _IntToByte( (Y + B) >> 8 );
dst[1 + nWidth * 4] = _IntToByte( (Y + G) >> 8 );
dst[2 + nWidth * 4] = _IntToByte( (Y + R) >> 8 );
dst[3 + nWidth * 4] = 255;
Y = (int(pY[1 + nWidth]) - 16) * 298;
dst[4 + nWidth * 4] = IntToByte( (Y + B) >> 8 );
dst[5 + nWidth * 4] = IntToByte( (Y + G) >> 8 );
dst[6 + nWidth * 4] = IntToByte( (Y + R) >> 8 );
dst[4 + nWidth * 4] = _IntToByte( (Y + B) >> 8 );
dst[5 + nWidth * 4] = _IntToByte( (Y + G) >> 8 );
dst[6 + nWidth * 4] = _IntToByte( (Y + R) >> 8 );
dst[7 + nWidth * 4] = 255;
}
}
......
......@@ -352,9 +352,9 @@ namespace ImageStudio
// nG = int(nG * dK + 0.5);
// nB = int(nB * dK + 0.5);
// pPixels[0] = IntToByte(nB);
// pPixels[1] = IntToByte(nG);
// pPixels[2] = IntToByte(nR);
// pPixels[0] = _IntToByte(nB);
// pPixels[1] = _IntToByte(nG);
// pPixels[2] = _IntToByte(nR);
//}
/* */
......@@ -379,9 +379,9 @@ namespace ImageStudio
nG = (nG * nK + 512) >> 10;
nB = (nB * nK + 512) >> 10;
pPixels[0] = IntToByte(nB);
pPixels[1] = IntToByte(nG);
pPixels[2] = IntToByte(nR);
pPixels[0] = _IntToByte(nB);
pPixels[1] = _IntToByte(nG);
pPixels[2] = _IntToByte(nR);
}
return ImageStudio::Transforms::Core::c_nErrorNone;
......@@ -448,9 +448,9 @@ namespace ImageStudio
// nG = int(nG * dK + 0.5);
// nB = int(nB * dK + 0.5);
// pPixels[0] = IntToByte(nB);
// pPixels[1] = IntToByte(nG);
// pPixels[2] = IntToByte(nR);
// pPixels[0] = _IntToByte(nB);
// pPixels[1] = _IntToByte(nG);
// pPixels[2] = _IntToByte(nR);
//}
/* */
......@@ -477,9 +477,9 @@ namespace ImageStudio
nG = (nG * nK + 512) >> 10;
nB = (nB * nK + 512) >> 10;
pPixels[0] = IntToByte(nB);
pPixels[1] = IntToByte(nG);
pPixels[2] = IntToByte(nR);
pPixels[0] = _IntToByte(nB);
pPixels[1] = _IntToByte(nG);
pPixels[2] = _IntToByte(nR);
}
return ImageStudio::Transforms::Core::c_nErrorNone;
......@@ -802,9 +802,9 @@ namespace ImageStudio
nG = int(nG * dFactor + dOffset);
nB = int(nB * dFactor + dOffset);
pPixels[0] = IntToByte(nB);
pPixels[1] = IntToByte(nG);
pPixels[2] = IntToByte(nR);
pPixels[0] = _IntToByte(nB);
pPixels[1] = _IntToByte(nG);
pPixels[2] = _IntToByte(nR);
}
return ImageStudio::Transforms::Core::c_nErrorNone;
......@@ -891,9 +891,9 @@ namespace ImageStudio
nG = int(nG * (nG * dFactor + dOffset));
nB = int(nB * (nB * dFactor + dOffset));
pPixels[0] = IntToByte(nB);
pPixels[1] = IntToByte(nG);
pPixels[2] = IntToByte(nR);
pPixels[0] = _IntToByte(nB);
pPixels[1] = _IntToByte(nG);
pPixels[2] = _IntToByte(nR);
}
return ImageStudio::Transforms::Core::c_nErrorNone;
......@@ -1183,7 +1183,7 @@ namespace ImageStudio
GetBValue(nColor),
GetGValue(nColor),
GetRValue(nColor),
IntToByte(alpha)
_IntToByte(alpha)
};
IppiSize oImageSize = {nWidth, nHeight};
......@@ -1867,7 +1867,7 @@ namespace ImageStudio
if (nAlpha == 0 || dCompleteness < 0.0001)
return c_nErrorNone;
double dAlpha = IntToByte( nAlpha ) / 255.0;
double dAlpha = _IntToByte( nAlpha ) / 255.0;
if (dCompleteness >= 0.999 || nWidth < 2 || nHeight < 2)
return BGRA_Fog( pBGRA, nWidth, nHeight, nColor, dAlpha );
......@@ -3220,7 +3220,7 @@ namespace ImageStudio
// Table[nIndex] = BYTE((unsigned)(nIndex * (255 + Level) + 127) * 0x8081u >> 23);
//}
Table[nIndex] = IntToByte( nIndex + Level );
Table[nIndex] = _IntToByte( nIndex + Level );
}
// apply table
......@@ -3247,9 +3247,9 @@ namespace ImageStudio
// compose table
for (int i = 0; i < 256; ++i)
{
Table[2][i] = IntToByte( i + LevelR );
Table[1][i] = IntToByte( i + LevelG );
Table[0][i] = IntToByte( i + LevelB );
Table[2][i] = _IntToByte( i + LevelR );
Table[1][i] = _IntToByte( i + LevelG );
Table[0][i] = _IntToByte( i + LevelB );
}
// apply table
......@@ -3278,7 +3278,7 @@ namespace ImageStudio
// compose table
for (int i = 0; i < 256; ++i)
{
Table[i] = IntToByte( int(127.5 + (i - 127.5)*dLevel) );
Table[i] = _IntToByte( int(127.5 + (i - 127.5)*dLevel) );
}
// apply table
......@@ -3588,9 +3588,9 @@ namespace ImageStudio
// compose table
for( int i = 0; i < 256; ++i )
{
Table[2][i] = IntToByte(i + nDeltaRed);
Table[1][i] = IntToByte(i + nDeltaGreen);
Table[0][i] = IntToByte(i + nDeltaBlue);
Table[2][i] = _IntToByte(i + nDeltaRed);
Table[1][i] = _IntToByte(i + nDeltaGreen);
Table[0][i] = _IntToByte(i + nDeltaBlue);
}
// apply table
......@@ -3606,9 +3606,9 @@ namespace ImageStudio
if( Type < 0 || Type > 3 )
return c_nErrorNone;
Blue = IntToByte( Blue );
Green = IntToByte( Green );
Red = IntToByte( Red );
Blue = _IntToByte( Blue );
Green = _IntToByte( Green );
Red = _IntToByte( Red );
// color tables
BYTE oTableB[256];
......@@ -4062,9 +4062,9 @@ namespace ImageStudio
g = int( (g - gray) * dLevel + g + 0.5 );
r = int( (r - gray) * dLevel + r + 0.5 );
src[0] = IntToByte( b );
src[1] = IntToByte( g );
src[2] = IntToByte( r );
src[0] = _IntToByte( b );
src[1] = _IntToByte( g );
src[2] = _IntToByte( r );
}
return c_nErrorNone;
......@@ -6598,9 +6598,9 @@ namespace ImageStudio
g += pBackup[1] * 31;
r += pBackup[2] * 31;
r = IntToByte( r );
g = IntToByte( g );
b = IntToByte( b );
r = _IntToByte( r );
g = _IntToByte( g );
b = _IntToByte( b );
int clr = Intensity2( r, g, b ) > level ? 255 : 0;
......@@ -6915,9 +6915,9 @@ namespace ImageStudio
dSumV *= 0.25;
// 8 YUV -> RGB
pPixel[nX * 4 + 0] = IntToByte( int(dSumY + 1.772 * dSumU) );
pPixel[nX * 4 + 1] = IntToByte( int(dSumY - 0.34414 * dSumU - 0.71414 * dSumV) );
pPixel[nX * 4 + 2] = IntToByte( int(dSumY + 1.402 * dSumV) );
pPixel[nX * 4 + 0] = _IntToByte( int(dSumY + 1.772 * dSumU) );
pPixel[nX * 4 + 1] = _IntToByte( int(dSumY - 0.34414 * dSumU - 0.71414 * dSumV) );
pPixel[nX * 4 + 2] = _IntToByte( int(dSumY + 1.402 * dSumV) );
}
}
}
......@@ -7032,7 +7032,7 @@ namespace ImageStudio
int nMaxLight = Round(dIntensity);
for( int i = 0; i < 256; i++ )
{
oTable[i] = IntToByte(i + nMaxLight);
oTable[i] = _IntToByte(i + nMaxLight);
}
dAngle *= IPP_PI180;
......@@ -7091,9 +7091,9 @@ namespace ImageStudio
g = int(g + t);
r = int(r + t);
pPixels[0] = IntToByte( b );
pPixels[1] = IntToByte( g );
pPixels[2] = IntToByte( r );
pPixels[0] = _IntToByte( b );
pPixels[1] = _IntToByte( g );
pPixels[2] = _IntToByte( r );
}
}
......@@ -7114,7 +7114,7 @@ namespace ImageStudio
for( int i = 0; i < 256; i++ )
{
oTable[i] = IntToByte(i + nMaxLight);
oTable[i] = _IntToByte(i + nMaxLight);
}
dFeather = max(0, min(100, dFeather )) / 100.0;
......@@ -7202,9 +7202,9 @@ namespace ImageStudio
int disp = Round( t );
pPixels[0] = IntToByte( pPixels[0] + disp );
pPixels[1] = IntToByte( pPixels[1] + disp );
pPixels[2] = IntToByte( pPixels[2] + disp );
pPixels[0] = _IntToByte( pPixels[0] + disp );
pPixels[1] = _IntToByte( pPixels[1] + disp );
pPixels[2] = _IntToByte( pPixels[2] + disp );
}
else
{
......@@ -7255,9 +7255,9 @@ namespace ImageStudio
int disp = Round( t );
pPixels[0] = IntToByte( pPixels[0] + disp );
pPixels[1] = IntToByte( pPixels[1] + disp );
pPixels[2] = IntToByte( pPixels[2] + disp );
pPixels[0] = _IntToByte( pPixels[0] + disp );
pPixels[1] = _IntToByte( pPixels[1] + disp );
pPixels[2] = _IntToByte( pPixels[2] + disp );
}
}
else
......@@ -7282,9 +7282,9 @@ namespace ImageStudio
int disp = Round( t );
pPixels[0] = IntToByte( pPixels[0] + disp );
pPixels[1] = IntToByte( pPixels[1] + disp );
pPixels[2] = IntToByte( pPixels[2] + disp );
pPixels[0] = _IntToByte( pPixels[0] + disp );
pPixels[1] = _IntToByte( pPixels[1] + disp );
pPixels[2] = _IntToByte( pPixels[2] + disp );
}
}
}
......@@ -10036,7 +10036,7 @@ namespace ImageStudio
GetBValue(nBackColor),
GetGValue(nBackColor),
GetRValue(nBackColor),
IntToByte(nBackAlpha),
_IntToByte(nBackAlpha),
};
nDstStride -= nWidth * 4;
......@@ -11376,9 +11376,9 @@ namespace ImageStudio
g += c * 24615;
r += c * -714;
pDst[0] = IntToByte( (b + 32768) >> 16 );
pDst[1] = IntToByte( (g + 32768) >> 16 );
pDst[2] = IntToByte( (r + 32768) >> 16 );
pDst[0] = _IntToByte( (b + 32768) >> 16 );
pDst[1] = _IntToByte( (g + 32768) >> 16 );
pDst[2] = _IntToByte( (r + 32768) >> 16 );
}
break;
......
......@@ -1191,6 +1191,11 @@ namespace ImageStudio
bLoading = IO::Utils::FromFile( sFilePath, nFormatOutput, oImage, nFrame, 0, 0, cxType );
break;
}
case c_Wdp:
{
ImageStudio::IO::Wdp oReaderWdp;
bLoading = oReaderWdp.FromFile( sFilePath, nFormatOutput, oImage);
}break;
case c_Psd:
{
ImageStudio::IO::Psd oReaderPsd;
......
......@@ -132,6 +132,24 @@ struct TRationalU
SetPropertyShort(bitmap,PropertyTagExifSensingMethod , m_nSensingMethod);
SetPropertyShort(bitmap,PropertyTagExifFocalLengthIn35mmFilm,m_nFocalLengthIn35mmFilm);
if (m_sGpsVersion[0]>0 || m_sGpsVersion[1] >0 || m_sGpsVersion[2]>0)
{
SetPropertyByte(bitmap, PropertyTagGpsVer, m_sGpsVersion, 4);
}
if (m_sGpsLatitudeRef.GetLength()>0)
{
SetPropertyStr(bitmap, PropertyTagGpsLatitudeRef, m_sGpsLatitudeRef);
SetPropertyRational(bitmap, PropertyTagGpsLatitude, m_sGpsLatitude,3);
}
if (m_sGpsLongitudeRef.GetLength()>0)
{
SetPropertyStr(bitmap, PropertyTagGpsLongitudeRef, m_sGpsLongitudeRef);
SetPropertyRational(bitmap, PropertyTagGpsLongitude,m_sGpsLongitude,3);
}
SetPropertyByte(bitmap, PropertyTagGpsAltitudeRef, &m_sGpsAltitudeRef,1);
SetPropertyRational(bitmap, PropertyTagGpsAltitude, m_sGpsAltitude,3);
SetPropertyRational(bitmap, PropertyTagGpsGpsTime, m_sGpsTimeStamp,3);
SetPropertyStr(bitmap, PropertyTagGpsDate, m_sGpsDateStamp);
if (bitmap->GetLastStatus() != Ok)
return FALSE;
......@@ -206,9 +224,19 @@ struct TRationalU
m_nBitDepth = 1;
m_sMetaDataXML = _T("");
m_sGpsLongitudeRef = _T("");
m_sGpsAltitudeRef = 0;
m_sGpsLatitudeRef = _T("");
m_sGpsDateStamp = _T("");
ZeroMemory(m_sGpsLatitude, 3*sizeof(TRationalU));
ZeroMemory(m_sGpsLongitude, 3*sizeof(TRationalU));
ZeroMemory(m_sGpsAltitude, 3*sizeof(TRationalU));
ZeroMemory(m_sGpsTimeStamp, 3*sizeof(TRationalU));
ZeroMemory(m_sGpsVersion, 4*sizeof(BYTE));
m_sMetaDataXML = _T("");
}
CString GetXML()
......@@ -230,6 +258,10 @@ struct TRationalU
protected:
//common functions
BYTE IntFromBytes1( const BYTE* pBytes)
{
return pBytes[0];
}
int IntFromBytes2( const BYTE* pBytes, int nType)
{
int nValue = 0;
......@@ -351,8 +383,78 @@ struct TRationalU
}
return nValue;
}
void GetPropertyByte(Bitmap*& pImage, PROPID nId, BYTE *Value, int size)
{
// retrieve property size
UINT nSize = pImage->GetPropertyItemSize(nId);
// check for valid size
if (nSize > 0)
{
// allocate memory for tag
PropertyItem* pProp = (PropertyItem*)(malloc(nSize));
if ( NULL == pProp )
return;
// read tag to buffer
pImage->GetPropertyItem(nId, nSize, pProp);
// copy data to buffer
if ( NULL != pProp->value )
memcpy(Value,pProp->value,min (size,nSize));
// release buffer
free(pProp);
}
}
BYTE GetPropertyByte(Bitmap*& pImage, PROPID nId)
{
// reset value
int nValue = 0;
// retrieve property size
UINT nSize = pImage->GetPropertyItemSize(nId);
// check for valid size
if (nSize > 0)
{
// allocate memory for tag
PropertyItem* pProp = (PropertyItem*)(malloc(nSize));
if ( NULL == pProp )
return nValue;
// read tag to buffer
pImage->GetPropertyItem(nId, nSize, pProp);
// copy data to buffer
if ( NULL != pProp->value )
nValue = *(int*)pProp->value;
// release buffer
free(pProp);
}
return nValue;
}
void SetPropertyByte(Bitmap*& pImage, PROPID nId, BYTE* nValue, int size )
{
// create new property item
PropertyItem* pProp = new PropertyItem;
if ( NULL == pProp )
return;
// compose property item
pProp->id = nId;
pProp->length = size * sizeof(BYTE);
pProp->type = PropertyTagTypeByte;
pProp->value = nValue;
// sset property item
pImage->SetPropertyItem(pProp);
// delete property item
delete pProp;
}
short GetPropertyShort(Bitmap*& pImage, PROPID nId)
{
// reset value
......@@ -412,8 +514,10 @@ struct TRationalU
return dValue;
}
void GetPropertyRationalU(Bitmap*& pImage, PROPID nId, TRationalU *pResult)
void GetPropertyRationalU(Bitmap*& pImage, PROPID nId, TRationalU *pResult,int sizeResult = 1)
{
if (sizeResult <1)return;
//rational - ( )
(*pResult).Denominator = 1;
(*pResult).Fraction = 0;
......@@ -433,7 +537,16 @@ struct TRationalU
// copy data to buffer
if ( NULL != pProp->value )
{
if (sizeResult >1)
{
memcpy(pResult,pProp->value,min(nSize-8,sizeResult * 2 * 4));
}
else
{
*pResult = *(TRationalU*)pProp->value;
}
}
// release buffer
free(pProp);
......@@ -441,6 +554,7 @@ struct TRationalU
}
void GetPropertyRational(Bitmap*& pImage, PROPID nId, TRational *pResult)
{
//rational - ( )
......@@ -533,6 +647,25 @@ struct TRationalU
// delete property item
delete pProp;
}
void SetPropertyRational(Bitmap*& pImage, PROPID nId, TRationalU* nValue,int size=1)
{//unsignes
// create new property item
PropertyItem* pProp = new PropertyItem;
if ( NULL == pProp )
return;
// compose property item
pProp->id = nId;
pProp->length = 2 * sizeof(long) * size;
pProp->type = PropertyTagTypeRational;
pProp->value = (unsigned long*)(nValue);
// sset property item
pImage->SetPropertyItem(pProp);
// delete property item
delete pProp;
}
void SetPropertySRational(Bitmap*& pImage, PROPID nId, TRational& nValue)
{//signed
// create new property item
......@@ -566,6 +699,24 @@ struct TRationalU
}
return sResult;
}
CString RationalUToString(TRationalU *oRat,int size =1)
{
CString sResult = _T("");
for (long i=0;i<size;i++)
{
char str[32];
_itoa(oRat[i].Fraction, str, 10);
sResult += str;
if ( 0 != oRat[i].Denominator )
{
sResult += _T("/");
_itoa(oRat[i].Denominator, str, 10);
sResult += str;
}
sResult += _T(" ");
}
return sResult;
}
CString RationalToString(TRational oRat)
{
CString sResult = _T("");
......@@ -630,6 +781,16 @@ struct TRationalU
m_nOrientation = GetPropertyShort(bitmap, PropertyTagOrientation);
GetPropertyByte(bitmap, PropertyTagGpsVer, m_sGpsVersion, 4);
m_sGpsLatitudeRef = GetPropertyStr(bitmap, PropertyTagGpsLatitudeRef);
GetPropertyRationalU(bitmap, PropertyTagGpsLatitude, m_sGpsLatitude,3);
m_sGpsLongitudeRef = GetPropertyStr(bitmap, PropertyTagGpsLongitudeRef);
GetPropertyRationalU(bitmap, PropertyTagGpsLongitude, m_sGpsLongitude,3);
m_sGpsAltitudeRef = GetPropertyByte(bitmap, PropertyTagGpsAltitudeRef);
GetPropertyRationalU(bitmap, PropertyTagGpsAltitude, m_sGpsAltitude,3);
GetPropertyRationalU(bitmap, PropertyTagGpsGpsTime, m_sGpsTimeStamp,3);
m_sGpsDateStamp = GetPropertyStr(bitmap, PropertyTagGpsDate);
if ( m_nBitDepth <= 1 )
m_nBitDepth = (short)GetPixelFormatSize( bitmap->GetPixelFormat() );
......@@ -723,35 +884,57 @@ struct TRationalU
}
}
}
void ReadNodeText(XmlUtils::CXmlReader &oReader, const CString &sName, TRationalU *oValue)
void ReadNodeText(XmlUtils::CXmlReader &oReader, const CString &sName, TRationalU *oValue,int max_size_read = 1)
{
CString sValue = _T("");
oReader.ReadRootNode();
oReader.ReadNode(sName);
sValue = oReader.ReadNodeText();
int pos_flash = sValue.Find(_T("/"));
int pos_point = sValue.Find(_T("."));
CString sValueOne = sValue;
int i=0;
while(true)
{
int pos_space = sValue.Find(_T(" "));
if (pos_space > 0)
{
sValueOne = sValue.Left(pos_space);
sValue = sValue.Mid(pos_space +1);
}else
{
sValueOne = sValue;
sValue = L"";
}
int pos_flash = sValueOne.Find(_T("/"));
int pos_point = sValueOne.Find(_T("."));
if (pos_flash >=0)
{
oValue->Fraction = _ttoi(sValue.Left(pos_flash));
oValue->Denominator = _ttoi(sValue.Mid(pos_flash+1));
oValue[i].Fraction = _ttoi(sValueOne.Left(pos_flash));
oValue[i].Denominator = _ttoi(sValueOne.Mid(pos_flash+1));
}
else
{
if (pos_point>=0)
{
float fValue = _tstof(sValue);
oValue->Denominator = 100;
oValue->Fraction = int(fValue*100);
float fValue = _tstof(sValueOne);
oValue[i].Denominator = 100;
oValue[i].Fraction = int(fValue*100);
}
else
{
oValue->Fraction = _ttoi(sValue);
oValue->Denominator = 0;
oValue[i].Fraction = _ttoi(sValueOne);
oValue[i].Denominator = 0;
}
}
if (sValue.GetLength()<1)break;
i++;
if (i>max_size_read)break;
}
}
void ReadNodeText(XmlUtils::CXmlReader &oReader, const CString &sName, short *nValue)
{
CString sValue = _T("");
......@@ -760,6 +943,14 @@ struct TRationalU
sValue = oReader.ReadNodeText();
*nValue = _ttoi(sValue);
}
void ReadNodeText(XmlUtils::CXmlReader &oReader, const CString &sName, BYTE *nValue, int size=1)
{
CString sValue = _T("");
oReader.ReadRootNode();
oReader.ReadNode(sName);
sValue = oReader.ReadNodeText();
BytesFromString(sValue,nValue,size);
}
void ReadNodeText(XmlUtils::CXmlReader &oReader, const CString &sName, BOOL *nValue)
{
CString sValue = _T("");
......@@ -970,8 +1161,16 @@ struct TRationalU
}
WriteNode(oXmlWriter, _T("ColorSpace"), sColorSpace);
WriteNode(oXmlWriter, _T("GpsVersion"), CString(m_sGpsVersion));
WriteNode(oXmlWriter, _T("GpsLatitudeRef"), m_sGpsLatitudeRef);
WriteNode(oXmlWriter, _T("GpsLatitude"), RationalUToString(m_sGpsLatitude,3));
WriteNode(oXmlWriter, _T("GpsLongitudeRef"),m_sGpsLongitudeRef);
WriteNode(oXmlWriter, _T("GpsLongitude"), RationalUToString(m_sGpsLongitude,3));
oXmlWriter.WriteNode(_T("GpsAltitudeRef"), m_sGpsAltitudeRef);
WriteNode(oXmlWriter, _T("GpsAltitude"), RationalUToString(m_sGpsAltitude,3));
WriteNode(oXmlWriter, _T("GpsTimeStamp"), RationalUToString(m_sGpsTimeStamp,3));
WriteNode(oXmlWriter, _T("GpsDateStamp"), m_sGpsDateStamp);
//
oXmlWriter.WriteNode(_T("BitDepth"), m_nBitDepth);
oXmlWriter.WriteNode(_T("MultiPageImage"), (int)m_bMultiPageImage );
......@@ -1104,6 +1303,15 @@ struct TRationalU
ReadNodeText(oReader, _T("BitDepth"),&m_nBitDepth);
ReadNodeText(oReader, _T("MultiPageImage"), &m_bMultiPageImage );
ReadNodeText(oReader, _T("GpsVersion"), m_sGpsVersion, 4);
ReadNodeText(oReader, _T("GpsLatitudeRef"), &m_sGpsLatitudeRef);
ReadNodeText(oReader, _T("GpsLatitude"), m_sGpsLatitude, 3);
ReadNodeText(oReader, _T("GpsLongitudeRef"),&m_sGpsLongitudeRef);
ReadNodeText(oReader, _T("GpsLongitude"), m_sGpsLongitude, 3);
ReadNodeText(oReader, _T("GpsAltitudeRef"), &m_sGpsAltitudeRef,1);
ReadNodeText(oReader, _T("GpsAltitude"), m_sGpsAltitude, 3);
ReadNodeText(oReader, _T("GpsTimeStamp"), m_sGpsTimeStamp, 3);
ReadNodeText(oReader, _T("GpsDateStamp"), &m_sGpsDateStamp);
return TRUE;
}
private:
......@@ -1140,6 +1348,16 @@ struct TRationalU
short m_nPageNumber;
short m_nPagesCount;
BYTE m_sGpsVersion[4];
CString m_sGpsLatitudeRef;//size = 2
TRationalU m_sGpsLatitude[3];
CString m_sGpsLongitudeRef;//size = 2
TRationalU m_sGpsLongitude[3];
BYTE m_sGpsAltitudeRef;
TRationalU m_sGpsAltitude[3];
TRationalU m_sGpsTimeStamp[3];
CString m_sGpsDateStamp;//size = 11
short m_nExposureProgram;
TRationalU m_oExposureTime;
TRational m_oExposureCompensation;
......
......@@ -71,7 +71,7 @@ namespace ImageStudio
return DWORD(value + 127) * 0x8081U >> 23;
}
inline int IntToByte( int value )
inline int _IntToByte( int value )
{
if( value < 0 ) value = 0; else
if( value > 255 ) value = 255;
......@@ -89,7 +89,7 @@ namespace ImageStudio
inline int RealToByte( double value )
{
return IntToByte( RealToInt( value ) );
return _IntToByte( RealToInt( value ) );
}
int ColorBlend( int dst, int src, double alpha )
......@@ -98,7 +98,7 @@ namespace ImageStudio
}
Gdiplus::Color GetColor( int color, int alpha )
{
return Gdiplus::Color( IntToByte(alpha), GetRValue(color), GetGValue(color), GetBValue(color) );
return Gdiplus::Color( _IntToByte(alpha), GetRValue(color), GetGValue(color), GetBValue(color) );
}
......
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