ARGB Hex Converter

« Older   Newer »
  Share  
xdmisterx
CAT_IMG Posted on 28/4/2010, 14:58     +1   -1




Come da nome, questo programmino serve per trovare il valore esadecimale di un colore:

SPOILER (click to view)
CODICE
;ARGB Hex Converter - by Misterx
#include <GuiConstants.au3>
#include <GdiPlus.au3>

Global $title = "ARGB Hex Converter - by Misterx"

$gui = GUICreate($title,460,130)

GUICtrlCreateLabel("Alpha",10,10)
$alpha = GUICtrlCreateSlider(50,8,255,20,0x0010)
GUICtrlSetLimit($alpha,255,0)
$alphan = GUICtrlCreateLabel("0",315,10,20)

GUICtrlCreateLabel("Rosso",10,40)
$rosso = GUICtrlCreateSlider(50,38,255,20,0x0010)
GUICtrlSetLimit($rosso,255,0)
$rosson = GUICtrlCreateLabel("0",315,40,20)

GUICtrlCreateLabel("Verde",10,70)
$verde = GUICtrlCreateSlider(50,68,255,20,0x0010)
GUICtrlSetLimit($verde,255,0)
$verden = GUICtrlCreateLabel("0",315,70,20)

GUICtrlCreateLabel("Blu",10,100)
$blu = GUICtrlCreateSlider(50,98,255,20,0x0010)
GUICtrlSetLimit($blu,255,0)
$blun = GUICtrlCreateLabel("0",315,100,20)

Dim $hexv[4] = [00,00,00,00]
$hex = GUICtrlCreateInput("0x00000000",350,5,100,20)

GUISetState()

_GDIPlus_Startup()
$h = _GDIPlus_GraphicsCreateFromHWND($gui)
$brush = _GDIPlus_BrushCreateSolid()
_GDIPlus_GraphicsFillRect($h,350, 35, 100, 80,$brush)

While 1
       If GUICtrlRead($alpha) <> GUICtrlRead($alphan) Then
               $at = GUICtrlRead($alpha)
               GUICtrlSetData($alphan,$at)
               $hexv[0] = Number($at)
               set()
       EndIf
       If GUICtrlRead($rosso) <> GUICtrlRead($rosson) Then
               $rt = GUICtrlRead($rosso)
               GUICtrlSetData($rosson,$rt)
               $hexv[1] = Number($rt)
               set()
       EndIf
       If GUICtrlRead($verde) <> GUICtrlRead($verden) Then
               $vt = GUICtrlRead($verde)
               GUICtrlSetData($verden,$vt)
               $hexv[2] = Number($vt)
               set()
       EndIf
       If GUICtrlRead($blu) <> GUICtrlRead($blun) Then
               $bt = GUICtrlRead($blu)
               GUICtrlSetData($blun,$bt)
               $hexv[3] = Number($bt)
               set()
       EndIf
       
       Switch GUIGetMsg()
       Case $gui_event_close
               Exit
       EndSwitch
WEnd

Func set()
       $0 = StringRight(Hex($hexv[0]),2)
       $1 = StringRight(Hex($hexv[1]),2)
       $2 = StringRight(Hex($hexv[2]),2)
       $3 = StringRight(Hex($hexv[3]),2)
       $fin = "0x" & $0 & $1 & $2 & $3
       GUICtrlSetData($hex,$fin)
       $brush = _GDIPlus_BrushCreateSolid()
       $h = _GDIPlus_GraphicsCreateFromHWND($gui)
       _GDIPlus_BrushSetSolidColor($brush,$fin)
       _GDIPlus_GraphicsFillRect($h,350, 35, 100, 80,$brush)
EndFunc


Unico problema: non riesco a capire perchè non riesco a regolare l'alpha, ovvero l'intensità del colore...così a vedere il codice mi sembra di averlo fatto giusto, vedete voi se riuscite a trovare l'inghippo xD.
ciao :)
 
Top
Gianlu-thebest
CAT_IMG Posted on 28/4/2010, 18:55     +1   -1




g00d work :)
 
Top
Dragon[ITA]
CAT_IMG Posted on 5/5/2010, 13:49     +1   -1




risolto (hai sbagliato a scrivere il nome di 1 funzione...)
CODICE
;ARGB Hex Converter - by Misterx
#include <GuiConstants.au3>
#include <GdiPlus.au3>

Global $title = "ARGB Hex Converter - by Misterx"

$gui = GUICreate($title,460,130)

GUICtrlCreateLabel("Alpha",10,10)
$alpha = GUICtrlCreateSlider(50,8,255,20,0x0010)
GUICtrlSetLimit($alpha,255,0)
$alphan = GUICtrlCreateLabel("0",315,10,20)

GUICtrlCreateLabel("Rosso",10,40)
$rosso = GUICtrlCreateSlider(50,38,255,20,0x0010)
GUICtrlSetLimit($rosso,255,0)
$rosson = GUICtrlCreateLabel("0",315,40,20)

