v2.70 QRCode
svn path=/Slnkdwf/trunk/; revision=12513
This commit is contained in:
0
QRCode/.gitignore
vendored
0
QRCode/.gitignore
vendored
200
QRCode/QRCode.vcproj
Normal file
200
QRCode/QRCode.vcproj
Normal file
@@ -0,0 +1,200 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8,00"
|
||||
Name="QRCode"
|
||||
ProjectGUID="{3EA5B7D3-EA9B-420B-B283-0D92E620B970}"
|
||||
RootNamespace="QRCode"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="D:\Temp\Slnkdwf\$(ProjectName)\$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
UseOfATL="1"
|
||||
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;_LIB"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\..\Release"
|
||||
IntermediateDirectory="D:\Temp\Slnkdwf\$(ProjectName)\$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
UseOfATL="1"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="2"
|
||||
TreatWChar_tAsBuiltInType="false"
|
||||
UsePrecompiledHeader="2"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<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;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\QR_Encode.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;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\stdafx.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\ReadMe.txt"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
1949
QRCode/QR_Encode.cpp
Normal file
1949
QRCode/QR_Encode.cpp
Normal file
File diff suppressed because it is too large
Load Diff
144
QRCode/QR_Encode.h
Normal file
144
QRCode/QR_Encode.h
Normal file
@@ -0,0 +1,144 @@
|
||||
// QR_Encode.h : CQR_Encode <20>N<EFBFBD><4E><EFBFBD>X<EFBFBD>錾<EFBFBD><E98CBE><EFBFBD><EFBFBD><EFBFBD>уC<D183><43><EFBFBD>^<5E>[<5B>t<EFBFBD>F<EFBFBD>C<EFBFBD>X<EFBFBD><58><EFBFBD>`
|
||||
// Date 2006/05/17 Ver. 1.22 Psytec Inc.
|
||||
|
||||
#if !defined(AFX_QR_ENCODE_H__AC886DF7_C0AE_4C9F_AC7A_FCDA8CB1DD37__INCLUDED_)
|
||||
#define AFX_QR_ENCODE_H__AC886DF7_C0AE_4C9F_AC7A_FCDA8CB1DD37__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// <20>萔
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>x<EFBFBD><78>
|
||||
#define QR_LEVEL_L 0
|
||||
#define QR_LEVEL_M 1
|
||||
#define QR_LEVEL_Q 2
|
||||
#define QR_LEVEL_H 3
|
||||
|
||||
// <20>f<EFBFBD>[<5B>^<5E><><EFBFBD>[<5B>h
|
||||
#define QR_MODE_NUMERAL 0
|
||||
#define QR_MODE_ALPHABET 1
|
||||
#define QR_MODE_8BIT 2
|
||||
#define QR_MODE_KANJI 3
|
||||
|
||||
// <20>o<EFBFBD>[<5B>W<EFBFBD><57><EFBFBD><EFBFBD>(<28>^<5E><>)<29>O<EFBFBD><4F><EFBFBD>[<5B>v
|
||||
#define QR_VRESION_S 0 // 1 <20>` 9
|
||||
#define QR_VRESION_M 1 // 10 <20>` 26
|
||||
#define QR_VRESION_L 2 // 27 <20>` 40
|
||||
|
||||
#define MAX_ALLCODEWORD 3706 // <20><><EFBFBD>R<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>ő<EFBFBD><C591>l
|
||||
#define MAX_DATACODEWORD 2956 // <20>f<EFBFBD>[<5B>^<5E>R<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>[<5B>h<EFBFBD>ő<EFBFBD><C591>l(<28>o<EFBFBD>[<5B>W<EFBFBD><57><EFBFBD><EFBFBD>40-L)
|
||||
#define MAX_CODEBLOCK 153 // <20>u<EFBFBD><75><EFBFBD>b<EFBFBD>N<EFBFBD>f<EFBFBD>[<5B>^<5E>R<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>ő<EFBFBD><C591>l(<28>q<EFBFBD>r<EFBFBD>R<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>܂<EFBFBD>)
|
||||
#define MAX_MODULESIZE 177 // <20><><EFBFBD>Ӄ<EFBFBD><D383>W<EFBFBD><57><EFBFBD>[<5B><><EFBFBD><EFBFBD><EFBFBD>ő<EFBFBD><C591>l
|
||||
|
||||
// <20>r<EFBFBD>b<EFBFBD>g<EFBFBD>}<7D>b<EFBFBD>v<EFBFBD>`<60>掞<EFBFBD>}<7D>[<5B>W<EFBFBD><57>
|
||||
#define QR_MARGIN 4
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
typedef struct tagRS_BLOCKINFO
|
||||
{
|
||||
int ncRSBlock; // <20>q<EFBFBD>r<EFBFBD>u<EFBFBD><75><EFBFBD>b<EFBFBD>N<EFBFBD><4E>
|
||||
int ncAllCodeWord; // <20>u<EFBFBD><75><EFBFBD>b<EFBFBD>N<EFBFBD><4E><EFBFBD>R<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>[<5B>h<EFBFBD><68>
|
||||
int ncDataCodeWord; // <20>f<EFBFBD>[<5B>^<5E>R<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>[<5B>h<EFBFBD><68>(<28>R<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>[<5B>h<EFBFBD><68> - <20>q<EFBFBD>r<EFBFBD>R<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>[<5B>h<EFBFBD><68>)
|
||||
|
||||
} RS_BLOCKINFO, *LPRS_BLOCKINFO;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// QR<51>R<EFBFBD>[<5B>h<EFBFBD>o<EFBFBD>[<5B>W<EFBFBD><57><EFBFBD><EFBFBD>(<28>^<5E><>)<29>֘A<D698><41><EFBFBD><EFBFBD>
|
||||
|
||||
typedef struct tagQR_VERSIONINFO
|
||||
{
|
||||
int nVersionNo; // <20>o<EFBFBD>[<5B>W<EFBFBD><57><EFBFBD><EFBFBD>(<28>^<5E><>)<29>ԍ<EFBFBD>(1<>`40)
|
||||
int ncAllCodeWord; // <20><><EFBFBD>R<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>[<5B>h<EFBFBD><68>
|
||||
|
||||
// <20>ȉ<EFBFBD><C889>z<EFBFBD><7A><EFBFBD>Y<EFBFBD><59><EFBFBD>͌<EFBFBD><CD8C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(0 = L, 1 = M, 2 = Q, 3 = H)
|
||||
int ncDataCodeWord[4]; // <20>f<EFBFBD>[<5B>^<5E>R<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>[<5B>h<EFBFBD><68>(<28><><EFBFBD>R<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>[<5B>h<EFBFBD><68> - <20>q<EFBFBD>r<EFBFBD>R<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>[<5B>h<EFBFBD><68>)
|
||||
|
||||
int ncAlignPoint; // <20>A<EFBFBD><41><EFBFBD>C<EFBFBD><43><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD>p<EFBFBD>^<5E>[<5B><><EFBFBD><EFBFBD><EFBFBD>W<EFBFBD><57>
|
||||
int nAlignPoint[6]; // <20>A<EFBFBD><41><EFBFBD>C<EFBFBD><43><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD>p<EFBFBD>^<5E>[<5B><><EFBFBD><EFBFBD><EFBFBD>S<EFBFBD><53><EFBFBD>W
|
||||
|
||||
RS_BLOCKINFO RS_BlockInfo1[4]; // <20>q<EFBFBD>r<EFBFBD>u<EFBFBD><75><EFBFBD>b<EFBFBD>N<EFBFBD><4E><EFBFBD><EFBFBD>(1)
|
||||
RS_BLOCKINFO RS_BlockInfo2[4]; // <20>q<EFBFBD>r<EFBFBD>u<EFBFBD><75><EFBFBD>b<EFBFBD>N<EFBFBD><4E><EFBFBD><EFBFBD>(2)
|
||||
|
||||
} QR_VERSIONINFO, *LPQR_VERSIONINFO;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CQR_Encode <20>N<EFBFBD><4E><EFBFBD>X
|
||||
|
||||
class CQR_Encode
|
||||
{
|
||||
// <20>\<5C>z/<2F><><EFBFBD><EFBFBD>
|
||||
public:
|
||||
CQR_Encode();
|
||||
~CQR_Encode();
|
||||
|
||||
public:
|
||||
int m_nLevel; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>x<EFBFBD><78>
|
||||
int m_nVersion; // <20>o<EFBFBD>[<5B>W<EFBFBD><57><EFBFBD><EFBFBD>(<28>^<5E><>)
|
||||
BOOL m_bAutoExtent; // <20>o<EFBFBD>[<5B>W<EFBFBD><57><EFBFBD><EFBFBD>(<28>^<5E><>)<29><><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD><67><EFBFBD>w<EFBFBD><77><EFBFBD>t<EFBFBD><74><EFBFBD>O
|
||||
int m_nMaskingNo; // <20>}<7D>X<EFBFBD>L<EFBFBD><4C><EFBFBD>O<EFBFBD>p<EFBFBD>^<5E>[<5B><><EFBFBD>ԍ<EFBFBD>
|
||||
|
||||
public:
|
||||
int m_nSymbleSize;
|
||||
BYTE m_byModuleData[MAX_MODULESIZE][MAX_MODULESIZE]; // [x][y]
|
||||
// bit5:<3A>@<40>\<5C><><EFBFBD>W<EFBFBD><57><EFBFBD>[<5B><><EFBFBD>i<EFBFBD>}<7D>X<EFBFBD>L<EFBFBD><4C><EFBFBD>O<EFBFBD>ΏۊO<DB8A>j<EFBFBD>t<EFBFBD><74><EFBFBD>O
|
||||
// bit4:<3A>@<40>\<5C><><EFBFBD>W<EFBFBD><57><EFBFBD>[<5B><><EFBFBD>`<60><><EFBFBD>f<EFBFBD>[<5B>^
|
||||
// bit1:<3A>G<EFBFBD><47><EFBFBD>R<EFBFBD>[<5B>h<EFBFBD>f<EFBFBD>[<5B>^
|
||||
// bit0:<3A>}<7D>X<EFBFBD>N<EFBFBD><4E><EFBFBD>G<EFBFBD><47><EFBFBD>R<EFBFBD>[<5B>h<EFBFBD>`<60><><EFBFBD>f<EFBFBD>[<5B>^
|
||||
// 20h<30>Ƃ̘_<CC98><5F><EFBFBD>a<EFBFBD>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>@<40>\<5C><><EFBFBD>W<EFBFBD><57><EFBFBD>[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A11h<31>Ƃ̘_<CC98><5F><EFBFBD>a<EFBFBD>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>`<60><><EFBFBD>i<EFBFBD>ŏI<C58F>I<EFBFBD>ɂ<EFBFBD>BOOL<4F>l<EFBFBD><6C><EFBFBD>j
|
||||
|
||||
private:
|
||||
int m_ncDataCodeWordBit; // <20>f<EFBFBD>[<5B>^<5E>R<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>[<5B>h<EFBFBD>r<EFBFBD>b<EFBFBD>g<EFBFBD><67>
|
||||
BYTE m_byDataCodeWord[MAX_DATACODEWORD]; // <20><><EFBFBD>̓f<CD83>[<5B>^<5E>G<EFBFBD><47><EFBFBD>R<EFBFBD>[<5B>h<EFBFBD>G<EFBFBD><47><EFBFBD>A
|
||||
|
||||
int m_ncDataBlock;
|
||||
BYTE m_byBlockMode[MAX_DATACODEWORD];
|
||||
int m_nBlockLength[MAX_DATACODEWORD];
|
||||
|
||||
int m_ncAllCodeWord; // <20><><EFBFBD>R<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>[<5B>h<EFBFBD><68>(<28>q<EFBFBD>r<EFBFBD><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>f<EFBFBD>[<5B>^<5E><><EFBFBD>܂<EFBFBD>)
|
||||
BYTE m_byAllCodeWord[MAX_ALLCODEWORD]; // <20><><EFBFBD>R<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>[<5B>h<EFBFBD>Z<EFBFBD>o<EFBFBD>G<EFBFBD><47><EFBFBD>A
|
||||
BYTE m_byRSWork[MAX_CODEBLOCK]; // <20>q<EFBFBD>r<EFBFBD>R<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>[<5B>h<EFBFBD>Z<EFBFBD>o<EFBFBD><6F><EFBFBD>[<5B>N
|
||||
|
||||
// <20>f<EFBFBD>[<5B>^<5E>G<EFBFBD><47><EFBFBD>R<EFBFBD>[<5B>h<EFBFBD>֘A<D698>t<EFBFBD>@<40><><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD>
|
||||
public:
|
||||
BOOL EncodeData(int nLevel, int nVersion, BOOL bAutoExtent, int nMaskingNo, LPCSTR lpsSource, int ncSource = 0);
|
||||
|
||||
private:
|
||||
int GetEncodeVersion(int nVersion, LPCSTR lpsSource, int ncLength);
|
||||
BOOL EncodeSourceData(LPCSTR lpsSource, int ncLength, int nVerGroup);
|
||||
|
||||
int GetBitLength(BYTE nMode, int ncData, int nVerGroup);
|
||||
|
||||
int SetBitStream(int nIndex, WORD wData, int ncData);
|
||||
|
||||
BOOL IsNumeralData(unsigned char c);
|
||||
BOOL IsAlphabetData(unsigned char c);
|
||||
BOOL IsKanjiData(unsigned char c1, unsigned char c2);
|
||||
|
||||
BYTE AlphabetToBinaly(unsigned char c);
|
||||
WORD KanjiToBinaly(WORD wc);
|
||||
|
||||
void GetRSCodeWord(LPBYTE lpbyRSWork, int ncDataCodeWord, int ncRSCodeWord);
|
||||
|
||||
// <20><><EFBFBD>W<EFBFBD><57><EFBFBD>[<5B><><EFBFBD>z<EFBFBD>u<EFBFBD>֘A<D698>t<EFBFBD>@<40><><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD>
|
||||
private:
|
||||
void FormatModule();
|
||||
|
||||
void SetFunctionModule();
|
||||
void SetFinderPattern(int x, int y);
|
||||
void SetAlignmentPattern(int x, int y);
|
||||
void SetVersionPattern();
|
||||
void SetCodeWordPattern();
|
||||
void SetMaskingPattern(int nPatternNo);
|
||||
void SetFormatInfoPattern(int nPatternNo);
|
||||
int CountPenalty();
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // !defined(AFX_QR_ENCODE_H__AC886DF7_C0AE_4C9F_AC7A_FCDA8CB1DD37__INCLUDED_)
|
||||
8
QRCode/stdafx.cpp
Normal file
8
QRCode/stdafx.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// QRCode.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
|
||||
17
QRCode/stdafx.h
Normal file
17
QRCode/stdafx.h
Normal file
@@ -0,0 +1,17 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
|
||||
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
|
||||
#endif
|
||||
|
||||
//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include "../SLNKDwfImpl/targetsxs.h"
|
||||
|
||||
#include <atlbase.h>
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
203
SlnkDWFCom/QRCode.cpp
Normal file
203
SlnkDWFCom/QRCode.cpp
Normal file
@@ -0,0 +1,203 @@
|
||||
// QRCode.cpp : Implementation of CQRCode
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "QRCode.h"
|
||||
#include "..\QRCode\QR_Encode.h"
|
||||
|
||||
// CQRCode
|
||||
|
||||
STDMETHODIMP CQRCode::InterfaceSupportsErrorInfo(REFIID riid)
|
||||
{
|
||||
static const IID* arr[] =
|
||||
{
|
||||
&IID_IQRCode
|
||||
};
|
||||
|
||||
for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
|
||||
{
|
||||
if (InlineIsEqualGUID(*arr[i],riid))
|
||||
return S_OK;
|
||||
}
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
STDMETHODIMP CQRCode::get_Text(BSTR* pVal)
|
||||
{
|
||||
*pVal = m_Text.AllocSysString();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CQRCode::put_Text(BSTR newVal)
|
||||
{
|
||||
m_Text = CString(newVal);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CQRCode::StreamPNG(CxImage &img, VARIANT *ImageData, BOOL bPNG)
|
||||
{
|
||||
SAFEARRAY *psaData; BYTE *pData;
|
||||
SAFEARRAYBOUND rgsabound[1];
|
||||
|
||||
long size=0;
|
||||
BYTE* pBuffer=0;
|
||||
{
|
||||
{
|
||||
CmyTimer timer("CQRCode::StreamPNG/de PNG encoden");
|
||||
if (!img.Encode(pBuffer,size, bPNG?CXIMAGE_FORMAT_PNG:CXIMAGE_FORMAT_GIF))
|
||||
return myAtlReportError (GetObjectCLSID(), "\nStreamPNG encode failed: %s", img.GetLastError());
|
||||
}
|
||||
|
||||
// TODO: Echt netjes zou zijn om hier een IStream op te leveren?
|
||||
// create safe array and copy image data
|
||||
rgsabound[0].lLbound = 0; rgsabound[0].cElements = size;
|
||||
psaData = SafeArrayCreate(VT_UI1, 1, rgsabound);
|
||||
SafeArrayAccessData(psaData, (void **)&pData);
|
||||
memcpy(pData,pBuffer,size);
|
||||
SafeArrayUnaccessData(psaData);
|
||||
img.FreeMemory (pBuffer);
|
||||
// put data in variant
|
||||
ImageData->vt = (VT_ARRAY | VT_UI1);
|
||||
ImageData->parray = psaData;
|
||||
}
|
||||
myDoTRACE("\nCQRCode::StreamPNG done, sending %d bytes", size);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
bool CQRCode::CreateCxImage(CxImage *img)
|
||||
{
|
||||
CQR_Encode* pQR_Encode = new CQR_Encode;
|
||||
|
||||
//m_bDataEncoded = pQR_Encode->EncodeData(nLevel, nVersion, bAutoExtent, nMaskingNo, strEncodeData);
|
||||
BOOL res = pQR_Encode->EncodeData(m_nLevel, m_nVersion,
|
||||
m_bAutoExtend, m_nMaskingNo,
|
||||
m_Text );
|
||||
if (!res)
|
||||
return false;
|
||||
|
||||
img->Create((pQR_Encode->m_nSymbleSize+2*QR_MARGIN), (pQR_Encode->m_nSymbleSize+2*QR_MARGIN), 24 /* bpp */);
|
||||
img->Clear(255);
|
||||
img->SetTransIndex(-1);
|
||||
for (int i = 0; i < pQR_Encode->m_nSymbleSize; ++i)
|
||||
for (int j = 0; j < pQR_Encode->m_nSymbleSize; ++j)
|
||||
{
|
||||
if (pQR_Encode->m_byModuleData[i][j])
|
||||
{
|
||||
img->SetPixelColor((i + QR_MARGIN), (pQR_Encode->m_nSymbleSize-j + QR_MARGIN) , RGB(0, 0, 0));
|
||||
}
|
||||
}
|
||||
img->Resample(m_nSize * img->GetWidth(), m_nSize * img->GetHeight());
|
||||
delete pQR_Encode;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
STDMETHODIMP CQRCode::GetAsPNG(VARIANT* ImageData)
|
||||
{
|
||||
try
|
||||
{
|
||||
myDoTRACE("\nCQRCode::GetAsPNG()");
|
||||
|
||||
CxImage img;
|
||||
BOOL res = CreateCxImage(&img);
|
||||
if (!res)
|
||||
{
|
||||
CString err; err.Format("Could not QRCode: %s", m_Text);
|
||||
throw err;
|
||||
}
|
||||
|
||||
return StreamPNG(img, ImageData, true /*bPNG*/);
|
||||
}
|
||||
catch (DWFException& ex)
|
||||
{
|
||||
CString err;
|
||||
err.Format("%ls\n%ls\n%s\n%ls(%d)",ex.type(),ex.message(),ex.function(),ex.file(),ex.line());
|
||||
return myAtlReportError (GetObjectCLSID(), "\nCQRCode::GetAsPNG('%s')\n%s", m_Text, err);
|
||||
}
|
||||
catch (CString& err)
|
||||
{
|
||||
return myAtlReportError (GetObjectCLSID(), "\nCQRCode::GetAsPNG('%s')\n%s", m_Text, err);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CQRCode::get_Version(LONG* pVal)
|
||||
{
|
||||
*pVal = m_nVersion;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CQRCode::put_Version(LONG newVal)
|
||||
{
|
||||
if (newVal < -1 || newVal > 40)
|
||||
return E_INVALIDARG;
|
||||
m_nVersion = newVal;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CQRCode::get_Autoextend(VARIANT_BOOL* pVal)
|
||||
{
|
||||
*pVal = m_bAutoExtend;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CQRCode::put_Autoextend(VARIANT_BOOL newVal)
|
||||
{
|
||||
m_bAutoExtend = newVal;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CQRCode::get_Level(LONG* pVal)
|
||||
{
|
||||
*pVal = m_nLevel;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CQRCode::put_Level(LONG newVal)
|
||||
{
|
||||
if (newVal < 1 || newVal > 3)
|
||||
return E_INVALIDARG;
|
||||
m_nLevel = newVal;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CQRCode::get_Masking(LONG* pVal)
|
||||
{
|
||||
*pVal = m_nMaskingNo;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CQRCode::put_Masking(LONG newVal)
|
||||
{
|
||||
if (newVal < -1 || newVal > 7)
|
||||
return E_INVALIDARG;
|
||||
m_nMaskingNo = newVal;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CQRCode::get_Size(LONG* pVal)
|
||||
{
|
||||
*pVal = m_nSize;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CQRCode::put_Size(LONG newVal)
|
||||
{
|
||||
if (newVal < 1 || newVal > 64)
|
||||
return E_INVALIDARG;
|
||||
m_nSize = newVal;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
84
SlnkDWFCom/QRCode.h
Normal file
84
SlnkDWFCom/QRCode.h
Normal file
@@ -0,0 +1,84 @@
|
||||
// QRCode.h : Declaration of the CQRCode
|
||||
|
||||
#pragma once
|
||||
#include "resource.h" // main symbols
|
||||
|
||||
#include "SLNKDWF.h"
|
||||
#include "CxImage\CxImage\ximage.h"
|
||||
|
||||
#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
|
||||
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// CQRCode
|
||||
|
||||
class ATL_NO_VTABLE CQRCode :
|
||||
public CComObjectRootEx<CComSingleThreadModel>,
|
||||
public CComCoClass<CQRCode, &CLSID_QRCode>,
|
||||
public ISupportErrorInfo,
|
||||
public IDispatchImpl<IQRCode, &IID_IQRCode, &LIBID_SLNKDWFLib, /*wMajor =*/ 1, /*wMinor =*/ 0>
|
||||
{
|
||||
public:
|
||||
CQRCode()
|
||||
{
|
||||
m_Text = "";
|
||||
m_nVersion = -1;
|
||||
m_bAutoExtend = true,
|
||||
m_nLevel = 1; // M=15%
|
||||
m_nMaskingNo = -1; // Auto
|
||||
m_nSize = 8; // pixels/module
|
||||
}
|
||||
|
||||
DECLARE_REGISTRY_RESOURCEID(IDR_QRCODE)
|
||||
|
||||
|
||||
BEGIN_COM_MAP(CQRCode)
|
||||
COM_INTERFACE_ENTRY(IQRCode)
|
||||
COM_INTERFACE_ENTRY(IDispatch)
|
||||
COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
||||
END_COM_MAP()
|
||||
|
||||
// ISupportsErrorInfo
|
||||
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
|
||||
|
||||
|
||||
DECLARE_PROTECT_FINAL_CONSTRUCT()
|
||||
|
||||
HRESULT FinalConstruct()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void FinalRelease()
|
||||
{
|
||||
}
|
||||
private:
|
||||
CString m_Text;
|
||||
int m_nMaskingNo;
|
||||
int m_nVersion;
|
||||
BOOL m_bAutoExtend;
|
||||
int m_nLevel;
|
||||
int m_nSize;
|
||||
bool CreateCxImage(CxImage* img);
|
||||
HRESULT StreamPNG(CxImage &img, VARIANT *ImageData, BOOL bPNG);
|
||||
|
||||
public:
|
||||
|
||||
STDMETHOD(get_Text)(BSTR* pVal);
|
||||
STDMETHOD(put_Text)(BSTR newVal);
|
||||
STDMETHOD(GetAsPNG)(VARIANT* ImageData);
|
||||
STDMETHOD(get_Version)(LONG* pVal);
|
||||
STDMETHOD(put_Version)(LONG newVal);
|
||||
STDMETHOD(get_Autoextend)(VARIANT_BOOL* pVal);
|
||||
STDMETHOD(put_Autoextend)(VARIANT_BOOL newVal);
|
||||
STDMETHOD(get_Level)(LONG* pVal);
|
||||
STDMETHOD(put_Level)(LONG newVal);
|
||||
STDMETHOD(get_Masking)(LONG* pVal);
|
||||
STDMETHOD(put_Masking)(LONG newVal);
|
||||
STDMETHOD(get_Size)(LONG* pVal);
|
||||
STDMETHOD(put_Size)(LONG newVal);
|
||||
};
|
||||
|
||||
OBJECT_ENTRY_AUTO(__uuidof(QRCode), CQRCode)
|
||||
26
SlnkDWFCom/QRCode.rgs
Normal file
26
SlnkDWFCom/QRCode.rgs
Normal file
@@ -0,0 +1,26 @@
|
||||
HKCR
|
||||
{
|
||||
SLNKDWF.QRCode.1 = s 'QRCode Class'
|
||||
{
|
||||
CLSID = s '{E951BBE6-F2F9-462D-90B9-D011D4F3AE91}'
|
||||
}
|
||||
SLNKDWF.QRCode = s 'QRCode Class'
|
||||
{
|
||||
CLSID = s '{E951BBE6-F2F9-462D-90B9-D011D4F3AE91}'
|
||||
CurVer = s 'SLNKDWF.QRCode.1'
|
||||
}
|
||||
NoRemove CLSID
|
||||
{
|
||||
ForceRemove {E951BBE6-F2F9-462D-90B9-D011D4F3AE91} = s 'QRCode Class'
|
||||
{
|
||||
ProgID = s 'SLNKDWF.QRCode.1'
|
||||
VersionIndependentProgID = s 'SLNKDWF.QRCode'
|
||||
ForceRemove 'Programmable'
|
||||
InprocServer32 = s '%MODULE%'
|
||||
{
|
||||
val ThreadingModel = s 'Apartment'
|
||||
}
|
||||
'TypeLib' = s '{B6FCDE6E-141C-4601-B3AC-4DF4D5F25DF8}'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -336,6 +336,29 @@ interface IBarcode : IDispatch{
|
||||
[propget, id(10), helpstring("property Rotation")] HRESULT Rotation([out, retval] LONG* pVal);
|
||||
[propput, id(10), helpstring("property Rotation")] HRESULT Rotation([in] LONG newVal);
|
||||
};
|
||||
[
|
||||
object,
|
||||
uuid(8442871A-AB7B-4F9E-8A5A-B06297E8821D),
|
||||
dual,
|
||||
nonextensible,
|
||||
helpstring("IQRCode Interface"),
|
||||
pointer_default(unique)
|
||||
]
|
||||
interface IQRCode : IDispatch{
|
||||
[propget, id(1), helpstring("property Text")] HRESULT Text([out, retval] BSTR* pVal);
|
||||
[propput, id(1), helpstring("property Text")] HRESULT Text([in] BSTR newVal);
|
||||
[id(2), helpstring("method GetAsPNG")] HRESULT GetAsPNG([out, retval] VARIANT* ImageData);
|
||||
[propget, id(3), helpstring("property Version")] HRESULT Version([out, retval] LONG* pVal);
|
||||
[propput, id(3), helpstring("property Version")] HRESULT Version([in] LONG newVal);
|
||||
[propget, id(4), helpstring("property Autoextend")] HRESULT Autoextend([out, retval] VARIANT_BOOL* pVal);
|
||||
[propput, id(4), helpstring("property Autoextend")] HRESULT Autoextend([in] VARIANT_BOOL newVal);
|
||||
[propget, id(5), helpstring("property Level")] HRESULT Level([out, retval] LONG* pVal);
|
||||
[propput, id(5), helpstring("property Level")] HRESULT Level([in] LONG newVal);
|
||||
[propget, id(6), helpstring("property Masking")] HRESULT Masking([out, retval] LONG* pVal);
|
||||
[propput, id(6), helpstring("property Masking")] HRESULT Masking([in] LONG newVal);
|
||||
[propget, id(7), helpstring("property Size")] HRESULT Size([out, retval] LONG* pVal);
|
||||
[propput, id(7), helpstring("property Size")] HRESULT Size([in] LONG newVal);
|
||||
};
|
||||
[
|
||||
uuid(B6FCDE6E-141C-4601-B3AC-4DF4D5F25DF8),
|
||||
version(1.0),
|
||||
@@ -479,4 +502,12 @@ library SLNKDWFLib
|
||||
{
|
||||
[default] interface IBarcode;
|
||||
};
|
||||
[
|
||||
uuid(E951BBE6-F2F9-462D-90B9-D011D4F3AE91),
|
||||
helpstring("QRCode Class")
|
||||
]
|
||||
coclass QRCode
|
||||
{
|
||||
[default] interface IQRCode;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Zorg dat versies alfabetisch altijd op elkaar volgen!
|
||||
#define SLNK_MAJOR_VERSION 2
|
||||
#define SLNK_MINOR_VERSION 60
|
||||
#define SLNK_MINOR_VERSION 70
|
||||
#define SLNK_BUILD_VERSION 0
|
||||
|
||||
// Define resource strings
|
||||
|
||||
@@ -139,6 +139,7 @@ IDR_ZIP REGISTRY "Zip.rgs"
|
||||
IDR_WHIPCLEANER REGISTRY "WhipCleaner.rgs"
|
||||
IDR_IMAGECONVERT REGISTRY "ImageConvert.rgs"
|
||||
IDR_BARCODE REGISTRY "Barcode.rgs"
|
||||
IDR_QRCODE REGISTRY "QRCode.rgs"
|
||||
#endif // Dutch (Netherlands) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -29,14 +29,15 @@
|
||||
#define IDR_WHIPCLEANER 129
|
||||
#define IDR_IMAGECONVERT 130
|
||||
#define IDR_BARCODE 131
|
||||
#define IDR_QRCODE 132
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 201
|
||||
#define _APS_NEXT_COMMAND_VALUE 32768
|
||||
#define _APS_NEXT_CONTROL_VALUE 201
|
||||
#define _APS_NEXT_SYMED_VALUE 132
|
||||
#define _APS_NEXT_SYMED_VALUE 133
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user