1
votes

I'm using windows spooler API in order to print a simple picture. In "TEXT" mode, my printer prints the picture as a text like it converts its data to char. So I've to use the "RAW" mode but nothing append in this case.
Here is the code :

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); 
}

The variable "image" is defined like this :

  • IplImage *image;

where IplImage is an OpenCV type of image.

I've tried to send a form-feed character to the printer but with no success:

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

In both cases, the print queue displays a job that correspond to the printShoot() method, then the queue is cleared with no error and nothing is print by the printer.

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

I add this article i've just found :
http://www.codeproject.com/Articles/8916/Printing-Architecture

2
It is a cheap inkjet printer, the kind that doesn't have its own printing language like Postscript or PCL. Nor the RAM to store a page. They rely on the printer driver to do the heavy lifting. - Hans Passant
The printer probably wont print JPEG images. Have you checked articles /solutions like graphicsbb.itgo.com/BitmapPrint.html or sourceforge.net/projects/imageprinter - Tony
WritePrinter only supports GDI printing. msdn.microsoft.com/en-us/library/windows/desktop/… - Tony
the printer is a Canon MG6350. GDI don't seem to be supported. XPS is supported. I found a related sourceforge project which a source code : sourceforge.net/projects/emfprinter/?source=dlp - user1312748
Unfortunately, imageprinter or emfprinter project are helpless - user1312748

2 Answers

0
votes

WritePrinter only supports GDI printing.

Printing JPEG image requires more code. IF it is urgent, you can try to call Command line MS Paint to print the JPEG image

C:\Windows\System32\mspaint.exe C:\image.jpg /p