Jump to content



Photo

FreeImage Library


  • Please log in to reply
62 replies to this topic

#41 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 03 May 2011 - 03:36 PM

Updated to 3.15.0. Download is in the first post.
*GERMAN* Posted Image [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







#42 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,647 posts

Posted 03 May 2011 - 05:14 PM

Plain Text         
C:\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)     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^


#43 jaberwacky

jaberwacky

    jaberwacky

  • Active Members
  • PipPipPipPipPipPip
  • 3,564 posts

Posted 03 May 2011 - 05:22 PM

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.

"In this latter, where the pieces have different and bizarre motions, with various and variable values, what is only complex is mistaken (a not unusual error) for what is profound."

 

Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt WikiUsing the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?


#44 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 03 May 2011 - 05:33 PM

Hey, I had corrected those errors. Did I forget to save? Reupload in a minute. Done.
@LaCastiglione: Thank you for that meaningful comment.

Edited by ProgAndy, 03 May 2011 - 05:38 PM.

*GERMAN* Posted Image [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

#45 IhanPrime

IhanPrime

    Seeker

  • Active Members
  • 5 posts

Posted 24 June 2011 - 04:20 PM

Thank you very much for this :huh2:

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.

AutoIt         
#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 ;)

#46 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 24 June 2011 - 04:51 PM

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.
AutoIt         
#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 by ProgAndy, 24 June 2011 - 04:52 PM.

*GERMAN* Posted Image [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

#47 IhanPrime

IhanPrime

    Seeker

  • Active Members
  • 5 posts

Posted 24 June 2011 - 09:47 PM

Ahhhh, ok. Thank you good sir :huh2:

#48 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 11 December 2011 - 11:46 PM

Before saving as a GIF-image, you'll have to convert the image data to use a color pallette. (FreeImage_ColorQuantize)
*GERMAN* Posted Image [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

#49 One

One

    Seeker

  • Normal Members
  • 5 posts

Posted 14 December 2011 - 10:21 PM

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 by One, 14 December 2011 - 10:22 PM.


#50 One

One

    Seeker

  • Normal Members
  • 5 posts

Posted 14 December 2011 - 10:29 PM

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)"

#51 SyavaK

SyavaK

    Seeker

  • New Members
  • 2 posts

Posted 09 May 2012 - 09:54 AM

hi ProgAndy i found bug, or i can wrong

this 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 file
but i have png in script dir
sorry for my eng i from ukraine )

Edited by SyavaK, 09 May 2012 - 09:58 AM.


#52 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 09 May 2012 - 01:31 PM

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* Posted Image [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

#53 SyavaK

SyavaK

    Seeker

  • New Members
  • 2 posts

Posted 09 May 2012 - 02:30 PM

Looks like a captcha, which we don't discuss or help with.


understand sorry

Edited by SyavaK, 09 May 2012 - 02:42 PM.


#54 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 10,989 posts

Posted 09 May 2012 - 02:38 PM

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 an XP machine, 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 Gude

 

How to ask questions the smart way!

 

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 editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.
GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips. Latin Square password generator

 

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.


#55 Marlo

Marlo

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 304 posts

Posted 23 August 2012 - 06:11 PM

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 :)

AutoIt         
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

#56 Sunaj

Sunaj

    Prodigy

  • Active Members
  • PipPipPip
  • 191 posts

Posted 07 January 2013 - 07:11 PM

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?

#57 Sundance

Sundance

    Prodigy

  • Active Members
  • PipPipPip
  • 196 posts

Posted 11 January 2013 - 12:37 PM

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;amp;"_rsz"&amp;amp;amp;$Ext, $JPEG_OPTIMIZE&amp;amp;amp;'|'&amp;amp;amp;$JPEG_SUBSAMPLING_422&amp;amp;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 by Sundance, 11 January 2013 - 12:44 PM.

  • Sunaj likes this

#58 Sundance

Sundance

    Prodigy

  • Active Members
  • PipPipPip
  • 196 posts

Posted 11 January 2013 - 12:49 PM

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

Plain Text         
#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 &amp;&amp; Palette[i].rgbBlue == 0x00 &amp;&amp; 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[i].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 by Sundance, 11 January 2013 - 02:43 PM.


#59 Sunaj

Sunaj

    Prodigy

  • Active Members
  • PipPipPip
  • 191 posts

Posted 12 January 2013 - 11:42 PM

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..

#60 Sunaj

Sunaj

    Prodigy

  • Active Members
  • PipPipPip
  • 191 posts

Posted 12 January 2013 - 11:49 PM

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

Plain Text         
#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 &amp;&amp; Palette[i].rgbBlue == 0x00 &amp;&amp; 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[i].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!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users