RyukShini

Image quality is bad compared to paint

17 posts in this topic

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=car.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GDIPlus.au3>
#include <File.au3>
#include <Array.au3>
#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ProgressConstants.au3>

; Declare array
Dim $Images[1]
; Gets all JPG files in the current directory (@ScriptDir).
Local $search = FileFindFirstFile("*.jpg")

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No JPG files could be found.")
    Exit
EndIf

; Resize array
While 1
    If IsArray($Images) Then
        Local $Bound = UBound($Images)
        ReDim $Images[$Bound+1]
    EndIf
    $Images[$Bound] = FileFindNextFile($search)
    If @error Then ExitLoop
WEnd

; Close the search handle
FileClose($search)

; Create directory "resized" if not there yet
$nymappe = InputBox("Mappe / Bil Navn", "Mappe / Bil Navn")
If NOT FileExists(@ScriptDir & "\" & $nymappe & "\") Then
    DirCreate(@ScriptDir & "\" & $nymappe & "\")
EndIf

; Loop for JPGs - gets dimension of JPG and calls resize function to resize to 50% width and 50% height
For $i = 1 to Ubound($Images)-1
    If $Images[$i] <> "" AND FileExists(@ScriptDir & "\" & $Images[$i]) Then
        Local $ImagePath = @ScriptDir & "\" & $Images[$i]
        _GDIPlus_Startup()
        Local $hImage = _GDIPlus_ImageLoadFromFile($ImagePath)
        Local $ImageWidth = _GDIPlus_ImageGetWidth($hImage)
        Local $ImageHeight = _GDIPlus_ImageGetHeight($hImage)
        _GDIPlus_ImageDispose($hImage)
        _GDIPlus_Shutdown()
        ;MsgBox(0,"DEBUG", $ImageWidth & " x " & $ImageHeight)
        Local $NewImageWidth = ($ImageWidth / 100) * 15
        Local $NewImageHeight = ($ImageHeight / 100) * 15

        ;MsgBox(0,"DEBUG: " & $i,$Images[$i])
        _ImageResize(@ScriptDir & "\" & $Images[$i], @ScriptDir & "\" & $nymappe & "\" & $Images[$i], $NewImageWidth, $NewImageHeight)
    EndIf
Next

; Resize function
Func _ImageResize($sInImage, $sOutImage, $iW, $iH)
    Local $hWnd, $hDC, $hBMP, $hImage1, $hImage2, $hGraphic, $CLSID, $i = 0

    ;OutFile path, to use later on.
    Local $sOP = StringLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))

    ;OutFile name, to use later on.
    Local $sOF = StringMid($sOutImage, StringInStr($sOutImage, "\", 0, -1) + 1)

    ;OutFile extension , to use for the encoder later on.
    Local $Ext = StringUpper(StringMid($sOutImage, StringInStr($sOutImage, ".", 0, -1) + 1))

    ; Win api to create blank bitmap at the width and height to put your resized image on.
    $hWnd = _WinAPI_GetDesktopWindow()
    $hDC = _WinAPI_GetDC($hWnd)
    $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH)
    _WinAPI_ReleaseDC($hWnd, $hDC)

    ;Start GDIPlus
    _GDIPlus_Startup()

    ;Get the handle of blank bitmap you created above as an image
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBMP)

    ;Load the image you want to resize.
    $hImage2 = _GDIPlus_ImageLoadFromFile($sInImage)

    ;Get the graphic context of the blank bitmap
    $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage1)

    ;Draw the loaded image onto the blank bitmap at the size you want
    _GDIPLus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iH)

    ;Get the encoder of to save the resized image in the format you want.
    $CLSID = _GDIPlus_EncodersGetCLSID($Ext)

    ;Generate a number for out file that doesn't already exist, so you don't overwrite an existing image.
    Do
        $i += 1
    Until (Not FileExists($sOP & $i & "_" & $sOF))

    ;Prefix the number to the begining of the output filename
    $sOutImage = $sOP & $i & "_" & $sOF

    ;Save the new resized image.
    _GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage, $CLSID)

    ;Clean up and shutdown GDIPlus.
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _WinAPI_DeleteObject($hBMP)
    _GDIPlus_Shutdown()


EndFunc

Quality gets quite bad compared to using Paint / Photoshop when resizing with GDIPlus
Any idea how to make the quality better?
Thanks in advance

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try the built-in functions

_GDIPlus_ImageResize
_GDIPlus_ImageScale

