|
@@ -882,8 +882,6 @@ void CPosPrinter::PrintWaimaiOrderShouyin(CWaimaiOrder& order)
|
|
|
POS_TextOut("请使用配送员app扫码绑定订单", false, false, 1);
|
|
POS_TextOut("请使用配送员app扫码绑定订单", false, false, 1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- POS_OutBmp(_T("D:\\256.jpg"));
|
|
|
|
|
-
|
|
|
|
|
//走纸几行再切
|
|
//走纸几行再切
|
|
|
POS_FeedLine();
|
|
POS_FeedLine();
|
|
|
POS_FeedLine();
|
|
POS_FeedLine();
|
|
@@ -1611,13 +1609,19 @@ void CPosPrinter::POS_OutQRCode(std::string dataString)
|
|
|
escBmp[3] = (unsigned char)(unWidthAdjusted % 256);
|
|
escBmp[3] = (unsigned char)(unWidthAdjusted % 256);
|
|
|
escBmp[4] = (unsigned char)(unWidthAdjusted / 256);
|
|
escBmp[4] = (unsigned char)(unWidthAdjusted / 256);
|
|
|
|
|
|
|
|
|
|
+ //换行符,每打印一行都要发送这个,不然有些尺寸下图片会乱掉
|
|
|
|
|
+ unsigned char change_line_tag = '\n';
|
|
|
|
|
+
|
|
|
|
|
+ //存储每行数据的结构
|
|
|
|
|
+ unsigned char* dataTmp = new unsigned char[unWidthAdjusted * 3];
|
|
|
|
|
+
|
|
|
//循环图片像素打印图片
|
|
//循环图片像素打印图片
|
|
|
for (unsigned int i = 0; i < (unHeightAjusted / 24 + 1); i++)
|
|
for (unsigned int i = 0; i < (unHeightAjusted / 24 + 1); i++)
|
|
|
{
|
|
{
|
|
|
//设置模式为位图模式
|
|
//设置模式为位图模式
|
|
|
WriteBuf(escBmp, 5);
|
|
WriteBuf(escBmp, 5);
|
|
|
|
|
|
|
|
- unsigned char* dataTmp = new unsigned char[unWidthAdjusted * 3];
|
|
|
|
|
|
|
+ //重新开始打印一行,置零
|
|
|
memset(dataTmp, 0, unWidthAdjusted * 3);
|
|
memset(dataTmp, 0, unWidthAdjusted * 3);
|
|
|
|
|
|
|
|
//循环宽
|
|
//循环宽
|
|
@@ -1638,13 +1642,19 @@ void CPosPrinter::POS_OutQRCode(std::string dataString)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
WriteBuf(dataTmp, unWidthAdjusted * 3);
|
|
WriteBuf(dataTmp, unWidthAdjusted * 3);
|
|
|
- delete[] dataTmp;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //换行符,这里必须要发这个,不然图片会乱
|
|
|
|
|
+ WriteBuf(&change_line_tag, 1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ WriteBuf(&change_line_tag, 1);
|
|
|
|
|
+
|
|
|
//还原默认的行间距
|
|
//还原默认的行间距
|
|
|
unsigned char data3[2] = { 0x1B, 0x32 };
|
|
unsigned char data3[2] = { 0x1B, 0x32 };
|
|
|
WriteBuf(data3, 2);
|
|
WriteBuf(data3, 2);
|
|
|
|
|
|
|
|
|
|
+ delete[] dataTmp;
|
|
|
|
|
+
|
|
|
QRcode_free(qrCode);
|
|
QRcode_free(qrCode);
|
|
|
|
|
|
|
|
delete[] realData;
|
|
delete[] realData;
|
|
@@ -1654,6 +1664,9 @@ void CPosPrinter::POS_OutQRCode(std::string dataString)
|
|
|
|
|
|
|
|
void CPosPrinter::POS_OutBmp(std::wstring ImagePath)
|
|
void CPosPrinter::POS_OutBmp(std::wstring ImagePath)
|
|
|
{
|
|
{
|
|
|
|
|
+ //初始化
|
|
|
|
|
+ POS_Reset();
|
|
|
|
|
+
|
|
|
//设置行间距为0
|
|
//设置行间距为0
|
|
|
unsigned char data[3] = { 0x1B, 0x33, 0x00 };
|
|
unsigned char data[3] = { 0x1B, 0x33, 0x00 };
|
|
|
WriteBuf(data, 3);
|
|
WriteBuf(data, 3);
|
|
@@ -1697,13 +1710,19 @@ void CPosPrinter::POS_OutBmp(std::wstring ImagePath)
|
|
|
|
|
|
|
|
Gdiplus::Color pixelColor;
|
|
Gdiplus::Color pixelColor;
|
|
|
|
|
|
|
|
|
|
+ //换行符,每打印一行都要发送这个,不然有些尺寸下图片会乱掉
|
|
|
|
|
+ unsigned char change_line_tag = '\n';
|
|
|
|
|
+
|
|
|
|
|
+ //存储每行数据的结构
|
|
|
|
|
+ unsigned char* dataTmp = new unsigned char[nWidth * 3];
|
|
|
|
|
+
|
|
|
//循环图片像素打印图片
|
|
//循环图片像素打印图片
|
|
|
for (unsigned int i = 0; i < (nHeight / 24 + 1); i++)
|
|
for (unsigned int i = 0; i < (nHeight / 24 + 1); i++)
|
|
|
{
|
|
{
|
|
|
//设置模式为位图模式
|
|
//设置模式为位图模式
|
|
|
WriteBuf(escBmp, 5);
|
|
WriteBuf(escBmp, 5);
|
|
|
|
|
|
|
|
- unsigned char* dataTmp = new unsigned char[nWidth * 3];
|
|
|
|
|
|
|
+ //重新开始打印一行,置零
|
|
|
memset(dataTmp, 0, nWidth * 3);
|
|
memset(dataTmp, 0, nWidth * 3);
|
|
|
|
|
|
|
|
//循环宽
|
|
//循环宽
|
|
@@ -1727,100 +1746,18 @@ void CPosPrinter::POS_OutBmp(std::wstring ImagePath)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
WriteBuf(dataTmp, nWidth * 3);
|
|
WriteBuf(dataTmp, nWidth * 3);
|
|
|
- delete[] dataTmp;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //还原默认的行间距
|
|
|
|
|
- unsigned char data3[2] = { 0x1B, 0x32 };
|
|
|
|
|
- WriteBuf(data3, 2);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-/*
|
|
|
|
|
- *这个是8点双密度的模式
|
|
|
|
|
- **/
|
|
|
|
|
-void CPosPrinter::POS_OutBmp_New(std::wstring ImagePath)
|
|
|
|
|
-{
|
|
|
|
|
- //设置行间距为0
|
|
|
|
|
- unsigned char data[3] = { 0x1B, 0x33, 0x00 };
|
|
|
|
|
- WriteBuf(data, 3);
|
|
|
|
|
-
|
|
|
|
|
- //设置图像居中对齐
|
|
|
|
|
- unsigned char data2[3] = { 0x1B, 0x61, 0x01 };
|
|
|
|
|
- WriteBuf(data2, 3);
|
|
|
|
|
-
|
|
|
|
|
- CBitmapHelper helper;
|
|
|
|
|
- helper.LoadImage(ImagePath.c_str());
|
|
|
|
|
-
|
|
|
|
|
- Bitmap* bmp = helper.getBmp();
|
|
|
|
|
-
|
|
|
|
|
- //先进行图片预处理
|
|
|
|
|
- unsigned int nWidth = bmp->GetWidth();
|
|
|
|
|
- unsigned int nHeight = bmp->GetHeight();
|
|
|
|
|
-
|
|
|
|
|
- //压缩尺寸
|
|
|
|
|
- if (nWidth > 380)
|
|
|
|
|
- {
|
|
|
|
|
- int newWidth = 380;
|
|
|
|
|
- int newHeight = (int)(nHeight / (nWidth / 380.0));
|
|
|
|
|
-
|
|
|
|
|
- helper.ScaleBitmap(newWidth, newHeight);;
|
|
|
|
|
|
|
|
|
|
- nWidth = newWidth;
|
|
|
|
|
- nHeight = newHeight;
|
|
|
|
|
|
|
+ //换行符,这里必须要发这个,不然图片会乱
|
|
|
|
|
+ WriteBuf(&change_line_tag, 1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //二值化
|
|
|
|
|
- helper.Image2Values();
|
|
|
|
|
-
|
|
|
|
|
- //获得最新的图像指针
|
|
|
|
|
- bmp = helper.getBmp();
|
|
|
|
|
-
|
|
|
|
|
- //选择位图模式
|
|
|
|
|
- unsigned char escBmp[5] = { 0x1B, 0x2A, 0x01, 0x00, 0x00 };
|
|
|
|
|
-
|
|
|
|
|
- escBmp[3] = (unsigned char)(nWidth % 256);
|
|
|
|
|
- escBmp[4] = (unsigned char)(nWidth / 256);
|
|
|
|
|
-
|
|
|
|
|
- Gdiplus::Color pixelColor;
|
|
|
|
|
-
|
|
|
|
|
- unsigned char *dataTmp = new unsigned char[1];
|
|
|
|
|
- dataTmp[0] = (unsigned char)'\x00';
|
|
|
|
|
-
|
|
|
|
|
- //循环图片像素打印图片
|
|
|
|
|
- for (unsigned int i = 0; i < (nHeight / 8 + 1); i++)
|
|
|
|
|
- {
|
|
|
|
|
- //设置模式为位图模式
|
|
|
|
|
- WriteBuf(escBmp, 5);
|
|
|
|
|
-
|
|
|
|
|
- //循环宽
|
|
|
|
|
- for (unsigned int j = 0; j < nWidth; j++)
|
|
|
|
|
- {
|
|
|
|
|
- for (unsigned int k = 0; k < 8; k++)
|
|
|
|
|
- {
|
|
|
|
|
- //找到有像素的区域,也就是未超出位图高度的区域
|
|
|
|
|
- if (((i * 8) + k) < nHeight)
|
|
|
|
|
- {
|
|
|
|
|
- bmp->GetPixel(j, (i * 8) + k, &pixelColor);
|
|
|
|
|
- unsigned char r = pixelColor.GetR();
|
|
|
|
|
-
|
|
|
|
|
- if (r == 0)
|
|
|
|
|
- {
|
|
|
|
|
- //如果本来是黑色的像素,那么就把对应的数据位设置为1
|
|
|
|
|
- dataTmp[0] += (unsigned char)(128 >> (k % 8));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- WriteBuf(dataTmp, 1);
|
|
|
|
|
- dataTmp[0] = (unsigned char)'\x00';
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- delete[] dataTmp;
|
|
|
|
|
|
|
+ WriteBuf(&change_line_tag, 1);
|
|
|
|
|
|
|
|
//还原默认的行间距
|
|
//还原默认的行间距
|
|
|
unsigned char data3[2] = { 0x1B, 0x32 };
|
|
unsigned char data3[2] = { 0x1B, 0x32 };
|
|
|
WriteBuf(data3, 2);
|
|
WriteBuf(data3, 2);
|
|
|
|
|
+
|
|
|
|
|
+ delete[] dataTmp;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void CPosPrinter::BIAOQIAN_Reset()
|
|
void CPosPrinter::BIAOQIAN_Reset()
|