Je suis pas un pro de GDI+ mais bon...
En fait, je pense qu'il faut que tu détermines la couleur moyenne de ton image. Pour ça, j'ai trouvé des scripts, mais ils sont très longs car ils parcourent toute l'image pixel par pixel...
Mon idée serait plutôt de dupliquer et redimensionner l'image en une image de 1 pixel x 1 pixel : du coup le ré-échantillonnage te donnerait un pixel de couleur "moyenne" approximative.
Je ne sais pas si cette technique sera vraiment fiable, mais tu peux essayer.
Je t'ai fait un petit bout de script, si tu veux regarder. Ma fonction _ImageAverageColor retourne la couleur moyenne (en utilisant le redimensionnement de 1x1) au format RRGGBB.
Il te restera (si ça convient) à déduire d'après cette valeur si l'image est plutôt claire ou plutôt foncée.
► Afficher le texte
Code : Tout sélectionner
#Include <WinApi.au3>
#include <GDIPlus.au3>
$picture = FileOpenDialog("image", @ScriptDir, "Images (*.jpg)")
If $picture = "" Then Exit
$color = _ImageAverageColor($picture)
MsgBox(0, "", $color)
Func _ImageAverageColor($sInImage)
Local $hWnd, $hDC, $hBMP, $hImage1, $hImage2, $hGraphic, $result
; 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, 1, 1)
_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)
$result = StringRegExpReplace( Hex(_GDIPlus_BitmapGetPixel($hImage2, 0, 0) ), ".*(.{6})$", "$1")
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_ImageDispose($hImage2)
_WinAPI_DeleteObject($hBMP)
_GDIPlus_Shutdown()
Return $result
EndFunc ;==>_ImageAverageColor
L'idéal serait même de trouver la couleur moyenne non pas pour l'image complète mais uniquement pour la zone concernée (là où tu veux mettre le texte). Tu pourra utiliser _GDIPlus_BitmapCloneArea pour ça.
Bon, c'est du bricolage, mais j'ai pas trouvé mieux

Le script, ça fait gagner beaucoup de temps... à condition d'en avoir beaucoup devant soi !