Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: ImageMagickObject COM udfImgClipPut Convert Image DIB
;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfImgClipPut_1 (strFilenameImage) If !FileExist (strFilenameImage) Then Return 0 AddExtender ("WWIMG44I.DLL") ; Load the WIL Pixie Extender. strFilenameTemp = FileCreateTemp ("TMP") If 1 != ImgConvert (strFilenameImage, "DIB:" : strFilenameTemp) Then Return 0 intBBsize = FileSize (strFilenameTemp) If !intBBSize Then Return 0 hdlBB = BinaryAlloc (intBBsize) BinaryRead (hdlBB, strFilenameTemp) BinaryClipPut (hdlBB, 8) ; CF_DIB = 8. hdlBB = BinaryFree (hdlBB) FileDelete (strFilenameTemp) Return intBBSize ;.......................................................................................................................................... ; This user defined function "udfImgClipPut" uses the 'ImgConvert' function of the WinBatch 'Pixie' Extender. ; This function converts an input image file to a DIB formatted temporary file ; and puts the DIB content to Windows Clipboard, ; from where it can be pasted into some graphical application. ; The temporary DIB file is deleted afterwards. ; On success this function returns the DIB size in Byte, on failure it returns 0. ; ; Detlev Dalitz.20020904.20090717. ;.......................................................................................................................................... #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfImgClipPut_2 (strFilenameImage) Switch FileExist (strFilenameImage) Case 1 objIM = ObjectCreate ("ImageMagickObject.MagickImage.1") strInfo = objIM.Convert("MIFF:", strFilenameImage, "CLIPBOARD:") ; e. g. strInfo = "174,288,BMP" Drop (objIM) Return strInfo != "" Case 2 objIM = ObjectCreate ("ImageMagickObject.MagickImage.1") strInfo = objIM.Convert('XC:', '-size', '600x400', 'xc:yellow', '-draw', 'black', '-gravity', 'center', '-pointsize', '20', '-annotate', '0', StrReplace ('"' : strFilenameImage : '"', "\", "\\") : '\nexists, but is currently open\nby another application in read deny mode.', "CLIPBOARD:") ; e. g. strInfo = "600,400,XCP" Drop (objIM) Return strInfo != "" Case 0 objIM = ObjectCreate ("ImageMagickObject.MagickImage.1") strInfo = objIM.Convert('XC:', '-size', '600x400', 'xc:yellow', '-draw', 'black', '-gravity', 'center', '-pointsize', '20', '-annotate', '0', StrReplace ('"' : strFilenameImage : '"', "\", "\\") : '\ndoes not exist.', "CLIPBOARD:") ; e. g. strInfo = "600,400,XCP" Drop (objIM) Return strInfo != "" EndSwitch Return @FALSE ;.......................................................................................................................................... ; This user defined function "udfImgClipPut" uses the 'Convert' function of the ImageMagickObject. ; The ImageMagickObject is a COM+ compatible component that can be invoked from any language capable of using COM objects. ; This function converts resp. copies any supported input image file to Windows Clipboard. ; On success this function returns @TRUE (1), on failure it returns @FALSE (0). ; ; Detlev Dalitz.20080730.20090717. ;.......................................................................................................................................... #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfRunPaint (strMsgTitle) Run ("mspaint", "") While !WinExist ("~Paint") TimeDelay (2) EndWhile If WinExist ("~Paint") WinActivate ("~Paint") SendKeysTo ("~Paint", "^v") ; Paste Clipboard content to MSPaint. Pause (strMsgTitle, "Press OK to continue ...") If WinExist ("~Paint") Then WinClose ("~Paint") While WinExist ("~Paint") TimeDelay (1) EndWhile EndIf #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ; Test. ; The ImageMagickObject COM object must be installed. ; Test 1 strFilenameImage = DirHome () : "WBOwl.bmp" ; File exists. ; Test 1.1 WIL Pixie extender. If udfImgClipPut_1 (strFilenameImage) Then udfRunPaint ("Demo Pixie: udfImgClipPut_1 (strFilenameImage)") ; Test 1.2 ImageMagickObject. If udfImgClipPut_2 (strFilenameImage) Then udfRunPaint ("Demo IM: udfImgClipPut_2 (strFilenameImage)") ; Test 2 strFilenameImage = DirHome () : "WBOwl.bmp.bmp" ; File does not exist. ; ImageMagickObject. If udfImgClipPut_2 (strFilenameImage) Then udfRunPaint ("Demo IM: udfImgClipPut_2 (strFilenameImage)") Exit
Article ID: W18076
Filename: Converts Image to DIB Formatted Temporary File.txt
File Created: 2019:12:02:11:30:30
Last Updated: 2019:12:02:11:30:30