/*
LodePNG version 20130325
Copyright (c) 2005-2013 Lode Vandevenne
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
/*
The manual and changelog are in the header file "lodepng.h"
Rename this file to lodepng.cpp to use it for C++, or to lodepng.c to use it for C.
*/
#include "lodepng.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef LODEPNG_COMPILE_CPP
#include <fstream>
#endif /*LODEPNG_COMPILE_CPP*/
#define VERSION_STRING "20130325"
/*
This source file is built up in the following large parts. The code sections
with the "LODEPNG_COMPILE_" #defines divide this up further in an intermixed way.
-Tools for C and common code for PNG and Zlib
-C Code for Zlib (huffman, deflate, ...)
-C Code for PNG (file format chunks, adam7, PNG filters, color conversions, ...)
-The C++ wrapper around all of the above
*/
/*The malloc, realloc and free functions defined here with "lodepng_" in front
of the name, so that you can easily change them to others related to your
platform if needed. Everything else in the code calls these. Pass
-DLODEPNG_NO_COMPILE_ALLOCATORS to the compiler, or comment out
#define LODEPNG_COMPILE_ALLOCATORS in the header, to disable the ones here and
define them in your own project's source files without needing to change
lodepng source code. Don't forget to remove "static" if you copypaste them
from here.*/
#ifdef LODEPNG_COMPILE_ALLOCATORS
static void* lodepng_malloc(size_t size)
{
return malloc(size);
}
static void* lodepng_realloc(void* ptr, size_t new_size)
{
return realloc(ptr, new_size);
}
static void lodepng_free(void* ptr)
{
free(ptr);
}
#else /*LODEPNG_COMPILE_ALLOCATORS*/
void* lodepng_malloc(size_t size);
void* lodepng_realloc(void* ptr, size_t new_size);
void lodepng_free(void* ptr);
#endif /*LODEPNG_COMPILE_ALLOCATORS*/
/* ////////////////////////////////////////////////////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */
/* // Tools for C, and common code for PNG and Zlib. // */
/* ////////////////////////////////////////////////////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */
/*
Often in case of an error a value is assigned to a variable and then it breaks
out of a loop (to go to the cleanup phase of a function). This macro does that.
It makes the error handling code shorter and more readable.
Example: if(!uivector_resizev(&frequencies_ll, 286, 0)) ERROR_BREAK(83);
*/
#define CERROR_BREAK(errorvar, code)\
{\
errorvar = code;\
break;\
}
/*version of CERROR_BREAK that assumes the common case where the error variable is named "error"*/
#define ERROR_BREAK(code) CERROR_BREAK(error, code)
/*Set error var to the error code, and return it.*/
#define CERROR_RETURN_ERROR(errorvar, code)\
{\
errorvar = code;\
return code;\
}
/*Try the code, if it returns error, also return the error.*/
#define CERROR_TRY_RETURN(call)\
{\
unsigned error = call;\
if(error) return error;\
}
/*
About uivector, ucvector and string:
-All of them wrap dynamic arrays or text strings in a similar way.
-LodePNG was originally written in C++. The vectors replace the std::vectors that were used in the C++ version.
-The string tools are made to avoid problems with compilers that declare things like strncat as deprecated.
-They're not used in the interface, only internally in this file as static functions.
-As with many other structs in this file, the init and cleanup functions serve as ctor and dtor.
*/
#ifdef LODEPNG_COMPILE_ZLIB
/*dynamic vector of unsigned ints*/
typedef struct uivector
{
unsigned* data;
size_t size; /*size in number of unsigned longs*/
size_t allocsize; /*allocated size in bytes*/
} uivector;
static void uivector_cleanup(void* p)
{
((uivector*)p)->size = ((uivector*)p)->allocsize = 0;
lodepng_free(((uivector*)p)->data);
((uivector*)p)->data = NULL;
}
/*returns 1 if success, 0 if failure ==> nothing done*/
static unsigned uivector_resize(uivector* p, size_t size)
{
if(size * sizeof(unsigned) > p->allocsize)
{
size_t newsize = size * sizeof(unsigned) * 2;
void* data = lodepng_realloc(p->data, newsize);
if(data)
{
p->allocsize = newsize;
p->data = (unsigned*)data;
p->size = size;
}
else return 0;
}
else p->size = size;
return 1;
}
/*resize and give all new elements the value*/
static unsigned uivector_resizev(uivector* p, size_t size, unsigned value)
{
size_t oldsize = p->size, i;
if(!uivector_resize(p, size)) return 0;
for(i = oldsize; i < size; i++) p->data[i] = value;
return 1;
}
static void uivector_init(uivector* p)
{
p->data = NULL;
p->size = p->allocsize = 0;
}
#ifdef LODEPNG_COMPILE_ENCODER
/*returns 1 if success, 0 if failure ==> nothing done*/
static unsigned uivector_push_back(uivector* p, unsigned c)
{
if(!uivector_resize(p, p->size + 1)) return 0;
p->data[p->size - 1] = c;
return 1;
}
/*copy q to p, returns 1 if success, 0 if failure ==> nothing done*/
static unsigned uivector_copy(uivector* p, const uivector* q)
{
size_t i;
if(!uivector_resize(p, q->size)) return 0;
for(i = 0; i < q->size; i++) p->data[i] = q->data[i];
return 1;
}
static void uivector_swap(uivector* p, uivector* q)
{
size_t tmp;
unsigned* tmpp;
tmp = p->size; p->size = q->size; q->size = tmp;
tmp = p->allocsize; p->allocsize = q->allocsize; q->allocsize = tmp;
tmpp = p->data; p->data = q->data; q->data = tmpp;
}
#endif /*LODEPNG_COMPILE_ENCODER*/
#endif /*LODEPNG_COMPILE_ZLIB*/
/* /////////////////////////////////////////////////////////////////////////// */
/*dynamic vector of unsigned chars*/
typedef struct ucvector
{
unsigned char* data;
size_t size; /*used size*/
size_t allocsize; /*allocated size*/
} ucvector;
/*returns 1 if success, 0 if failure ==> nothing done*/
static unsigned ucvector_resize(ucvector* p, size_t size)
{
if(size * sizeof(unsigned char) > p->allocsize)
{
size_t newsize = size * sizeof(unsigned char) * 2;
void* data = lodepng_realloc(p->data, newsize);
if(data)
{
p->allocsize = newsize;
p->data = (unsigned char*)data;
p->size = size;
}
else return 0; /*error: not enough memory*/
}
else p->size = size;
return 1;
}
#ifdef LODEPNG_COMPILE_PNG
static void ucvector_cleanup(void* p)
{
((ucvector*)p)->size = ((ucvector*)p)->allocsize = 0;
lodepng_free(((ucvector*)p)->data);
((ucvector*)p)->data = NULL;
}
static void ucvector_init(ucvector* p)
{
p->data = NULL;
p->size = p->allocsize = 0;
}
#ifdef LODEPNG_COMPILE_DECODER
/*resize and give all new elements the value*/
static unsigned ucvector_resizev(ucvector* p, size_t size, unsigned char value)
{
size_t oldsize = p->size, i;
if(!ucvector_resize(p, size)) return 0;
for(i = oldsize; i < size; i++) p->data[i] = value;
return 1;
}
#endif /*LODEPNG_COMPILE_DECODER*/
#endif /*LODEPNG_COMPILE_PNG*/
#ifdef LODEPNG_COMPILE_ZLIB
/*you can both convert from vector to buffer&size and vica versa. If you use
init_buffer to take over a buffer and size, it is not needed to use cleanup*/
static void ucvector_init_buffer(ucvector* p, unsigned char* buffer, size_t size)
{
p->dat
没有合适的资源?快使用搜索试试~ 我知道了~
zxing+opencv解析二维码的DEMO,
共217个文件
h:107个
cpp:101个
o:6个
5星 · 超过95%的资源 需积分: 45 222 下载量 177 浏览量
2016-11-18
12:25:13
上传
评论 6
收藏 859KB ZIP 举报
温馨提示
zxing+opencv解析二维码的DEMO,需要安装opencv,并编译opencv
资源推荐
资源详情
资源评论
收起资源包目录
zxing+opencv解析二维码的DEMO, (217个子文件)
lodepng.cpp 212KB
jpgd.cpp 85KB
BitMatrixParser.cpp 51KB
Version.cpp 29KB
Detector.cpp 25KB
LinesSampler.cpp 24KB
DecodedBitStreamParser.cpp 20KB
Detector.cpp 18KB
FinderPatternFinder.cpp 18KB
Detector.cpp 15KB
DecodedBitStreamParser.cpp 14KB
Code128Reader.cpp 14KB
Decoder.cpp 14KB
DecodedBitStreamParser.cpp 14KB
Detector.cpp 12KB
BitMatrixParser.cpp 12KB
CodaBarReader.cpp 11KB
ITFReader.cpp 10KB
Code39Reader.cpp 10KB
UPCEANReader.cpp 10KB
MultiFinderPatternFinder.cpp 9KB
WhiteRectangleDetector.cpp 9KB
ModulusPoly.cpp 9KB
Code93Reader.cpp 9KB
OneDReader.cpp 8KB
HybridBinarizer.cpp 7KB
Version.cpp 7KB
GenericGFPoly.cpp 7KB
ErrorCorrection.cpp 7KB
AlignmentPatternFinder.cpp 7KB
GlobalHistogramBinarizer.cpp 7KB
MonochromeRectangleDetector.cpp 6KB
StringUtils.cpp 6KB
ReedSolomonDecoder.cpp 6KB
BitMatrixParser.cpp 6KB
PDF417Reader.cpp 5KB
PerspectiveTransform.cpp 5KB
DecodeHints.cpp 5KB
GenericMultipleBarcodeReader.cpp 5KB
FormatInformation.cpp 5KB
Decoder.cpp 4KB
MultiFormatReader.cpp 4KB
GridSampler.cpp 4KB
UPCEReader.cpp 4KB
BitArray.cpp 4KB
DataBlock.cpp 4KB
MultiFormatUPCEANReader.cpp 4KB
DataBlock.cpp 4KB
GenericGF.cpp 4KB
DataMask.cpp 4KB
ResultPoint.cpp 4KB
CharacterSetECI.cpp 4KB
ImageReaderSource.cpp 4KB
BitMatrix.cpp 3KB
Decoder.cpp 3KB
MultiFormatOneDReader.cpp 3KB
Decoder.cpp 3KB
ModulusGF.cpp 3KB
GreyscaleLuminanceSource.cpp 3KB
GreyscaleRotatedLuminanceSource.cpp 3KB
Mode.cpp 3KB
LuminanceSource.cpp 3KB
EAN13Reader.cpp 3KB
FinderPattern.cpp 3KB
zxingdecoder.cpp 2KB
InvertedLuminanceSource.cpp 2KB
ByQuadrantReader.cpp 2KB
UPCAReader.cpp 2KB
QRCodeMultiReader.cpp 2KB
BitSource.cpp 2KB
BinaryBitmap.cpp 2KB
AztecReader.cpp 2KB
EAN8Reader.cpp 2KB
ErrorCorrectionLevel.cpp 2KB
AlignmentPattern.cpp 2KB
QRCodeReader.cpp 2KB
AztecDetectorResult.cpp 2KB
Result.cpp 2KB
DataMatrixReader.cpp 2KB
MultiDetector.cpp 2KB
Str.cpp 2KB
DecoderResult.cpp 1KB
FinderPatternInfo.cpp 1KB
Binarizer.cpp 1KB
CornerPoint.cpp 1KB
Exception.cpp 1KB
DetectorResult.cpp 1KB
FormatException.cpp 1KB
BarcodeFormat.cpp 1KB
opencvbitmapsource.cpp 1KB
ResultIO.cpp 1KB
ChecksumException.cpp 1KB
IllegalArgumentException.cpp 1KB
BitArrayIO.cpp 999B
MultipleBarcodeReader.cpp 969B
ReedSolomonException.cpp 942B
Reader.cpp 878B
OneDResultPoint.cpp 820B
ResultPointCallback.cpp 771B
test1.cpp 754B
共 217 条
- 1
- 2
- 3
shishiyouyou
- 粉丝: 2
- 资源: 26
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页