GUICtrlCreateLabel("Verde",10,70)
$verde = GUICtrlCreateSlider(50,68,255,20,0x0010)
GUICtrlSetLimit($verde,255,0)
$verden = GUICtrlCreateLabel("0",315,70,20)

GUICtrlCreateLabel("Blu",10,100)
$blu = GUICtrlCreateSlider(50,98,255,20,0x0010)
GUICtrlSetLimit($blu,255,0)
$blun = GUICtrlCreateLabel("0",315,100,20)

Dim $hexv[4] = [00,00,00,00]
$hex = GUICtrlCreateInput("0x00000000",350,5,100,20)

GUISetState()

_GDIPlus_Startup()
$h = _GDIPlus_GraphicsCreateFromHWND($gui)
$brush = _GDIPlus_BrushCreateSolid()
_GDIPlus_GraphicsFillRect($h,350, 35, 100, 80,$brush)

While 1
      If GUICtrlRead($alpha) <> GUICtrlRead($alphan) Then
              $at = GUICtrlRead($alpha)
              GUICtrlSetData($alphan,$at)
              $hexv[0] = Number($at)
              set()
      EndIf
      If GUICtrlRead($rosso) <> GUICtrlRead($rosson) Then
              $rt = GUICtrlRead($rosso)
              GUICtrlSetData($rosson,$rt)
              $hexv[1] = Number($rt)
              set()
      EndIf
      If GUICtrlRead($verde) <> GUICtrlRead($verden) Then
              $vt = GUICtrlRead($verde)
              GUICtrlSetData($verden,$vt)
              $hexv[2] = Number($vt)
              set()
      EndIf
      If GUICtrlRead($blu) <> GUICtrlRead($blun) Then
              $bt = GUICtrlRead($blu)
              GUICtrlSetData($blun,$bt)
              $hexv[3] = Number($bt)
              set()
      EndIf
     
      Switch GUIGetMsg()
      Case $gui_event_close
              Exit
      EndSwitch
WEnd

Func set()
      $0 = StringRight(Hex($hexv[0]),2)
      $1 = StringRight(Hex($hexv[1]),2)
      $2 = StringRight(Hex($hexv[2]),2)
      $3 = StringRight(Hex($hexv[3]),2)
      $fin = "0x" & $0 & $1 & $2 & $3
      GUICtrlSetData($hex,$fin)
      $brush = _GDIPlus_BrushCreateSolid($fin)
      $h = _GDIPlus_GraphicsCreateFromHWND($gui)
      _GDIPlus_GraphicsFillRect($h,350, 35, 100, 80,$brush)
EndFunc


cmq niente male
 
Top
xdmisterx
CAT_IMG Posted on 5/5/2010, 14:05     +1   -1




veramente non era il problema della sintassi, ma di qualcos'altro a me sconosciuto xD.
Comunque cosa avevo sbagliato che non riesco a trovare la differenza?
 
Top
Dragon[ITA]
CAT_IMG Posted on 5/5/2010, 14:13     +1   -1




guarda
func set()
; ...
endfunc

_GDIPlus_BrushSetSolidColor($brush,$fin) non esiste >_<
 
Top
xdmisterx
CAT_IMG Posted on 5/5/2010, 14:18     +1   -1




Si che esiste o.0, altrimenti mi andrebbe in errore...
Che versione di autoit hai?
 
Top
Dragon[ITA]
CAT_IMG Posted on 5/5/2010, 14:25     +1   -1




bho ._. l'ultima >_<
 
Top
xdmisterx
CAT_IMG Posted on 5/5/2010, 14:29     +1   -1




Ma tu l'hai tolta perchè non ti fungeva? Io uso la 3.3.6.1
 
Top
Dragon[ITA]
CAT_IMG Posted on 5/5/2010, 14:31     +1   -1




ah ho capito non ho l'ultima versione ._. ecco cos'era quell'AdlibRegister ._. nn riuscivo a capirlo...
 
Top
xdmisterx
CAT_IMG Posted on 5/5/2010, 14:33     +1   -1




hahaha, risolto il mistero delle funzioni xD
In effetti hanno fatto un cambio molto vasto nelle ultime versioni...
 
Top
Dragon[ITA]
CAT_IMG Posted on 5/5/2010, 14:44     +1   -1




cmq ora va e ho anche aggiornato AutoIT ... asd ora ho tutti i programmi scazzati...

ORA HO CAPITO!

l'alpha non è il problema!
il problema è che se tu metti una cosa con alpha basso su un oggetto di un colore qualsiasi si continua a vedere il colore precedente

così è risolto:

CODICE
$brush = _GDIPlus_BrushCreateSolid()
      $h = _GDIPlus_GraphicsCreateFromHWND($gui)
      _GDIPlus_GraphicsFillRect($h,350, 35, 100, 80,$brush)
      _GDIPlus_BrushSetSolidColor($brush,$fin)
      _GDIPlus_GraphicsFillRect($h,350, 35, 100, 80,$brush)


Edited by Dragon[ITA] - 5/5/2010, 19:40
 
Top
10 replies since 28/4/2010, 14:58   207 views
  Share