|
15精币
论坛里面QR二维码的生成、解码教程满天飞,但是DataMatrix格式的却没几个,我找了大半个月,终于东拼西凑找到一个调用DataMatrixEncode.dll生成二维码的源码,可能这个DLL也能用来解码,不过新手看不懂。求大神帮忙研究解码方法,十分感谢
DataMatrixEncode.dll函数列表:
其他语言源码:
/*
Test Encode DataMatrix.
*/
#include <windows.h>
#include <stdio.h>
void (__stdcall *Info)(char*,int *);
void (__stdcall *TestEncode)(int*);
void (__stdcall *QueryCode)(int,char*,int *);
void (__stdcall *QueryMode)(int,char*,int *);
void (__stdcall *QuerySize)(int,int*);
int (__stdcall *EncodeDataMatrix)(char* ,int, unsigned char* ,long *,int ,int ,int ,int );
int main()
{
printf("DataMatrixEncode.dll:\n");
HINSTANCE dllInstance=LoadLibrary("DataMatrixEncode.dll");
// Test Version Info
int i,size;
char buf[256];
// Test Info
(FARPROC&)Info=GetProcAddress(dllInstance,"Info");
size=256;
Info(buf,&size);
printf("Info:");printf(buf);printf("\n");
// Test Encode Info
(FARPROC&)TestEncode=GetProcAddress(dllInstance,"TestEncode");
int p[3];
TestEncode(p);
printf("Code:%d; Mode:%d; Size:%d\n",p[0],p[1],p[2]);
(FARPROC&)QueryCode=GetProcAddress(dllInstance,"QueryCode");
printf("Supported codes:\n");
for(i=0;i<p[0];i++)
{
size=256;
QueryCode(i,buf,&size);
printf(buf);printf("\n");
}
(FARPROC&)QueryMode=GetProcAddress(dllInstance,"QueryMode");
printf("Supported modes:\n");
for(i=0;i<p[1];i++)
{
size=256;
QueryMode(i,buf,&size);
printf(buf);printf("\n");
}
(FARPROC&)QuerySize=GetProcAddress(dllInstance,"QuerySize");
printf("Supported sizes:\n");
int size_[2];
for(i=1;i<p[2];i++)
{
QuerySize(i,size_);
printf("%dx%d\t",size_[0],size_[1]);
}
printf("\n");
// Test Encode
//(FARPROC&)EncodeDataMatrix=GetProcAddress(dllInstance,"EncodeDataMatrix");
(FARPROC&)EncodeDataMatrix=GetProcAddress(dllInstance,"EncodeDataMatrix1Bit");
long s=10000000;
BYTE* out_bitmap=new BYTE;
lstrcpy(buf,"Hello World!!! And 1234567890");
if (EncodeDataMatrix(buf,strlen(buf),out_bitmap,&s,4,0,5,0)!=0)
{
printf("Encoding error!");
delete out_bitmap;
return 5;
}
FILE *f;
f=fopen("out.bmp","wb");
if (f!=NULL)
{
fwrite(out_bitmap,1,s,f);
fclose(f);
printf("Encoding...OK!");
}
else printf("Can not write bmp file!");
delete out_bitmap;
FreeLibrary(dllInstance);
return 0;
}
|
最佳答案
查看完整内容
DM码,可以使用开源的libdmtx库就可以了,自己封装一个方便易语言调用的DLL就可以了,没必要使用这种来历不明甚至可能是破J他人软件得来的DLL,容易出问题
|