JScript Posted March 14, 2011 Share Posted March 14, 2011 (edited) Hello everybody,Could someone help me pass this little VB code for AutoIt?expandcollapse popupOption Explicit Private Type BITMAPINFOHEADER biSize As Long biWidth As Long biHeight As Long biPlanes As Integer biBitCount As Integer biCompression As Long biSizeImage As Long biXPelsPerMeter As Long biYPelsPerMeter As Long biClrUsed As Long biClrImportant As Long End Type Private Type RGBQUAD rgbBlue As Byte rgbGreen As Byte rgbRed As Byte rgbReserved As Byte End Type Private Type BITMAPINFO8 bmiHeader As BITMAPINFOHEADER bmiColors(255) As RGBQUAD End Type Private Sub GrayScale_Click() ' // Convert Picture1 to GrayScale // Dim DeskWnd As Long, DeskDC As Long Dim MyDC As Long Dim MyDIB As Long, OldDIB As Long Dim DIBInf As BITMAPINFO8 Dim MakePal As Long Picture1.AutoRedraw = True ' Create DC based on desktop DC DeskWnd = GetDesktopWindow() DeskDC = GetDC(DeskWnd) MyDC = CreateCompatibleDC(DeskDC) ReleaseDC DeskWnd, DeskDC ' Validate DC If (MyDC = 0) Then Exit Sub ' Set DIB information With DIBInf With .bmiHeader ' Same size as picture .biWidth = Picture1.ScaleX(Picture1.ScaleWidth, Picture1.ScaleMode, vbPixels) .biHeight = Picture1.ScaleY(Picture1.ScaleHeight, Picture1.ScaleMode, vbPixels) .biBitCount = 8 .biPlanes = 1 .biClrUsed = 256 .biClrImportant = 256 .biSize = Len(DIBInf.bmiHeader) End With ' Palette is Greyscale For MakePal = 0 To 255 With .bmiColors(MakePal) .rgbRed = MakePal .rgbGreen = MakePal .rgbBlue = MakePal End With Next MakePal End With ' Create the DIBSection MyDIB = CreateDIBSection8(MyDC, DIBInf, 0, ByVal 0&, 0, 0) If (MyDIB) Then ' Validate and select DIB OldDIB = SelectObject(MyDC, MyDIB) ' Draw original picture to the greyscale DIB BitBlt MyDC, 0, 0, DIBInf.bmiHeader.biWidth, DIBInf.bmiHeader.biHeight, Picture1.hdc, 0, 0, vbSrcCopy ' Draw the greyscale image back to picture box 1 BitBlt Picture1.hdc, 0, 0, DIBInf.bmiHeader.biWidth, DIBInf.bmiHeader.biHeight, MyDC, 0, 0, vbSrcCopy ' Clean up DIB SelectObject MyDC, OldDIB DeleteObject MyDIB End If ' Clean up DC DeleteDC MyDC ' Redraw Picture1.Refresh End SubSource: http://www.allquests.com/question/3418218/Convert-color-images-to-black-and-white.htmlEdit: I found the light at the end of the tunnel...And the best: in assembler! It has what I need and much more...Link: Edited March 21, 2011 by jscript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
JScript Posted March 16, 2011 Author Share Posted March 16, 2011 (edited) If have someone on the forum who understands VB can give me a hand, I shall be very grateful... Edited March 16, 2011 by jscript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 17, 2011 Share Posted March 17, 2011 AutoIt has a lot in common with VBScript, but is not compatible with plain VB. VB code depends on libraries that are not available to an AutoIt script. If you wish to perform that function in AutoIt, scrap the VB code and look at calling ImageMagick instead. Use the forum search for examples. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
ptrex Posted March 18, 2011 Share Posted March 18, 2011 @jscriptAn other option is to use PDFCreator if PDF greyscale output of the picture is OK.Look at the VBScript examples TestCompression.vbs provided with PDFCreator installation.Rgds,ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
JScript Posted March 21, 2011 Author Share Posted March 21, 2011 @PsaltyDS@ptrexThanks for the replies!But giving a very detailed search, I found the light at the end of the tunnel...And the best: in assembler! It has what I need and much more...Link: http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! 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