jwurmz Posted December 8, 2010 Share Posted December 8, 2010 I'm trying to create an application that will create an image-based signature for email. It will take as input a number of text strings like Full Name, Job Title, Phone/Fax, Company Logo (, etc.). The program would place those text strings and the logo in series, and generate an image of that series, like in the attachment. I'm trying to use GDI+ to get it done, but I'm having some trouble with saving the image -- it just saves a black image. I'm not exactly sure what I'm doing wrong; if anyone can help that would be great OR if you can suggest another way of achieving the same results that would also be great. Here is my code: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> $mainwindow = GUICreate("Signature Generator", 400, 200, (@DesktopWidth / 2) - 200, (@DesktopHeight / 2) - 200) GUISetState() $fullnamelabel = GUICtrlCreateLabel("Name:", 10, 13, 40, 20, $SS_RIGHT) $fullnameinput = GUICtrlCreateInput("", 55, 10, 165, 20) $fullnamefont = GUICtrlCreateCombo("Arial", 225, 10, 120, 20) $fullnamesize = GUICtrlCreateInput("12", 350, 10, 40, 20) $fullnamesizeupdown = GUICtrlCreateUpdown($fullnamesize) $titlelabel = GUICtrlCreateLabel("Title:", 10, 38, 40, 20, $SS_RIGHT) $titleinput = GUICtrlCreateInput("", 55, 35, 165, 20) $titlefont = GUICtrlCreateCombo("Arial", 225, 35, 120, 20) $titlesize = GUICtrlCreateInput("12", 350, 35, 40, 20) $titlesizeupdown = GUICtrlCreateUpdown($titlesize) $phonelabel = GUICtrlCreateLabel("Phone:", 10, 63, 40, 20, $SS_RIGHT) $phoneinput = GUICtrlCreateInput("", 55, 60, 165, 20) $phonefont = GUICtrlCreateCombo("Arial", 225, 60, 120, 20) $phonesize = GUICtrlCreateInput("12", 350, 60, 40, 20) $phonesizeupdown = GUICtrlCreateUpdown($phonesize) $faxlabel = GUICtrlCreateLabel("Fax:", 10, 88, 40, 20, $SS_RIGHT) $faxinput = GUICtrlCreateInput("", 55, 85, 165, 20) $faxfont = GUICtrlCreateCombo("Arial", 225, 85, 120, 20) $faxsize = GUICtrlCreateInput("12", 350, 85, 40, 20) $faxsizeupdown = GUICtrlCreateUpdown($faxsize) $logolabel = GUICtrlCreateLabel("Logo:", 10, 118, 40, 20, $SS_RIGHT) $logobutton = GUICtrlCreateButton("Browse", 55, 110, 335, 35) $savebutton = GUICtrlCreateButton("Save", 55, 150, 335, 40) $previewwindow = GUICreate("Preview", 400, 200, (@DesktopWidth / 2) - 200, (@DesktopHeight / 2) - 100 + 150, $WS_EX_TOOLWINDOW) GUISetState(@SW_SHOW, $previewwindow) $context = _WinAPI_GetWindowDC($previewwindow) _GDIPlus_Startup() $previewgraphic = _GDIPlus_GraphicsCreateFromHDC($context) $brush = _GDIPlus_BrushCreateSolid (0x7F00007F) $format = _GDIPlus_StringFormatCreate () $fontfamily = _GDIPlus_FontFamilyCreate ("Arial") $font = _GDIPlus_FontCreate ($fontfamily, 12, 2) $rectfont = _GDIPlus_RectFCreate (140, 100, 100, 20) _GDIPlus_GraphicsDrawStringEx ($previewgraphic, "Hello world", $font, $rectfont, $format, $brush) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $savebutton $tempbmp = _GDIPlus_BitmapCreateFromGraphics(400, 200, $previewgraphic) _GDIPlus_ImageSaveToFile($tempbmp, @ScriptDir & "\test.bmp") _GDIPlus_BitmapDispose($tempbmp) EndSelect WEnd _GDIPlus_FontDispose ($font) _GDIPlus_FontFamilyDispose ($fontfamily) _GDIPlus_StringFormatDispose ($format) _GDIPlus_BrushDispose ($brush) _GDIPlus_GraphicsDispose ($previewgraphic) _WinAPI_ReleaseDC($mainwindow, $context) _GDIPlus_Shutdown () GUIDelete() Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now