Ich möchte QR -Bild (Bitmap) und Text mit ESCPOs drucken. Ich verwende Visual Studio 2005. Dies ist die einzige Version, die bei der Arbeit verfügbar ist. Die unten stehende Logik ist das, was ich bisher geändert habe.
qr iamage hier → qrimage < /p>
Dieses Qrimage ist Bitmap (128x128) < /p>
Ich habe erfolgreich das Drucken eines Bitmap -Bildes mithilfe mithilfe des Druckens implementiert GS V 0 in ESC/POS. > Ich habe festgestellt, dass viele Leute dieselbe Frage wie ich gestellt haben. →
Link < /p>
Ich habe es erstellt, um das Druck von Bitmap -Bildern anstelle von Text zu priorisieren. . /p>
HBITMAP hBmp;
LONG x, y, x1, h;
CString temp = "";
CString csFileName = "C:\QRCODE.bmp";
hBmp = (HBITMAP)::LoadImage(NULL, fileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_MONOCHROME);
if (hBmp == NULL) {
return FALSE
}
CBitmap* m_bmpImage = CBitmap::FromHandle(hBmp);
BITMAP m_bmpInfo;
m_bmpImage->GetBitmap(&m_bmpInfo);
if (m_bmpInfo.bmBitsPixel != 1) {
return ERR_PRT_WRITE;
}
int width = m_bmpInfo.bmWidth;
int height = m_bmpInfo.bmHeight;
int bytesPerLine = (width + 7) / 8;
int totalSize = m_bmpInfo.bmWidthBytes * height;
BYTE* m_buf = (BYTE*)malloc(totalSize);
if (m_buf == NULL) {
return FALSE;
}
memset(m_buf, 0x00, totalSize);
BYTE bmiBuffer[sizeof(BITMAPINFOHEADER) + 2 * sizeof(RGBQUAD)];
BITMAPINFO* pBMI = (BITMAPINFO*)bmiBuffer;
ZeroMemory(bmiBuffer, sizeof(bmiBuffer));
pBMI->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pBMI->bmiHeader.biWidth = m_bmpInfo.bmWidth;
pBMI->bmiHeader.biHeight = m_bmpInfo.bmHeight;
pBMI->bmiHeader.biPlanes = 1;
pBMI->bmiHeader.biBitCount = 1;
pBMI->bmiHeader.biCompression = BI_RGB;
pBMI->bmiColors[0].rgbBlue = 0;
pBMI->bmiColors[0].rgbGreen = 0;
pBMI->bmiColors[0].rgbRed = 0;
pBMI->bmiColors[0].rgbReserved = 0;
pBMI->bmiColors[1].rgbBlue = 255;
pBMI->bmiColors[1].rgbGreen = 255;
pBMI->bmiColors[1].rgbRed = 255;
pBMI->bmiColors[1].rgbReserved = 0;
HDC hdc = ::GetDC(NULL);
if (!GetDIBits(hdc, hBmp, 0, m_bmpInfo.bmHeight, m_buf, pBMI, DIB_RGB_COLORS)) {
::ReleaseDC(NULL, hdc);
free(m_buf);
return ERR_PRT_WRITE;
}
::ReleaseDC(NULL, hdc);
for (int i = 0; i < 10; i++) {
printf("m_buf[%d]: 0x%02X\n", i, m_buf);
}
BYTE sendData[1024];
int pos = 0;
for (int row = 0; row < height; row += 8) {
pos = 0;
sendData[pos++] = 0x1B; // ESC
sendData[pos++] = '*'; // '*'
sendData[pos++] = 0; // mode:0
sendData[pos++] = (BYTE)(width & 0xFF); // nL
sendData[pos++] = (BYTE)((width >> 8) & 0xFF); // nH
for (int col = 0; col < width; col++) {
BYTE c = 0;
for (int i = 0; i < 8; i++) {
int currentRow = row + i;
if (currentRow < height) {
int byteIndex = currentRow * m_bmpInfo.bmWidthBytes + (col / 8);
int bitIndex = col % 8;
BYTE pixelByte = m_buf[byteIndex];
if (pixelByte & (0x80 >> bitIndex)) {
c |= (1
Also, drucken Sie ... hier ....
Bildbeschreibung hier eingeben
Ich verstehe meine Quittung nicht ...
Die Fragen und Antworten hier sind ziemlich unreif. Es tut mir leid.
Wie kann ich ein Bild auf einem Epson -Drucker mit MFC drucken? [geschlossen] ⇐ C++
-
- Similar Topics
- Replies
- Views
- Last post