Further it makes no sense to  call _GDIPlus_Startup() / _GDIPlus_Shutdown() in a loop. Just call _GDIPlus_Startup() once when you start the script and _GDIPlus_Shutdown() when you exit.

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
22 minutes ago, UEZ said:

Try the built-in functions

_GDIPlus_ImageResize
_GDIPlus_ImageScale

Further it makes no sense to  call _GDIPlus_Startup() / _GDIPlus_Shutdown() in a loop. Just call _GDIPlus_Startup() once when you start the script and _GDIPlus_Shutdown() when you exit.

Thank you I will look in to that.
Could you give me a small example?:sweating:

Share this post


Link to post
Share on other sites
Just now, RyukShini said:

Could you give me a small example?:sweating:

What about the examples in the help file?


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
20 minutes ago, UEZ said:

What about the examples in the help file?

Oh sorry, of course!
 

Share this post


Link to post
Share on other sites
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=car.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GDIPlus.au3>
#include <File.au3>
#include <Array.au3>
#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ProgressConstants.au3>

; Declare array
Dim $Images[1]
; Gets all JPG files in the current directory (@ScriptDir).
Local $search = FileFindFirstFile("*.jpg")

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No JPG files could be found.")
    Exit
EndIf

;if no exit then startup gdi
_GDIPlus_Startup()

; Resize array
While 1
    If IsArray($Images) Then
        Local $Bound = UBound($Images)
        ReDim $Images[$Bound+1]
    EndIf
    $Images[$Bound] = FileFindNextFile($search)
    If @error Then ExitLoop
WEnd

; Close the search handle
FileClose($search)

