1

簡単な画像を印刷するために Windows スプーラ API を使用しています。「TEXT」モードでは、データを char に変換するように、プリンターが画像をテキストとして印刷します。したがって、「RAW」モードを使用する必要がありますが、この場合は何も追加しません。
コードは次のとおりです。

void camgl::printShoot() {
HANDLE print_handle;
DOC_INFO_1 docinfo1;
DWORD bytes_written;

docinfo1.pDocName = (LPTSTR)L"Shot.jpg";
docinfo1.pOutputFile = NULL;
docinfo1.pDatatype = (LPTSTR)L"RAW";

BOOL bool1, bool2, bool3, bool4;

bool1 = OpenPrinter((LPTSTR)L"Canon MG6300 series Printer", &print_handle, NULL);
bool2 = StartDocPrinter(print_handle, 1, (LPBYTE)&docinfo1);

bool3 = StartPagePrinter(print_handle);
bool4 = WritePrinter(print_handle, (LPVOID)image->imageData, (DWORD)image->imageSize, &bytes_written);
EndPagePrinter(print_handle);
EndDocPrinter(print_handle);

ClosePrinter(print_handle); 
}

変数「画像」は次のように定義されます。

  • IplImage *イメージ;

ここで、IplImage は OpenCV タイプのイメージです。

フォーム フィード文字をプリンターに送信しようとしましたが、成功しませんでした:

int iFF = 0x0c;
WritePrinter(print_handle, (LPVOID)&iFF, (DWORD)sizeof(iFF), &bytes_written);

どちらの場合も、printShoot() メソッドに対応するジョブが印刷キューに表示され、キューはエラーなしでクリアされ、プリンターによって何も印刷されません。

==============

見つけたばかりのこの記事を追加します:
http://www.codeproject.com/Articles/8916/Printing-Architecture

4

2 に答える 2