I'm stuck. I'm trying to print a page using GDI+. I modified some code that works using GDI+ to display an image in a window. When I run this, I get a completely blank page out of the printer.
Here's the code, at least the relevant parts, that I'm using. Again, the non-printing parts of this code work using a window instead of a printer. I don't want to post the complete code just now; it's complicated, and I'm hoping that someone will be able to point out that I left something out here, or some other (hopefully) simple mistake I'm making.
Also, the printing stuff works; copied from another program that successfully prints a page using GDI functions. it's GDI+ that ain't working here.
I thought that printing to a printer's DC using GDI+ would be similar to using a window's DC, but apparently that may not be the case.
BTW, in case the question comes up, the reason I'm using GDI+ instead of plain old GDI is that I need to be able to use non-BMP image files, which are the only ones you can load with GDI. (Using JPEGs here.)
Thanks in advance to anyone who can throw some light on this problem!
; Use Print dialog to select printer, get handle to DC:
INVOKE PrintDlgEx, ADDR printDlgStruct
INVOKE StartDoc, printDlgStruct.hDC, ADDR docInfo
INVOKE StartPage, printDlgStruct.hDC
; Make image filename Unicode:
INVOKE MakeUnicodeName, OFFSET ImageFileName, ADDR unicodeName
; Open JPEG image file:
INVOKE GdipLoadImageFromFile, ADDR unicodeName, OFFSET GdiHbitmap
; Get width & height of bitmap:
INVOKE GdipGetImageWidth, GdiHbitmap, ADDR imgStruct.imgW
INVOKE GdipGetImageHeight, GdiHbitmap, ADDR imgStruct.imgH
; Set image X- and Y-offsets:
MOV ImgStruct.imgX, 0
MOV ImgStruct.imgY, 0
; Get graphics "object" from DC handle:
INVOKE GdipCreateFromHDC, printDlgStruct.hDC, ADDR gdiHgraphics
; Display image at (X,Y) with dimensions (W,H):
; Many thanks to "mabdelouahab" from the MASM32 forum for this.
INVOKE GdipDrawImageRectI, gdiHgraphics, GdiHbitmap,
imgStruct.imgX, imgStruct.imgY, imgStruct.imgW, imgStruct.imgH
; DOESN'T WORK!