ProgAndy Posted May 3, 2011 Author Share Posted May 3, 2011 Updated to 3.15.0. Download is in the first post. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Yashied Posted May 3, 2011 Share Posted May 3, 2011 expandcollapse popupC:\Users\Jack\Desktop\freeimage0\FreeImage.au3(690,41) : ERROR: syntax error Global Const $JPEG_OPTIMIZE = 0x20000 / / ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Users\Jack\Desktop\freeimage0\FreeImage.au3(691,41) : ERROR: syntax error Global Const $JPEG_BASELINE = 0x40000 / / ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Users\Jack\Desktop\freeimage0\FreeImage.au3(732,27) : ERROR: syntax error Global Const $TIFF_LOGLUV 0 ~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Users\Jack\Desktop\freeimage0\FreeImage.au3(1755,163) : ERROR: syntax error Local $result = DllCall($__g_hFREEIMAGEDLL, "none", "_FreeImage_ConvertLine1To16_555@16", "ptr", $target, "ptr", $source, "int", $width_in_pixels, "ptr", palette) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Users\Jack\Desktop\freeimage0\FreeImage.au3(1761,163) : ERROR: syntax error Local $result = DllCall($__g_hFREEIMAGEDLL, "none", "_FreeImage_ConvertLine4To16_555@16", "ptr", $target, "ptr", $source, "int", $width_in_pixels, "ptr", palette) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Users\Jack\Desktop\freeimage0\FreeImage.au3(1767,163) : ERROR: syntax error Local $result = DllCall($__g_hFREEIMAGEDLL, "none", "_FreeImage_ConvertLine8To16_555@16", "ptr", $target, "ptr", $source, "int", $width_in_pixels, "ptr", palette) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Users\Jack\Desktop\freeimage0\FreeImage.au3(1791,163) : ERROR: syntax error Local $result = DllCall($__g_hFREEIMAGEDLL, "none", "_FreeImage_ConvertLine1To16_565@16", "ptr", $target, "ptr", $source, "int", $width_in_pixels, "ptr", palette) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Users\Jack\Desktop\freeimage0\FreeImage.au3(1797,163) : ERROR: syntax error Local $result = DllCall($__g_hFREEIMAGEDLL, "none", "_FreeImage_ConvertLine4To16_565@16", "ptr", $target, "ptr", $source, "int", $width_in_pixels, "ptr", palette) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Users\Jack\Desktop\freeimage0\FreeImage.au3(1803,163) : ERROR: syntax error Local $result = DllCall($__g_hFREEIMAGEDLL, "none", "_FreeImage_ConvertLine8To16_565@16", "ptr", $target, "ptr", $source, "int", $width_in_pixels, "ptr", palette) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Users\Jack\Desktop\freeimage0\FreeImage.au3(1827,159) : ERROR: syntax error Local $result = DllCall($__g_hFREEIMAGEDLL, "none", "_FreeImage_ConvertLine1To24@16", "ptr", $target, "ptr", $source, "int", $width_in_pixels, "ptr", palette) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Users\Jack\Desktop\freeimage0\FreeImage.au3(1833,159) : ERROR: syntax error Local $result = DllCall($__g_hFREEIMAGEDLL, "none", "_FreeImage_ConvertLine4To24@16", "ptr", $target, "ptr", $source, "int", $width_in_pixels, "ptr", palette) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Users\Jack\Desktop\freeimage0\FreeImage.au3(1839,159) : ERROR: syntax error Local $result = DllCall($__g_hFREEIMAGEDLL, "none", "_FreeImage_ConvertLine8To24@16", "ptr", $target, "ptr", $source, "int", $width_in_pixels, "ptr", palette) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Users\Jack\Desktop\freeimage0\FreeImage.au3(1863,159) : ERROR: syntax error Local $result = DllCall($__g_hFREEIMAGEDLL, "none", "_FreeImage_ConvertLine1To32@16", "ptr", $target, "ptr", $source, "int", $width_in_pixels, "ptr", palette) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Users\Jack\Desktop\freeimage0\FreeImage.au3(1869,159) : ERROR: syntax error Local $result = DllCall($__g_hFREEIMAGEDLL, "none", "_FreeImage_ConvertLine4To32@16", "ptr", $target, "ptr", $source, "int", $width_in_pixels, "ptr", palette) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Users\Jack\Desktop\freeimage0\FreeImage.au3(1875,159) : ERROR: syntax error Local $result = DllCall($__g_hFREEIMAGEDLL, "none", "_FreeImage_ConvertLine8To32@16", "ptr", $target, "ptr", $source, "int", $width_in_pixels, "ptr", palette) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ 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... Link to comment Share on other sites More sharing options...
jaberwacky Posted May 3, 2011 Share Posted May 3, 2011 All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
ProgAndy Posted May 3, 2011 Author Share Posted May 3, 2011 (edited) Hey, I had corrected those errors. Did I forget to save? Reupload in a minute. Done. @LaCastiglione: Thank you for that meaningful comment. Edited May 3, 2011 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
IhanPrime Posted June 24, 2011 Share Posted June 24, 2011 Thank you very much for this I had a question as far as manipulating pixel data. I have everything working perfectly, until I get to the spot where I need to change the value that the "$bits" pointer points to. expandcollapse popup#include <FreeImage.au3> OnAutoItExitRegister("Cleanup") func Main() _FreeImage_LoadDLL(@ScriptDir&"\FreeImage.dll") _FreeImage_Initialise() ;============================================================================= Global $image = _FreeImage_Load($FIF_TIFF, "test.tif") $bitdepth = _FreeImage_GetBPP($image) $bitsperpixel = _FreeImage_GetLine($image) / _FreeImage_GetWidth($image) Msgbox(0, "", $bitsperpixel) Local $bits ;$temp = _FreeImage_GetChannel($image, $FICC_RED) $y = 0 $x = 0 for $y = 0 to _FreeImage_GetHeight($image) step 1 $bits = _FreeImage_GetScanLine($image, $y) ;Tooltip($bits) for $x = 0 to _FreeImage_GetWidth($image) step 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;Manipulate Pixel here;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $bits = $bits + $bitsperpixel next next Msgbox(0, "", "Done") _FreeImage_Save($FIF_TIFF, $image, "test.tif") endfunc Main() Exit func Cleanup() _FreeImage_Unload($image) _FreeImage_DeInitialise() endfunc I've been looking everywhere for how to manipulate data from a pointer (Like in C++, the simple *ptr), and all I'm getting is Cheat Engine stuff Link to comment Share on other sites More sharing options...
ProgAndy Posted June 24, 2011 Author Share Posted June 24, 2011 (edited) Here is an example for 32bpp-bitmaps (invert the color: 0xAARRGGBB --> 0xAABBGGRR). For other pixel formats you have to change the code in the loop. expandcollapse popup#include <FreeImage.au3> _FreeImage_LoadDLL(@ScriptDir&"\FreeImage.dll") _FreeImage_Initialise() OnAutoItExitRegister("Cleanup") $sFile = @DesktopDir&"\test.tif" ;============================================================================= Global $image = _FreeImage_Load($FIF_TIFF, $sFile) If Not $image Then Exit $bitsperpixel = _FreeImage_GetBPP($image) $bytespp = $bitsperpixel / 8 $iType = _FreeImage_GetImageType($image) If $iType = $FIT_BITMAP And ($bitsperpixel = 32) Then $y = 0 $x = 0 $h = _FreeImage_GetHeight($image) $w = _FreeImage_GetWidth($image) for $y = 0 to $h-1 step 1 $bits = _FreeImage_GetScanLine($image, $y) $t = DllStructCreate("align 4; dword[" & $w & "]", $bits) for $x = 1 to $w step 1 $pix = DllStructGetData($t, 1, $x) $pix = BitOR(BitAND($pix, 0xFF00FF00), BitShift(BitAND($pix, 0x00FF0000), 16), BitShift(BitAND($pix, 0x000000FF), -16)) DllStructSetData($t, 1, $pix, $x) next next _FreeImage_Save($FIF_TIFF, $image, @DesktopDir&"\test.tif") Msgbox(0, "", "Done") Else MsgBox(0, '', "Not supported") EndIf _FreeImage_Unload($image) Exit func Cleanup() _FreeImage_DeInitialise() endfunc Edited June 24, 2011 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
IhanPrime Posted June 24, 2011 Share Posted June 24, 2011 Ahhhh, ok. Thank you good sir Link to comment Share on other sites More sharing options...
ProgAndy Posted December 11, 2011 Author Share Posted December 11, 2011 Before saving as a GIF-image, you'll have to convert the image data to use a color pallette. (FreeImage_ColorQuantize) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
One Posted December 14, 2011 Share Posted December 14, 2011 (edited) My code: #include <FreeImage.au3> _FreeImage_LoadDLL(@ScriptDir&"FreeImage.dll") _FreeImage_Initialise() $sFile = "test.tif" $FIF = _FreeImage_GetFileTypeU($sFile) If $FIF = $FIF_UNKNOWN Then $FIF = _FreeImage_GetFIFFromFilenameU($sFile) EndIf $image = _FreeImage_LoadU($FIF, $sFile) $bitsperpixel = _FreeImage_GetBPP($image) MsgBox(0, '', "$bitsperpixel="&$bitsperpixel) _FreeImage_Unload($image) _FreeImage_DeInitialise() When i use it on test.tif, result is "$bitsperpixel=24", but color of .tif is CMYK... Why? How to use FreeImage with CMYK pictures? Edited December 14, 2011 by One Link to comment Share on other sites More sharing options...
One Posted December 14, 2011 Share Posted December 14, 2011 My code: #include <FreeImage.au3> _FreeImage_LoadDLL(@ScriptDir&"FreeImage.dll") _FreeImage_Initialise() $sFile = "test.tif" $FIF = _FreeImage_GetFileTypeU($sFile) If $FIF = $FIF_UNKNOWN Then $FIF = _FreeImage_GetFIFFromFilenameU($sFile) EndIf $image = _FreeImage_LoadU($FIF, $sFile) $bitsperpixel = _FreeImage_GetBPP($image) MsgBox(0, '', "$bitsperpixel="&$bitsperpixel) _FreeImage_Unload($image) _FreeImage_DeInitialise() When i use it on test.tif, result is "$bitsperpixel=24", but color of .tif is CMYK... Why? How to use FreeImage with CMYK pictures? found mistake: must be "$image = _FreeImage_LoadU($FIF, $sFile, $TIFF_CMYK)" Link to comment Share on other sites More sharing options...
SyavaK Posted May 9, 2012 Share Posted May 9, 2012 (edited) hi ProgAndy i found bug, or i can wrongthis work fine#Include <FreeImage.au3> $sFile = 'Test.png' _FreeImage_LoadDLL(@ScriptDir & 'FreeImage.dll') _FreeImage_Initialise() $FIF = _FreeImage_GetFileTypeU($sFile) If $FIF = $FIF_UNKNOWN Then $FIF = _FreeImage_GetFIFFromFilenameU($sFile) EndIf $hImage = _FreeImage_LoadU($FIF, $sFile) $hGrey = _FreeImage_ConvertToGreyscale($hImage) _FreeImage_SaveU($FIF_PNG, $hGrey, @ScriptDir & 'Test_Grey.png') _FreeImage_Invert($hGrey) _FreeImage_SaveU($FIF_PNG, $hGrey, @ScriptDir & 'Test_Grey_Inverse.png') _FreeImage_Unload($hImage) _FreeImage_Unload($hGrey) _FreeImage_DeInitialise()but this wrong#Include <FreeImage.au3> $PatchTXT = FileOpenDialog ( "Choice text file", @ScriptDir, "Text files (*.txt)", 2+16, "") $TXT = FileOpen($PatchTXT, 0) $sFile = 'Test.png' _FreeImage_LoadDLL(@ScriptDir & 'FreeImage.dll') _FreeImage_Initialise() $FIF = _FreeImage_GetFileTypeU($sFile) If $FIF = $FIF_UNKNOWN Then $FIF = _FreeImage_GetFIFFromFilenameU($sFile) EndIf $hImage = _FreeImage_LoadU($FIF, $sFile) $hGrey = _FreeImage_ConvertToGreyscale($hImage) _FreeImage_SaveU($FIF_PNG, $hGrey, @ScriptDir & 'Test_Grey.png') _FreeImage_Invert($hGrey) _FreeImage_SaveU($FIF_PNG, $hGrey, @ScriptDir & 'Test_Grey_Inverse.png') _FreeImage_Unload($hImage) _FreeImage_Unload($hGrey) _FreeImage_DeInitialise()script looking png file in directory where i choice txt filebut i have png in script dirsorry for my eng i from ukraine ) Edited May 9, 2012 by SyavaK Link to comment Share on other sites More sharing options...
ProgAndy Posted May 9, 2012 Author Share Posted May 9, 2012 FileOpenDialog changes @WorkingDIr, so relative paths start from the new location. If you now the path is relative to the scriptfile, use @ScriptDir to create an absolute path. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
SyavaK Posted May 9, 2012 Share Posted May 9, 2012 (edited) Looks like a captcha, which we don't discuss or help with.understand sorry Edited May 9, 2012 by SyavaK Link to comment Share on other sites More sharing options...
BrewManNH Posted May 9, 2012 Share Posted May 9, 2012 Looks like a captcha, which we don't discuss or help with. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Marlo Posted August 23, 2012 Share Posted August 23, 2012 How would i go about reducing the output file size? I start out with a JPEG roughly 150KB in size and once i run the following code it outputs at around 250KB's. Is there a way to down sample it a bit?I tried changing the filter but it didn't seem to change much. Also would just like to thank you for making such an awesome script Func _ProcessImage($Input, $Output) $sFile = $Input $iTWidth = 600 $iTHeight = 800 _FreeImage_Initialise() $FIF = _FreeImage_GetFileTypeU($sFile) If $FIF = $FIF_UNKNOWN Then $FIF = _FreeImage_GetFIFFromFilenameU($sFile) EndIf $hImage = _FreeImage_LoadU($FIF, $sFile) $oWidth = _FreeImage_GetWidth($hImage) $oHeight = _FreeImage_GetHeight($hImage) $Ratio = $oWidth / $oHeight If $Ratio > 1 Then $hImage = _FreeImage_RotateClassic($hImage, 90) EndIf $hImage = _FreeImage_Rescale($hImage, $iTWidth, $iTHeight, $FILTER_BILINEAR) $hImage = _FreeImage_ConvertToGreyscale($hImage) _FreeImage_SaveU($FIF_PNG, $hImage, $Output) _FreeImage_Unload($hImage) _FreeImage_DeInitialise() EndFunc Click here for the best AutoIt help possible.Currently Working on: Autoit RAT Link to comment Share on other sites More sharing options...
Sunaj Posted January 7, 2013 Share Posted January 7, 2013 Hi ProgAndy, thanks for your work on interfacing this lib; I seem to be having some issues with combining flags when saving using the "_FreeImage_SaveU" function, basically calling it like this: _FreeImage_SaveU($FIF, $hImageResized, $Name &"_rsz"&$Ext, $JPEG_OPTIMIZE&'|'&$JPEG_SUBSAMPLING_422&'|'&$JPEG_QUALITYSUPERB) But the results I am seeing does not indicate that the flags are being picked up right, file size way too small compared to simply passing the JPEG_QUALITYSUPERB flags on its own. Any ideas? [list=1][*]Generic way to detect full path to default browser, List/ListView Events Using GuiRegisterMsg (detect doubleclick and much more)[*]Using dllcall for full control over fileopendialog, Make DirMove act somewhat normally (by circumventing it...)[*]Avoid problems with "&" (chr(38)) in code, Change desktop maximized area/workspace (fx to make deskbar type app)[*]Change focus behavior when buttons are clicked to work closer to 'standard windows' app[*](Context) Menus With Timed Tooltips, Fast Loops & Operators in AU3[*]Clipboard UDF, A clipboard change notification udf[/list] Link to comment Share on other sites More sharing options...
Sundance Posted January 11, 2013 Share Posted January 11, 2013 (edited) Hi ProgAndy, thanks for your work on interfacing this lib; I seem to be having some issues with combining flags when saving using the "_FreeImage_SaveU" function, basically calling it like this: _FreeImage_SaveU($FIF, $hImageResized, $Name &amp;amp;"_rsz"&amp;amp;$Ext, $JPEG_OPTIMIZE&amp;amp;'|'&amp;amp;$JPEG_SUBSAMPLING_422&amp;amp;'|'&amp;amp;$JPEG_QUALITYSUPERB) But the results I am seeing does not indicate that the flags are being picked up right, file size way too small compared to simply passing the JPEG_QUALITYSUPERB flags on its own. Any ideas? Hi, did you try the BitOr function instead of the '&' sign?. _FreeImage_SaveU($FIF, $hImageResized, $Name & "_rsz"&$Ext, BitOR($JPEG_OPTIMIZE,$JPEG_SUBSAMPLING_422,$JPEG_QUALITYSUPERB)) Edited January 11, 2013 by Sundance Sunaj 1 Link to comment Share on other sites More sharing options...
Sundance Posted January 11, 2013 Share Posted January 11, 2013 (edited) Andy, i have also a problem. Hope you can give me a hint or two :-) I need to make the white color of a quantized picture transparent. There is an example in the pdf #include "FreeImage.h" int main(int argc, char* argv[]) { FIBITMAP *hDIB24bpp = FreeImage_Load(FIF_BMP, "test.bmp", 0); if (hDIB24bpp) { // color-quantize 24bpp (results in a 8bpp bitmap to set transparency) FIBITMAP *hDIB8bpp = FreeImage_ColorQuantize(hDIB24bpp, FIQ_WUQUANT); // get palette and find bright green RGBQUAD *Palette = FreeImage_GetPalette(hDIB8bpp); BYTE Transparency[256]; for (unsigned i = 0; i < 256; i++) { Transparency[i] = 0xFF; if (Palette[i].rgbGreen >= 0xFE && Palette[i].rgbBlue == 0x00 && Palette[i].rgbRed == 0x00) { Transparency[i] = 0x00; } } // set the tranparency table FreeImage_SetTransparencyTable(hDIB8bpp, Transparency, 256); // save 8bpp image as transparent PNG FreeImage_Save(FIF_PNG, hDIB8bpp, "test.png", 0); FreeImage_Unload(hDIB24bpp); FreeImage_Unload(hDIB8bpp); } return 0; } My problem is; how can i create a proper structure for the palette? I think it should be 256 times a RGBQUAD structure but i have no idea how to set the value of (ex.) Palette.rgbBlue .... Could be i think to complex but would be nice if you got an idea :-) Thanks in advance and happy weekend sundance EDIT: I GOT IT. :-) If someone is interested, i will post it after the weekend... Edited January 11, 2013 by Sundance Link to comment Share on other sites More sharing options...
Sunaj Posted January 12, 2013 Share Posted January 12, 2013 Hi, did you try the BitOr function instead of the '&' sign?. _FreeImage_SaveU($FIF, $hImageResized, $Name & "_rsz"&$Ext, BitOR($JPEG_OPTIMIZE,$JPEG_SUBSAMPLING_422,$JPEG_QUALITYSUPERB)) I could have sworn I did.. but obviously didn't because this works, thanks a lot for taking time to reply, made my day evening! Guess I took the advice about following the FreeImage PDF manual a bit too literal.. [list=1][*]Generic way to detect full path to default browser, List/ListView Events Using GuiRegisterMsg (detect doubleclick and much more)[*]Using dllcall for full control over fileopendialog, Make DirMove act somewhat normally (by circumventing it...)[*]Avoid problems with "&" (chr(38)) in code, Change desktop maximized area/workspace (fx to make deskbar type app)[*]Change focus behavior when buttons are clicked to work closer to 'standard windows' app[*](Context) Menus With Timed Tooltips, Fast Loops & Operators in AU3[*]Clipboard UDF, A clipboard change notification udf[/list] Link to comment Share on other sites More sharing options...
Sunaj Posted January 12, 2013 Share Posted January 12, 2013 Andy, i have also a problem. Hope you can give me a hint or two :-) I need to make the white color of a quantized picture transparent. There is an example in the pdf #include "FreeImage.h" int main(int argc, char* argv[]) { FIBITMAP *hDIB24bpp = FreeImage_Load(FIF_BMP, "test.bmp", 0); if (hDIB24bpp) { // color-quantize 24bpp (results in a 8bpp bitmap to set transparency) FIBITMAP *hDIB8bpp = FreeImage_ColorQuantize(hDIB24bpp, FIQ_WUQUANT); // get palette and find bright green RGBQUAD *Palette = FreeImage_GetPalette(hDIB8bpp); BYTE Transparency[256]; for (unsigned i = 0; i < 256; i++) { Transparency[i] = 0xFF; if (Palette[i].rgbGreen >= 0xFE && Palette[i].rgbBlue == 0x00 && Palette[i].rgbRed == 0x00) { Transparency[i] = 0x00; } } // set the tranparency table FreeImage_SetTransparencyTable(hDIB8bpp, Transparency, 256); // save 8bpp image as transparent PNG FreeImage_Save(FIF_PNG, hDIB8bpp, "test.png", 0); FreeImage_Unload(hDIB24bpp); FreeImage_Unload(hDIB8bpp); } return 0; } My problem is; how can i create a proper structure for the palette? I think it should be 256 times a RGBQUAD structure but i have no idea how to set the value of (ex.) Palette.rgbBlue .... Could be i think to complex but would be nice if you got an idea :-) Thanks in advance and happy weekend sundance EDIT: I GOT IT. :-) If someone is interested, i will post it after the weekend... I certainly am interested, do post away - used to hack a lot about with http://pngquant.org/ so be interested to see what freeimage can (not?) do when compared! [list=1][*]Generic way to detect full path to default browser, List/ListView Events Using GuiRegisterMsg (detect doubleclick and much more)[*]Using dllcall for full control over fileopendialog, Make DirMove act somewhat normally (by circumventing it...)[*]Avoid problems with "&" (chr(38)) in code, Change desktop maximized area/workspace (fx to make deskbar type app)[*]Change focus behavior when buttons are clicked to work closer to 'standard windows' app[*](Context) Menus With Timed Tooltips, Fast Loops & Operators in AU3[*]Clipboard UDF, A clipboard change notification udf[/list] 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