; Create directory "resized" if not there yet
$nymappe = InputBox("Mappe / Bil Navn", "Mappe / Bil Navn")
If NOT FileExists(@ScriptDir & "\" & $nymappe & "\") Then
    DirCreate(@ScriptDir & "\" & $nymappe & "\")
EndIf

; Loop for JPGs - gets dimension of JPG and calls resize function to resize to 50% width and 50% height
For $i = 1 to Ubound($Images)-1
    If $Images[$i] <> "" AND FileExists(@ScriptDir & "\" & $Images[$i]) Then
        Local $ImagePath = @ScriptDir & "\" & $Images[$i]
        _GDIPlus_Startup()
        Local $hImage = _GDIPlus_ImageLoadFromFile($ImagePath)
        Local $ImageWidth = _GDIPlus_ImageGetWidth($hImage)
        Local $ImageHeight = _GDIPlus_ImageGetHeight($hImage)
        _GDIPlus_ImageDispose($hImage)
        _GDIPlus_Shutdown()
        ;MsgBox(0,"DEBUG", $ImageWidth & " x " & $ImageHeight)
        Local $NewImageWidth = ($ImageWidth / 100) * 15
        Local $NewImageHeight = ($ImageHeight / 100) * 15

        ;MsgBox(0,"DEBUG: " & $i,$Images[$i])
        _ImageResize(@ScriptDir & "\" & $Images[$i], @ScriptDir & "\" & $nymappe & "\" & $Images[$i], $NewImageWidth, $NewImageHeight)
    EndIf
Next

; Resize function
Func _ImageResize($sInImage, $sOutImage, $iW, $iH)

    ;OutFile path, to use later on.
    Local $sOP = StringLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))

    ;OutFile name, to use later on.
    Local $sOF = StringMid($sOutImage, StringInStr($sOutImage, "\", 0, -1) + 1)

    ;OutFile extension , to use for the encoder later on.
    Local $Ext = StringUpper(StringMid($sOutImage, StringInStr($sOutImage, ".", 0, -1) + 1))

    ;Load the image you want to resize.
    $hImage = _GDIPlus_ImageLoadFromFile ($sInImage)

    ;Resize
    $hBitmap_Scaled = _GDIPlus_ImageResize($hImage, $iW, $iH)

    ;U can test this too
    ;$hBitmap_Scaled = _GDIPlus_ImageScale($hImage, 0.15, 0.15)

    ;Get the encoder of to save the resized image in the format you want.
    $CLSID = _GDIPlus_EncodersGetCLSID($Ext)

    ;Generate a number for out file that doesn't already exist, so you don't overwrite an existing image.
    Do
        $i += 1
    Until (Not FileExists($sOP & $i & "_" & $sOF))

    ;Prefix the number to the begining of the output filename
    $sOutImage = $sOP & $i & "_" & $sOF

    ;Save the new resized image.
    _GDIPlus_ImageSaveToFileEx($hBitmap_Scaled, $sOutImage, $CLSID)

    ;Clean up and shutdown GDIPlus.
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_BitmapDispose($hBitmap_Scaled)

EndFunc

_GDIPlus_Shutdown()

 

im not sure if this improve quality.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

58 minutes ago, Synapsee said:
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=car.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GDIPlus.au3>
#include <File.au3>
#include <Array.au3>
#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ProgressConstants.au3>

; Declare array
Dim $Images[1]
; Gets all JPG files in the current directory (@ScriptDir).
Local $search = FileFindFirstFile("*.jpg")

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No JPG files could be found.")
    Exit
EndIf

;if no exit then startup gdi
_GDIPlus_Startup()

; Resize array
While 1
    If IsArray($Images) Then
        Local $Bound = UBound($Images)
        ReDim $Images[$Bound+1]
    EndIf
    $Images[$Bound] = FileFindNextFile($search)
    If @error Then ExitLoop
WEnd

; Close the search handle
FileClose($search)

; Create directory "resized" if not there yet
$nymappe = InputBox("Mappe / Bil Navn", "Mappe / Bil Navn")
If NOT FileExists(@ScriptDir & "\" & $nymappe & "\") Then
    DirCreate(@ScriptDir & "\" & $nymappe & "\")
EndIf

; Loop for JPGs - gets dimension of JPG and calls resize function to resize to 50% width and 50% height
For $i = 1 to Ubound($Images)-1
    If $Images[$i] <> "" AND FileExists(@ScriptDir & "\" & $Images[$i]) Then
        Local $ImagePath = @ScriptDir & "\" & $Images[$i]
        _GDIPlus_Startup()
        Local $hImage = _GDIPlus_ImageLoadFromFile($ImagePath)
        Local $ImageWidth = _GDIPlus_ImageGetWidth($hImage)
        Local $ImageHeight = _GDIPlus_ImageGetHeight($hImage)
        _GDIPlus_ImageDispose($hImage)
        _GDIPlus_Shutdown()
        ;MsgBox(0,"DEBUG", $ImageWidth & " x " & $ImageHeight)
        Local $NewImageWidth = ($ImageWidth / 100) * 15
        Local $NewImageHeight = ($ImageHeight / 100) * 15

        ;MsgBox(0,"DEBUG: " & $i,$Images[$i])
        _ImageResize(@ScriptDir & "\" & $Images[$i], @ScriptDir & "\" & $nymappe & "\" & $Images[$i], $NewImageWidth, $NewImageHeight)
    EndIf
Next

; Resize function
Func _ImageResize($sInImage, $sOutImage, $iW, $iH)

    ;OutFile path, to use later on.
    Local $sOP = StringLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))

    ;OutFile name, to use later on.
    Local $sOF = StringMid($sOutImage, StringInStr($sOutImage, "\", 0, -1) + 1)

    ;OutFile extension , to use for the encoder later on.
    Local $Ext = StringUpper(StringMid($sOutImage, StringInStr($sOutImage, ".", 0, -1) + 1))

    ;Load the image you want to resize.
    $hImage = _GDIPlus_ImageLoadFromFile ($sInImage)

    ;Resize
    $hBitmap_Scaled = _GDIPlus_ImageResize($hImage, $iW, $iH)

    ;U can test this too
    ;$hBitmap_Scaled = _GDIPlus_ImageScale($hImage, 0.15, 0.15)

    ;Get the encoder of to save the resized image in the format you want.
    $CLSID = _GDIPlus_EncodersGetCLSID($Ext)

    ;Generate a number for out file that doesn't already exist, so you don't overwrite an existing image.
    Do
        $i += 1
    Until (Not FileExists($sOP & $i & "_" & $sOF))

    ;Prefix the number to the begining of the output filename
    $sOutImage = $sOP & $i & "_" & $sOF

    ;Save the new resized image.
    _GDIPlus_ImageSaveToFileEx($hBitmap_Scaled, $sOutImage, $CLSID)

    ;Clean up and shutdown GDIPlus.
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_BitmapDispose($hBitmap_Scaled)

EndFunc

_GDIPlus_Shutdown()

 

im not sure if this improve quality.

It did not, thank you a lot for trying, but it didn't make any changes really :/
Both of these:
 

;Resize
    $hBitmap_Scaled = _GDIPlus_ImageResize($hImage, $iW, $iH)

    ;U can test this too
    ;$hBitmap_Scaled = _GDIPlus_ImageScale($hImage, 0.15, 0.15)

 

Edited by RyukShini

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

maybe can u post 2 img. the original one and the paint result u target. like this we can see the quality problem and wait a "GDI expert" solution.

I prefer a full AutoIt Version but maybe u can look on a tiers party software (with command line) for improve quality.

Edited by Synapsee

Share this post


Link to post
Share on other sites

wow ! i have a solution, we need set the quality jpeg encoder setting, by default seems not be quality=100.

 

...
    ;Get the encoder of to save the resized image in the format you want.
    $CLSID = _GDIPlus_EncodersGetCLSID($Ext)






    ; code found here :
    ; https://www.autoitscript.com/autoit3/docs/libfunctions/_GDIPlus_ImageSaveToStream.htm
    
        Local $sImgCLSID = _GDIPlus_EncodersGetCLSID("jpg") ;create CLSID for a JPG image file type
        Local $tGUID = _WinAPI_GUIDFromString($sImgCLSID) ;convert CLSID GUID to binary form and returns $tagGUID structure
        Local $tParams = _GDIPlus_ParamInit(1) ;initialize an encoder parameter list and return $tagGDIPENCODERPARAMS structure
        Local $tData = DllStructCreate("int Quality") ;create struct to set JPG quality setting
        DllStructSetData($tData, "Quality", 100) ;quality 0-100 (0: lowest, 100: highest)
        Local $pData = DllStructGetPtr($tData) ;get pointer from quality struct
        _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) ;add a value to an encoder parameter list




    ;Generate a number for out file that doesn't already exist, so you don't overwrite an existing image.
    Do
        $i += 1
    Until (Not FileExists($sOP & $i & "_" & $sOF))

    ;Prefix the number to the begining of the output filename
    $sOutImage = $sOP & $i & "_" & $sOF




    ;Save the new resized image.
    _GDIPlus_ImageSaveToFileEx($hBitmap_Scaled, $sOutImage, $CLSID)
    _GDIPlus_ImageSaveToFileEx($hBitmap_Scaled, $sOutImage & "2.jpg", $CLSID, $tParams); <=========== create a 100% quality output
...

 

Share this post


Link to post
Share on other sites
1 hour ago, Synapsee said:

wow ! i have a solution, we need set the quality jpeg encoder setting, by default seems not be quality=100.

 

...
    ;Get the encoder of to save the resized image in the format you want.
    $CLSID = _GDIPlus_EncodersGetCLSID($Ext)






    ; code found here :
    ; https://www.autoitscript.com/autoit3/docs/libfunctions/_GDIPlus_ImageSaveToStream.htm
    
        Local $sImgCLSID = _GDIPlus_EncodersGetCLSID("jpg") ;create CLSID for a JPG image file type
        Local $tGUID = _WinAPI_GUIDFromString($sImgCLSID) ;convert CLSID GUID to binary form and returns $tagGUID structure
        Local $tParams = _GDIPlus_ParamInit(1) ;initialize an encoder parameter list and return $tagGDIPENCODERPARAMS structure
        Local $tData = DllStructCreate("int Quality") ;create struct to set JPG quality setting
        DllStructSetData($tData, "Quality", 100) ;quality 0-100 (0: lowest, 100: highest)
        Local $pData = DllStructGetPtr($tData) ;get pointer from quality struct
        _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) ;add a value to an encoder parameter list




    ;Generate a number for out file that doesn't already exist, so you don't overwrite an existing image.
    Do
        $i += 1
    Until (Not FileExists($sOP & $i & "_" & $sOF))

    ;Prefix the number to the begining of the output filename
    $sOutImage = $sOP & $i & "_" & $sOF




    ;Save the new resized image.
    _GDIPlus_ImageSaveToFileEx($hBitmap_Scaled, $sOutImage, $CLSID)
    _GDIPlus_ImageSaveToFileEx($hBitmap_Scaled, $sOutImage & "2.jpg", $CLSID, $tParams); <=========== create a 100% quality output
...

 

Amazing!
Will definitely try this when I get back to work.

Thanks a lot ;)

Share this post


Link to post
Share on other sites

@Synapsee

 

It still has a bit of quality loss but it made it better, thank you for trying but Its still not as good as paint?
 

Share this post


Link to post
Share on other sites

can u post the file source jpg for sample ?

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

2 hours ago, Synapsee said:

can u post the file source jpg for sample ?

I can give you a * 15 with paint and * 15 GDI plus!
Would you like that?

Still not good enough quality!
let me know and i'll sent you 2 pics.

Edited by RyukShini

Share this post


Link to post
Share on other sites

Why not saving in PNG format?


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
3 minutes ago, UEZ said:

Why not saving in PNG format?

Do you expect the quality to be better?
It still doesn't change the fact that Paint makes the quality better than GDIPlus for .jpg images.

But thank you for the suggestion!

Share this post


Link to post
Share on other sites

#17 ·  Posted

On ‎08‎.‎07‎.‎2016 at 3:36 PM, RyukShini said:

Paint makes the quality better than GDIPlus for .jpg images

Is still actual?

#include <ScreenCapture.au3>

$hBMP = _ScreenCapture_Capture()

; GDI+ resizign
_GDIPlus_Startup()
$hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
$hScale = _GDIPlus_ImageScale($hImage, 0.5, 0.5)
_GDIPlus_ImageSaveToFile($hScale, "GDIP.jpg")

; gdi32 resizing
$iW = _GDIPlus_ImageGetWidth($hImage)
$iH = _GDIPlus_ImageGetHeight($hImage)
$iW2 = $iW / 2
$iH2 = $iH / 2
$hDC = _WinAPI_GetDC(0)
$hDC1 = _WinAPI_CreateCompatibleDC($hDC)
_WinAPI_SelectObject($hDC1, $hBMP)
$hDC2 = _WinAPI_CreateCompatibleDC($hDC)
$hBMP2 = _WinAPI_CreateCompatibleBitmap($hDC, $iW2, $iH2)
_WinAPI_SelectObject($hDC2, $hBMP2)

_WinAPI_SetStretchBltMode($hDC2, 3) ; looks like Paint resizing
;~ _WinAPI_SetStretchBltMode($hDC2, 4) ; looks better than Paint

_WinAPI_StretchBlt($hDC2, 0, 0, $iW2, $iH2, $hDC1, 0, 0, $iW, $iH, 0x00CC0020) ; $SRCCOPY
$hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP2)
_GDIPlus_ImageSaveToFile($hBitmap, "Paint.jpg")

; cleaning
_WinAPI_DeleteObject($hBMP)
_WinAPI_DeleteObject($hBMP2)
_WinAPI_ReleaseDC(0, $hDC)
_WinAPI_DeleteDC($hDC1)
_WinAPI_DeleteDC($hDC2)
_GDIPlus_ImageDispose($hScale)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_ImageDispose($hBitmap)
_GDIPlus_Shutdown()

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • SimTheNo1
      By SimTheNo1
      I am busy with building a solution for change monitoring of VOIP call program and to be properly automated means among others need for some limited OCR functionality. Current works of others are way too much overkill for this case what makes the need to build it myself. But to do it properly I significantly have to increase my knowledge about digital graphics management.
      For now I already have discovered here and there some mind blowing  Autoit miracles what can be achieved with Windows own possibilities to manipulate that what is output to the monitor. And as far I can judge there are 2 options to process graphics without use of any external libraries like ImageMagick, FreeImage and so on. These are:
       WinAPI  GDIPlus It is for me quite obvious to have various holes in general understanding of graphics and it is once more very clear what advantages gives consistent general study in 1 or another official institutions like University.  Cause there you are introduced into certain domain of knowledge in a way which usually has been perfected over long period of time. So you are not overloaded by stuff which requires a certain amount of information to be initially clear for you. For example, before starting to solve physics you first learn to read, count and so on and then move to subjects like physics.
      Though in my case opportunity to study in such educational system I had only for 8 years, from my 7th to 15th year of age in the country that was falling apart now Ukraine but used to be USSR, was all what it was. After have immigrated to Netherlands possibilities to study further haven't occur. And this therefor causes often various implications when going deep in that or another field of practical knowledge acquiring for any needed physical result, like programming to perform enormous amount of tasks. In this particular case automating VOIP call program.
      Anyway, right now I think the best direction to move is to concentrate on as basic as possible image management and if someone would maybe explain in general what is a pixel will definitely help. Particularly I am very curious about how to do picture manipulations in Autoit. Especially would help a lot to produce eventually following functions:
      createImage($imageFileName, $width, $height, $color) readImagePixel($imageFileName, $x, $y)  writeImagePixel($imageFileName, $x, $y) I do not know exactly how image is handled in computer but preferably above mentioned functions should deal with so far possible origin of graphics creation on computer. But nevertheless I definitely would love to hear any proposition for solution.
      The problem with explaining screenshots:
       VOIPConnect full Window  Part of Window with control to monitor for changes  Exact location of area where actual changes occur and have to be processed  It comes down to a rectangle of approximately 51 pixel wide and 7 pixel high. In fact if I get to learn as far as to be able exactly read, write and compare 2 images consistently across different computers I could narrow down then even further the area to watch as little as a square of 2-5 pixels wide. 
      To finish here is last detail about particularly no need for ultra fast solution at all. This because it is needed only once when it is first run on a new computer and to have to wait few minutes while it is being set instead of just a few seconds make no sence.
      This is it and what I too think to do beside this very particular case is to purify out beautiful generic Autoit functions for core image manipulation by using WinAPI or/and GDIPlus. 
    • UritOR
      By UritOR
      Hi all,
      I'm trying to find how to draw an image (create a label in mspaint) and save it as .bmp. And set it to be a wallpaper
      I also need to know what wallpaper is use now, for restore it when the script is closed.
      What is the best way to do it? Do I need Gdi+ for it?  I use this code (which I found here in forum) to set a .bmp file as wallpaper:
      Func _ChangeWallpaper($sFile,$iType) ; Changes the wallpaper to $sFilename using $iType as: ; 1 Tiled ; 2 Centered ; 3 Stretched ; any other value (usually 0) unchanged ; ; Returns ; 0 if everything is allright. ; -1 if $sFile does not exist. @error is set to 1 ; -2 if £sFile is not a .bmp file. @error is set to 2 If Not FileExists($sFile) Then SetError(1) Return -1 EndIf If StringTrimLeft($sFile,StringInStr($sFile,'.',0,-1)) <> 'bmp' Then SetError(2) Return -2 EndIf Select Case $iType = 1 RegWrite('HKCU\Control Panel\Desktop','TileWallpaper','reg_sz','1') RegWrite('HKCU\Control Panel\Desktop','WallpaperStyle','reg_sz','0') Case $iType = 2 RegWrite('HKCU\Control Panel\Desktop','TileWallpaper','reg_sz','0') RegWrite('HKCU\Control Panel\Desktop','WallpaperStyle','reg_sz','0') Case $iType = 3 RegWrite('HKCU\Control Panel\Desktop','TileWallpaper','reg_sz','0') RegWrite('HKCU\Control Panel\Desktop','WallpaperStyle','reg_sz','2') Case Else EndSelect RegWrite('HKCU\Control Panel\Desktop','Wallpaper','reg_sz',$sFile) DllCall("User32.dll","int","SystemParametersInfo","int",20,"int",0,"str",$sFile,"int",0) Return 0 EndFunc  
      The flow that I understand should be:
      1) Check what wallpaper is in use now. I can find the path to it by going to registry  key named "wallpaper" here :[HKEY_CURRENT_USER\Control Panel\Desktop]
      2) Create a file mspaint
      3) Create a label with its properties (size,color) in this file
      3) Save this file in some temporary directory
      4) Set a created file as a wallpaper using the above code
      5) When the script is closed restore the old wallpaper.
       
      So again, my question is how to create a .bmp file with label in it?
    • Ian_Mac
      By Ian_Mac
      Func dg_get_images() $x1=0 $y1=0 ;MsgBox(0,"start","start") do $result = _ImageSearch("C:\Users\Server\Desktop\my project\image.png",1,$x1,$y1,0) until $result = 1; if $result=1 Then MouseMove($x1,$y1,3) MouseClick("left", $x1,$y1, 1) WinWait("[Title:TightVNC File Transfer]", "", 10) EndIf  this code works when i search the image, but when i change the location of the desktop icon it can't find the desktop icon anymore.   i wanna try image search area. but i don't know how to use it because i cant understand the parameter for the image search area.  please help me how to solve it thank you in advance.
    • corgano
      By corgano
      What I am trying to accomplish is to simplify a .PNG image and convert it to use only a specified pallet of colors. Eg if I have a pallet of 0xFF0000, 0x00FF00, 0x0000FF, it would change every pixel in the image to one of those three colors by whichever color is closest.
       
      The simplest method I have tried is simply converting the image to a 16 bit bitmap, and that does simplify the pallet of the image, but I want to be able to specify what colors it specifies to. The other problem is the resulting saved .BMP file is much larger (file size) than the original, and I don't know if it's possible to make a 16 bit jpg.
       
      It looks like _GDIPlus_BitmapConvertFormat is the solution but the help file doesn't go into how to use the pallet and I couldn't find an example that did what I needed. Can anyone help me?