直接上代码:
import win.ui; import gdip.graphics; import sys.printer; import qrencode.bitmap; /*DSG{{*/ mainForm = win.form(text="使用sys.printer+gdip打印二维码图片";right=451;bottom=252;parent=...) mainForm.add( button={cls="button";text="打印二维码";left=112;top=90;right=214;bottom=130;z=1}; edit={cls="edit";left=111;top=50;right=331;bottom=75;edge=1;z=3}; static={cls="static";text="二维码内容:";left=34;top=56;right=119;bottom=75;transparent=1;z=2} ) /*}}*/ mainForm.button.oncommand = function(id,event){ var pdc = sys.printer().createDevice(); pdc.start(function(hdcPrinter){ var bmp = qrencode.bitmap(mainForm.edit.text); bmp.copyBitmap(180); var graphics = gdip.graphics(hdcPrinter); graphics.drawImageRect(bmp[["bitmap"]], 0,0, 180, 180); }); } mainForm.enableDpiScaling(); mainForm.show(); return win.loopMessage();
转自:http://bbs.aardio.com/forum.php?mod=viewthread&tid=22064