//根据得到的波峰点位绘制网格(仅供调试输出中间结果)
bool __Func_DrawLine(unsigned char** img, unsigned int topmost, unsigned int downmost, const long width, const long height, const unsigned char color) {
	if (img == NULL || downmost <= topmost || downmost - topmost < 2)
		return false;

	unsigned char** preview = new unsigned char*[height];
	for (unsigned long i = 0; i < height; ++i) {
		preview[i] = new unsigned char[width];
	}

	for (unsigned long i = 0; i < height; ++i) {
		memcpy(preview[i], img[i], width * sizeof(unsigned char));
	}

	for (long i = 0; i < width; ++i) {
		preview[topmost][i] = (unsigned char)color;
		preview[downmost][i] = (unsigned char)color;
	}

	CImg * pPreviewImg = create_image();
	pPreviewImg->InitArray8(preview, height, width);
	string filepath = NowTimeToFileName("..//results//bqt//DrawLineToArea", ".bmp");
	pPreviewImg->SaveToFile(filepath.c_str());

	for (unsigned long i = 0; i < height; ++i) {
		delete[] preview[i];
	}
	delete[] preview;
	preview = NULL;

	return true;
}
//根据码带距离重新绘制条码(仅供调试输出中间结果)
bool __Func_DrawLine(unsigned char** img, unsigned int topmost, unsigned int downmost, vector<unsigned long > loc, const long width, const long height, const unsigned char color) {
	if (img == NULL || downmost <= topmost || downmost - topmost < 2)
		return false;

	unsigned char** preview = new unsigned char*[height];
	for (unsigned long i = 0; i < height; ++i) {
		preview[i] = new unsigned char[width];
	}

	for (unsigned long i = 0; i < height; ++i) {
		memcpy(preview[i], img[i], width * sizeof(unsigned char));
	}

	for (long i = 0; i < width; ++i) {
		preview[topmost][i] = (unsigned char)color;
		preview[downmost][i] = (unsigned char)color;
	}

	loc.push_back(width - 1);
	int flag = 1;
	unsigned long xprev = 0;
	for each(unsigned long x in loc) {
		if (x < width) {
			for (unsigned long y = topmost; y <= downmost; ++y) {
				preview[y][x] = (unsigned char)color;

				_ASSERTE(_CrtCheckMemory());
			}
		}
		if (flag > 0) {
			if (x < width) {
				for (unsigned long i = xprev; i <= x; ++i) {
					for (unsigned long y = topmost; y <= downmost; ++y) {
						preview[y][i] = (unsigned char)color;
						_ASSERTE(_CrtCheckMemory());
					}
				}
			}
		}
		else {
			if (x < width) {
				for (unsigned long i = xprev; i <= x; ++i) {
					for (unsigned long y = topmost; y <= downmost; ++y) {
						preview[y][i] = 0x22;
						_ASSERTE(_CrtCheckMemory());
					}
				}
			}
		}
		xprev = x;
		flag *= -1;
	}

	CImg * pPreviewImg = create_image();
	pPreviewImg->InitArray8(preview, height, width);
	string filepath = NowTimeToFileName("..//results//bqt//DrawLineOfGrid", ".bmp");
	pPreviewImg->SaveToFile(filepath.c_str());

	for (unsigned long i = 0; i < height; ++i) {
		delete[] preview[i];
	}
	delete[] preview;
	preview = NULL;

	return true;
}