Commit 8b364d01 authored by Ivan.Shulga's avatar Ivan.Shulga Committed by Alexander Trofimov

git-svn-id:...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@52419 954022d7-b5bf-4e40-9824-e11837661b57
parent 1a9a5423
......@@ -66,11 +66,11 @@ ASCImageStudio3/ASCImageEditor/TestViewManager/Images/MenuViewGridIcon.png svn_m
ASCImageStudio3/ASCImageEditor/TestViewManager/Images/MenuViewRulersIcon.png svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCImageEditor/TestViewManager/Images/MenuViewZoomInIcon.png svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCImageEditor/TestViewManager/Images/MenuViewZoomOutIcon.png svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/AVSImageFile3/Libs/GrayDither.lib svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/AVSImageFile3/Libs/GrayDither/GrayDither.lib svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/AVSImageFile3/Libs/LibJ2K.lib svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/AVSImageFile3/Libs/LibJ2K/libjasper.lib svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/AVSImageFile3/MetaData.h svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCImageFile3/Libs/GrayDither.lib svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCImageFile3/Libs/GrayDither/GrayDither.lib svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCImageFile3/Libs/LibJ2K.lib svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCImageFile3/Libs/LibJ2K/libjasper.lib svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCImageFile3/MetaData.h svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/AVSImageMetaData/trunk/common/xsd.exe svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/AVSImageMetaData/trunk/doc/AVSImageMetaData.odt svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/AVSImageMetaData/trunk/doc/IPTC-PhotoMetadata-2008.pdf svn_mime_002dtype=application%2Foctet-stream
......
// GrayDither.cpp : Defines the entry point for the application.
#include "stdafx.h"
#include "..\GrayDither.h"
#define gray_quant_fsdither1 BMPgray_quant_fsdither1
#define grayHistAlloc BMPgrayHistAlloc
#define grayHistDealloc BMPgrayHistDealloc
#define grayDitherUnprepare BMPgrayDitherUnprepare
#define grayDitherPrepare BMPgrayDitherPrepare
#define gray_quant_fsdither1 BMPgray_quant_fsdither1
extern ULONG** grayHistAlloc(UCHAR* imgMap);
extern void grayHistDealloc(ULONG** p);
extern int grayDitherPrepare(ULONG* raster, ULONG width, ULONG height, ULONG tilelen = 0, int bps = 0, BOOL dither = FALSE, BOOL paletted = FALSE, int numcolors = 0);
extern void grayDitherUnprepare();
extern int gray_quant_fsdither1(ULONG* inbuf, ULONG step, ULONG w, ULONG h, ULONG x, LONG fromskew, LONG toskew, UCHAR* outbuf);
/*
BOOL Dither32Image(BYTE* data, int width, int height)
{
// compute compressed image size
int compressedSize = (width + 7)/8;
// allocate memory for compressed image
BYTE* compressed = new BYTE[compressedSize];
// variables
int x, y;
ULONG* pixels = (ULONG*)data;
// dither image by line
for (y = 0; y < height; ++y)
{
// quantize data
if (gray_quant_fsdither1(pixels + width*y, 1, width, 1, 0, 0, 0, compressed) == 0)
return FALSE;
// decompress bit-image to 32bpp image
// for (x = 0; x < width; ++x)
// *(pixels + x) = (compressed[x/8] & 1 << (x % 8))? 0xFFFFFF : 0;
}
// quantize by whole image
// gray_quant_fsdither1((ULONG*)(bufin+4*cx*i), 1, cx, cy, 0, 0, 0, bufout);
// all ok
return TRUE;
}
*/
BOOL Dither32Image(BYTE* data, int width, int height)
{
BYTE * bufin, * bufout;
int cx, cy, i, j;
bufin = data;
cx = width;
cy = height;
int m_out_bit_depth = 1; // for B/W (1 bit / pixel)
int wout = (m_out_bit_depth * cx + 7)/8;
// BOOL m_bGrayscale = TRUE;
BOOL m_bUseFSdither = TRUE;
int* histogram = NULL;
ULONG** histp;
long step = 1; // Icons (1,2,3...)
static RGBQUAD palette[256];
ZeroMemory(palette, sizeof(palette));
int ncols = 0;
// (R,G,B )
if (m_out_bit_depth <= 8) { // building palette
// if (m_bGrayscale) {
ncols = 1<<m_out_bit_depth;
histp = grayHistAlloc(NULL);
if (histp == NULL) throw (-1);
ncols = grayDitherPrepare((ULONG*)bufin, cx, cy,
0, m_out_bit_depth, m_bUseFSdither, FALSE, ncols);
if (ncols == 0) throw (-1);
USHORT *rm;
rm = (USHORT*)histp[0];
histogram = (int*)histp[1];
// 8, 16
for (int icol = 0; icol < ncols; icol++)
palette[icol].rgbRed = palette[icol].rgbGreen =
palette[icol].rgbBlue = (UCHAR)rm[icol];
// }
}
// if (m_bGrayscale) { ? 16,24,32
// ColorToGrayscale(bpMem, cx, cy);
// }
// -
bufout = (BYTE*)malloc(wout); //
for (i=0; i < cy; i++) {
if (gray_quant_fsdither1(
(ULONG*)bufin+cx*i, 1,
cx, 1, 0, 0, 0, bufout) == 0) throw (-1);
// fwrite(bufout, wout, 1, file);
//
for (j=0; j<cx; j++)
*((ULONG*)bufin+(cx*i+j)) = (bufout[j/8] & 1<<(j%8))? 0xFFFFFF : 0;
}
free(bufout);
// -
/*
if (gray_quant_fsdither1(
(ULONG*)(bufin+4*cx*i), 1,
cx, cy, 0, 0, 0, bufout) == 0) throw (-1);
fwrite(bufout, wout*cy, 1, file);
*/
if (m_out_bit_depth <= 8)
{
grayDitherUnprepare();
grayHistDealloc(histp);
}
return TRUE;
}
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GrayDither", "GrayDither.vcproj", "{14A4EA98-9CB5-401A-BDF3-68B70D74F5E9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{14A4EA98-9CB5-401A-BDF3-68B70D74F5E9}.Debug|Win32.ActiveCfg = Debug|Win32
{14A4EA98-9CB5-401A-BDF3-68B70D74F5E9}.Debug|Win32.Build.0 = Debug|Win32
{14A4EA98-9CB5-401A-BDF3-68B70D74F5E9}.Release|Win32.ActiveCfg = Release|Win32
{14A4EA98-9CB5-401A-BDF3-68B70D74F5E9}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="GrayDither"
ProjectGUID="{14A4EA98-9CB5-401A-BDF3-68B70D74F5E9}"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(ProjectName).lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
OmitFramePointers="true"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(ProjectName).lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"
>
<File
RelativePath="_dither.cpp"
>
</File>
<File
RelativePath="_graydither.cpp"
>
</File>
<File
RelativePath="GrayDither.cpp"
>
</File>
<File
RelativePath="stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc"
>
<File
RelativePath="..\GrayDither.h"
>
</File>
<File
RelativePath="stdafx.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
// stdafx.cpp : source file that includes just the standard includes
// GrayDither.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
// C RunTime Header Files
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
Microsoft Visual Studio Solution File, Format Version 7.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibJ2K", "LibJ2K.vcproj", "{8E176F34-67BA-4F8A-88C2-77BB55EDC06C}"
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
ConfigName.0 = Debug
ConfigName.1 = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{8E176F34-67BA-4F8A-88C2-77BB55EDC06C}.Debug.ActiveCfg = Debug|Win32
{8E176F34-67BA-4F8A-88C2-77BB55EDC06C}.Debug.Build.0 = Debug|Win32
{8E176F34-67BA-4F8A-88C2-77BB55EDC06C}.Release.ActiveCfg = Release|Win32
{8E176F34-67BA-4F8A-88C2-77BB55EDC06C}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding = "windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="LibJ2K"
ProjectGUID="{8E176F34-67BA-4F8A-88C2-77BB55EDC06C}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\JASPER-15003\libjasper\include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="3"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/LibJ2K.lib"
AdditionalLibraryDirectories=""
IgnoreAllDefaultLibraries="TRUE"
IgnoreDefaultLibraryNames=""/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
OmitFramePointers="TRUE"
AdditionalIncludeDirectories="..\JASPER-15003\libjasper\include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
StringPooling="TRUE"
RuntimeLibrary="4"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="3"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/LibJ2K.lib"
AdditionalLibraryDirectories=""
IgnoreAllDefaultLibraries="TRUE"
IgnoreDefaultLibraryNames=""/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
</Configuration>
</Configurations>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
<File
RelativePath="realization.cpp">
</File>
<File
RelativePath="stdafx.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc">
<File
RelativePath="exports.h">
</File>
<File
RelativePath="stdafx.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
</Filter>
<File
RelativePath="libjasper.lib"
DeploymentContent="TRUE">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
// stdafx.cpp : source file that includes just the standard includes
// LibJ2K.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <atlbase.h>
#include <atlcom.h>
#include <atlsafe.h>
#include <atltypes.h>
#include <WindowsX.h>
#include <comdef.h>
#include <jasper/jasper.h>
#include <../jp2/jp2_cod.h>
#include <../jpc/jpc_cs.h>
/////////////////////////////////////////////////////////////////////////////
#pragma once
/////////////////////////////////////////////////////////////////////////////
// Appendix functions
struct ImageFormat
{
int picture_type; // picture type
int picture_subtype; // clipboard image type
// common variables
long colors;
long sizeX;
long sizeY;
long format; // format details (Win-OS/2 for Bmp)
int out_color_space; // colorspace for output (1=gray, >1=color)
int out_bit_depth; // colordepth for output (<=8, paletted)
unsigned int scale_num; // always=1
unsigned int scale_denom; // fraction by which to scale image
BOOL bUseFSdither; // for paletted image sabings
// internal common variables
UCHAR* image_ptr;
BOOL PropDefaults;
BOOL PreviewAllowed;
long DesiredSizeX;
long DesiredSizeY;
int OEMcompression; // Tiff compression type
DWORD CustData; // temporary data
// unused or unnecessary
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
// JPEG, PNG variables
int quality; // JPEG(0..100), PNG(0..9=>0..100)
BOOL simple_progressive;
// PNG variables
int filter; // 0 - default, 1..5
// GIF variables
int framenum; // in multiimage GIFs: 0=count of images
int frameidx; // 0=all images at once (screen size), >0: index of image
// BMP, TIFF variables
int compression; // 0-based index of compression type
// TIFF variables
int byteorder; // (0=IBM-PC(default), 1-Mac, 2-host)
int planarconfig; // contiguous(default)/separate
BOOL tiled; // stripped(default)/tiled image
int stripsize; // size of strip buffer (index of control)
int tilesize; // size of tile (0-based index in combo)
};
typedef struct ImageFormat* LPIMAGEFORMAT;
HRESULT GetJp2Format(LPCTSTR fileName, LPIMAGEFORMAT pFmt);
HRESULT LoadJp2(LPCTSTR fileName, LPSAFEARRAY *saImage, LPIMAGEFORMAT pFmt = NULL);
HRESULT SaveJp2(LPCTSTR fileName, LPSAFEARRAY *saImage, LPIMAGEFORMAT pFmt = NULL);
/////////////////////////////////////////////////////////////////////////////
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