aggixx Posted May 12, 2009 Posted May 12, 2009 #include <ScreenCapture.au3> $image = _ScreenCapture_Capture("C:\Users\aggixx\Desktop\test.tiff") The above code does not work. It does not give an error, and exits the program 'normally' (console gives no errors) after about a 300 ms. So it seemed like it worked, but when I check my desktop, the file isn't there. I used to have problems with the function crashing the program (In vista, an error message came up, not your normal console error), but that seems to have stopped now. I discovered that this line of code was causing the script to crash (found in _GDIPlus_ImageSaveToFileEx(), which is found in multiple places in the Screen Capture UDF): $aResult = DllCall($ghGDIPDll, "int", "GdipSaveImageToFile", "hwnd", $hImage, "wstr", $sFileName, "ptr", $pGUID, "ptr", $pParams) Of course, the crashes don't happen anymore, I just figured the info might be helpful in finding out what is causing it. It'd probably be good for me too mention that the Capture function does not EVER work, at least with any combination of settings I've found (unless you leave it as a handle). Any ideas? Thanks ahead of time.
Yashied Posted May 12, 2009 Posted May 12, 2009 #include <ScreenCapture.au3> $image = _ScreenCapture_Capture("C:\Users\aggixx\Desktop\test.tiff") The above code does not work. It does not give an error, and exits the program 'normally' (console gives no errors) after about a 300 ms. So it seemed like it worked, but when I check my desktop, the file isn't there. I used to have problems with the function crashing the program (In vista, an error message came up, not your normal console error), but that seems to have stopped now. I discovered that this line of code was causing the script to crash (found in _GDIPlus_ImageSaveToFileEx(), which is found in multiple places in the Screen Capture UDF): $aResult = DllCall($ghGDIPDll, "int", "GdipSaveImageToFile", "hwnd", $hImage, "wstr", $sFileName, "ptr", $pGUID, "ptr", $pParams) Of course, the crashes don't happen anymore, I just figured the info might be helpful in finding out what is causing it. It'd probably be good for me too mention that the Capture function does not EVER work, at least with any combination of settings I've found (unless you leave it as a handle). Any ideas? Thanks ahead of time.Please share with us your code. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
aggixx Posted May 12, 2009 Author Posted May 12, 2009 (edited) Please share with us your code.That's the strange thing, it's such a simple problem. I've tried using the function on many occasions, but it has never worked. So, I just wrote up a quick example, tested it (it didn't work), then posted it. It's the first codebox.I guess I could search around for a more complex example if you wish.EditLong story short, I was trying to write my own version of the CaptureScreen UDF, and it ended being pretty much the same. I had spliced this bit of code from an example I found on these forums and wrote into a UDF.CODE#include <GDIPlus.au3>#include <File.au3>Func _convert($in, $out, $format) $timer = TimerInit () _GDIPlus_Startup() ConsoleWrite("1"&@CRLF) $image = _GDIPlus_ImageLoadFromFile($in) ConsoleWrite("2"&@CRLF) $create = _GDIPlus_ImageSaveToFileEx($image, $out, _GDIPlus_EncodersGetCLSID($format)) ;$create = _GDIPlus_ImageSaveToFile($image, $out) ConsoleWrite("4"&@CRLF) _GDIPlus_Shutdown() ConsoleWrite("5"&@CRLF) $timerdiff = TimerDiff ($timer) Return $createEndFunc_convert("C:\Users\aggixx\Desktop\record1\pic1.bmp", "C:\Users\aggixx\Desktop\record1\pic0.tif", "tif")Now that I run the example, I find that the program crashes on the same line of code that I posted earlier. Edited May 12, 2009 by aggixx
Yashied Posted May 12, 2009 Posted May 12, 2009 Strangely, everything works fine for me. If you try to replace the "tif" to, for example, "jpg"? My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
aggixx Posted May 12, 2009 Author Posted May 12, 2009 Strangely, everything works fine for me. If you try to replace the "tif" to, for example, "jpg"?Nope, still doesn't work. I figured it was probably just a problem with my computer, the question is: what?
Yashied Posted May 12, 2009 Posted May 12, 2009 Nope, still doesn't work. I figured it was probably just a problem with my computer, the question is: what?Perhaps the reason for the malfunction is in the CLSID, check which programs to view the images you have installed (ACDSee, etc.). This is just my opinion. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
aggixx Posted May 13, 2009 Author Posted May 13, 2009 Perhaps the reason for the malfunction is in the CLSID, check which programs to view the images you have installed (ACDSee, etc.). This is just my opinion.Well, oddly enough, TIFs are opened with Photoshop, and TIFFs are opened with MSpaint. Is that what you meant?
aggixx Posted May 13, 2009 Author Posted May 13, 2009 (edited) #include <ScreenCapture.au3> $image = _ScreenCapture_Capture("C:\Users\aggixx\Desktop\test.tiff") The above code does not work. It does not give an error, and exits the program 'normally' (console gives no errors) after about a 300 ms. So it seemed like it worked, but when I check my desktop, the file isn't there. I used to have problems with the function crashing the program (In vista, an error message came up, not your normal console error), but that seems to have stopped now. I discovered that this line of code was causing the script to crash (found in _GDIPlus_ImageSaveToFileEx(), which is found in multiple places in the Screen Capture UDF): $aResult = DllCall($ghGDIPDll, "int", "GdipSaveImageToFile", "hwnd", $hImage, "wstr", $sFileName, "ptr", $pGUID, "ptr", $pParams) Of course, the crashes don't happen anymore, I just figured the info might be helpful in finding out what is causing it. It'd probably be good for me too mention that the Capture function does not EVER work, at least with any combination of settings I've found (unless you leave it as a handle). Any ideas? Thanks ahead of time. Well, I seem to have found an alternative to _ScreenCapture_Capture, but now I need a way to convert the BMP to a TIFF (I need it for OCR). Anyway to do it that doesn't involve GDI? Edited May 13, 2009 by aggixx
Yashied Posted May 14, 2009 Posted May 14, 2009 Use FreeImage library.expandcollapse popupGlobal Const $FIF_UNKNOWN = -1 Global Const $FIF_BMP = 0 Global Const $FIF_ICO = 1 Global Const $FIF_JPEG = 2 Global Const $FIF_JNG = 3 Global Const $FIF_KOALA = 4 Global Const $FIF_LBM = 5 Global Const $FIF_IFF = $FIF_LBM Global Const $FIF_MNG = 6 Global Const $FIF_PBM = 7 Global Const $FIF_PBMRAW = 8 Global Const $FIF_PCD = 9 Global Const $FIF_PCX = 10 Global Const $FIF_PGM = 11 Global Const $FIF_PGMRAW = 12 Global Const $FIF_PNG = 13 Global Const $FIF_PPM = 14 Global Const $FIF_PPMRAW = 15 Global Const $FIF_RAS = 16 Global Const $FIF_TARGA = 17 Global Const $FIF_TIFF = 18 Global Const $FIF_WBMP = 19 Global Const $FIF_PSD = 20 Global Const $FIF_CUT = 21 Global Const $FIF_XBM = 22 Global Const $FIF_XPM = 23 Global Const $FIF_DDS = 24 Global Const $FIF_GIF = 25 Global Const $FIF_HDR = 26 Global Const $FIF_FAXG3 = 27 Global Const $FIF_SGI = 28 Global Const $Sourse = 'C:\WINDOWS\Web\Wallpaper\Ascent.jpg' Global Const $Destination = 'C:\Ascent.tif' $Dll = DllOpen('FreeImage.dll') $hImage = DllCall($Dll, 'ptr', '_FreeImage_LoadU@12', 'int', $FIF_JPEG, 'wstr', $Sourse, 'int', 0) DllCall($Dll, 'int', '_FreeImage_SaveU@16', 'int', $FIF_TIFF, 'ptr', $hImage[0], 'wstr', $Destination, 'int', 0) DllCall($Dll, 'int', '_FreeImage_Unload@4', 'ptr', $hImage[0]) DllClose($Dll) My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
aggixx Posted May 14, 2009 Author Posted May 14, 2009 Use FreeImage library. expandcollapse popupGlobal Const $FIF_UNKNOWN = -1 Global Const $FIF_BMP = 0 Global Const $FIF_ICO = 1 Global Const $FIF_JPEG = 2 Global Const $FIF_JNG = 3 Global Const $FIF_KOALA = 4 Global Const $FIF_LBM = 5 Global Const $FIF_IFF = $FIF_LBM Global Const $FIF_MNG = 6 Global Const $FIF_PBM = 7 Global Const $FIF_PBMRAW = 8 Global Const $FIF_PCD = 9 Global Const $FIF_PCX = 10 Global Const $FIF_PGM = 11 Global Const $FIF_PGMRAW = 12 Global Const $FIF_PNG = 13 Global Const $FIF_PPM = 14 Global Const $FIF_PPMRAW = 15 Global Const $FIF_RAS = 16 Global Const $FIF_TARGA = 17 Global Const $FIF_TIFF = 18 Global Const $FIF_WBMP = 19 Global Const $FIF_PSD = 20 Global Const $FIF_CUT = 21 Global Const $FIF_XBM = 22 Global Const $FIF_XPM = 23 Global Const $FIF_DDS = 24 Global Const $FIF_GIF = 25 Global Const $FIF_HDR = 26 Global Const $FIF_FAXG3 = 27 Global Const $FIF_SGI = 28 Global Const $Sourse = 'C:\WINDOWS\Web\Wallpaper\Ascent.jpg' Global Const $Destination = 'C:\Ascent.tif' $Dll = DllOpen('FreeImage.dll') $hImage = DllCall($Dll, 'ptr', '_FreeImage_LoadU@12', 'int', $FIF_JPEG, 'wstr', $Sourse, 'int', 0) DllCall($Dll, 'int', '_FreeImage_SaveU@16', 'int', $FIF_TIFF, 'ptr', $hImage[0], 'wstr', $Destination, 'int', 0) DllCall($Dll, 'int', '_FreeImage_Unload@4', 'ptr', $hImage[0]) DllClose($Dll) Looks great, but: C:\Users\aggixx\Desktop\AU3 Scripts\test384.au3 (39) : ==> Subscript used with non-Array variable.: DllCall($Dll, 'int', '_FreeImage_SaveU@16', 'int', $FIF_TIFF, 'ptr', $hImage[0], 'wstr', $Destination, 'int', 0) DllCall($Dll, 'int', '_FreeImage_SaveU@16', 'int', $FIF_TIFF, 'ptr', $hImage^ ERROR
Yashied Posted May 14, 2009 Posted May 14, 2009 Looks great, but: C:\Users\aggixx\Desktop\AU3 Scripts\test384.au3 (39) : ==> Subscript used with non-Array variable.: DllCall($Dll, 'int', '_FreeImage_SaveU@16', 'int', $FIF_TIFF, 'ptr', $hImage[0], 'wstr', $Destination, 'int', 0) DllCall($Dll, 'int', '_FreeImage_SaveU@16', 'int', $FIF_TIFF, 'ptr', $hImage^ ERRORChange to an existing picture (JPEG). This library is used by many programs. Actually read the documentation in a lot of interesting things. It also can be downloaded on the link that I gave you. This is a pretty powerful library. $Sourse = 'C:\WINDOWS\Web\Wallpaper\Ascent.jpg' My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
aggixx Posted May 14, 2009 Author Posted May 14, 2009 Change to an existing picture (JPEG). This library is used by many programs. Actually read the documentation in a lot of interesting things. It also can be downloaded on the link that I gave you. This is a pretty powerful library. $Sourse = 'C:\WINDOWS\Web\Wallpaper\Ascent.jpg'It gives me the same error even when the file exists.
Yashied Posted May 14, 2009 Posted May 14, 2009 If the file 'C:\WINDOWS\Web\Wallpaper\Ascent.jpg' exists and FreeImage.dll is in the same folder where your script, then everything should work! Nonses. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
aggixx Posted May 15, 2009 Author Posted May 15, 2009 If the file 'C:\WINDOWS\Web\Wallpaper\Ascent.jpg' exists and FreeImage.dll is in the same folder where your script, then everything should work! Nonses.Well, that seems to make it work. But the problem is, the resulting file (tiff) is broken. It is not recognized by tesseract.exe or Photoshop.
aggixx Posted May 15, 2009 Author Posted May 15, 2009 Well, that seems to make it work. But the problem is, the resulting file (tiff) is broken. It is not recognized by tesseract.exe or Photoshop.Here are the errors it gives: tesseract.log Tesseract Open Source OCR Engine name_to_image_type:Error:Unrecognized image type:captured.tiff IMAGE::read_header:Error:Can't read this image type:captured.tiff Tessedit:Error:Read of file failed:captured.tiff Signal_exit 31 ABORT. LocCode: 3 AbortCode: 3 Adobe Photoshop CS3 Could not complete your request because it is not the right kind of document.
Yashied Posted May 15, 2009 Posted May 15, 2009 Here are the errors it gives: tesseract.log Tesseract Open Source OCR Engine name_to_image_type:Error:Unrecognized image type:captured.tiff IMAGE::read_header:Error:Can't read this image type:captured.tiff Tessedit:Error:Read of file failed:captured.tiff Signal_exit 31 ABORT. LocCode: 3 AbortCode: 3 Adobe Photoshop CS3 Could not complete your request because it is not the right kind of document.Give me your code (only relevant) and the image that you try to convert. I see. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
aggixx Posted May 15, 2009 Author Posted May 15, 2009 (edited) Give me your code (only relevant) and the image that you try to convert. I see.expandcollapse popupGlobal Const $FIF_UNKNOWN = -1 Global Const $FIF_BMP = 0 Global Const $FIF_ICO = 1 Global Const $FIF_JPEG = 2 Global Const $FIF_JPG = $FIF_JPEG Global Const $FIF_JNG = 3 Global Const $FIF_KOALA = 4 Global Const $FIF_LBM = 5 Global Const $FIF_IFF = $FIF_LBM Global Const $FIF_MNG = 6 Global Const $FIF_PBM = 7 Global Const $FIF_PBMRAW = 8 Global Const $FIF_PCD = 9 Global Const $FIF_PCX = 10 Global Const $FIF_PGM = 11 Global Const $FIF_PGMRAW = 12 Global Const $FIF_PNG = 13 Global Const $FIF_PPM = 14 Global Const $FIF_PPMRAW = 15 Global Const $FIF_RAS = 16 Global Const $FIF_TARGA = 17 Global Const $FIF_TIFF = 18 Global Const $FIF_TIF = $FIF_TIFF Global Const $FIF_WBMP = 19 Global Const $FIF_PSD = 20 Global Const $FIF_CUT = 21 Global Const $FIF_XBM = 22 Global Const $FIF_XPM = 23 Global Const $FIF_DDS = 24 Global Const $FIF_GIF = 25 Global Const $FIF_HDR = 26 Global Const $FIF_FAXG3 = 27 Global Const $FIF_SGI = 28 Func GetConvID($fileid) $retvar = "false" Switch $fileid Case "BMP" $retvar = 0 Case "JPG" or "JPEG" $retvar = 2 Case "PNG" $retvar = 13 Case "TIF" or "TIFF" $retvar = 18 Case "GIF" $retvar = 25 EndSwitch Return $retvar EndFunc Global Const $Source = 'C:\WINDOWS\Web\Wallpaper\Ascent.jpg' Global Const $Destination = 'C:\Ascent.tif' $dll = DllOpen('FreeImage.dll') ;DllClose($Dll) Func ConvertImg($in, $out) $inext = StringSplit( $in, ".", 1 ) $inext = GetConvID($inext[$inext[0]]) $outext = StringSplit( $out, ".", 1 ) $outext = GetConvID($outext[$outext[0]]) $hImage = DllCall($dll, 'ptr', '_FreeImage_LoadU@12', 'int', $inext, 'wstr', $in, 'int', 0) DllCall($Dll, 'int', '_FreeImage_SaveU@16', 'int', $outext, 'ptr', $hImage[0], 'wstr', $out, 'int', 0) DllCall($Dll, 'int', '_FreeImage_Unload@4', 'ptr', $hImage[0]) Return FileExists( $out ) EndFunc ConsoleWrite(ConvertImg("C:\Users\aggixx\Desktop\text.bmp","C:\Users\aggixx\Desktop\text.tiff")) I modified the code a little, but you get the idea.text.bmp Edited May 15, 2009 by aggixx
Yashied Posted May 16, 2009 Posted May 16, 2009 (edited) EDIT: Func GetConvID($fileid) Switch $fileid Case "BMP" Return 0 Case "JPG", "JPEG" Return 2 Case "PNG" Return 13 Case "TIF", "TIFF" Return 18 Case "GIF" Return 25 Case Else Return -1 EndSwitch EndFunc ;==>GetConvID Edited May 16, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
aggixx Posted May 16, 2009 Author Posted May 16, 2009 EDIT: Func GetConvID($fileid) Switch $fileid Case "BMP" Return 0 Case "JPG", "JPEG" Return 2 Case "PNG" Return 13 Case "TIF", "TIFF" Return 18 Case "GIF" Return 25 Case Else Return -1 EndSwitch EndFunc ;==>GetConvIDWell, it seems to be working relatively well now, but I'm still getting an error. It seems that the conversion is compressing the TIFF file, and Tesseract cannot support that.
Yashied Posted May 16, 2009 Posted May 16, 2009 Well, it seems to be working relatively well now, but I'm still getting an error. It seems that the conversion is compressing the TIFF file, and Tesseract cannot support that.$ret = DllCall($dll, 'int', '_FreeImage_SaveU@16', 'int', $outext, 'ptr', $hImage[0], 'wstr', $out, 'int', 0x0800) aggixx, why did you not read the documentation, everything is written? 0x0800 - TIF without compression My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
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