Moin,
Das folgende Skript zeigt den XYZ Farbraum in 2 Dimensionen (x,y = 0 -> 100).
Der Slider verstellt die Z Koordinate.
Die Darstellung sieht für mich seltsam aus, irgendwas stimmt hier nicht und ich finde den Fehler nicht.
Man kann in Zeile 48 und 49 durch Auskommentieren zwischen RGB und XYZ umschalten, RGB läuft (wie üblich) Problemlos.
Skript
#include <GDIPlus.au3>
[/autoit] [autoit][/autoit] [autoit]Global Const $iSize = 5 ; Größe der Kacheln in Px
Global Const $iAnz = 125 ; Anzahl der Kacheln in x, y und z Richtung
Global $hGUI, $hSli, $iZ, $hGFX, $hBRU, $hBUF, $hBMP
[/autoit] [autoit][/autoit] [autoit]$hGUI = GUICreate('XYZ Farbraum', $iSize * $iAnz, $iSize * $iAnz + 25)
[/autoit] [autoit][/autoit] [autoit]$hSli = GUICtrlCreateSlider(0, $iAnz * $iSize, $iSize * $iAnz, 25)
GUICtrlSetLimit($hSli, 1000, 0)
_GDIPlus_Startup()
$hGFX = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBMP = _GDIPlus_BitmapCreateFromGraphics($iSize * $iAnz, $iSize * $iAnz, $hGFX)
$hBUF = _GDIPlus_ImageGetGraphicsContext($hBMP)
$hBRU = _GDIPlus_BrushCreateSolid()
GUIRegisterMsg(0xF, 'WM_PAINT')
GUISetState(@SW_SHOW)
_ApplyCol(0.9)
[/autoit] [autoit][/autoit] [autoit]While GUIGetMsg() <> -3
If GUICtrlRead($hSli) <> $iZ Then
$iZ = GUICtrlRead($hSli)
_ApplyCol($iZ/1000)
EndIf
WEnd
_GDIPlus_GraphicsDispose($hGFX)
_GDIPlus_BrushDispose($hBRU)
_GDIPlus_GraphicsDispose($hBUF)
_GDIPlus_BitmapDispose($hBMP)
_GDIPlus_Shutdown()
Func WM_PAINT()
_GDIPlus_GraphicsDrawImage($hGFX, $hBMP, 0, 0)
EndFunc
Func _ApplyCol($Z = 0)
Local $t = TimerInit()
Local $sCol, $iAnzMinus1 = $iAnz - 1, $klX, $klY
For $x = 0 To $iAnzMinus1 Step 1
For $y = 0 To $iAnzMinus1 Step 1
$klX = $x / $iAnzMinus1
$klY = $y / $iAnzMinus1
$sCol = _XYZ_to_RGB($klX, $klY, $Z)
;~ $sCol = '0xFF' & Hex(Int(Round($klX * 255, 0)),2) & Hex(Int(Round($klY * 255, 0)),2) & Hex(Int(Round($Z * 255, 0)),2)
DllCall($ghGDIPDll, 'int', 'GdipSetSolidFillColor', 'handle', $hBRU, 'dword', $sCol)
DllCall($ghGDIPDll, 'int', 'GdipFillRectangleI', 'handle', $hBUF, 'handle', $hBRU, 'int', $x * $iSize, 'int', $y * $iSize, 'int', $iSize, 'int', $iSize)
Next
If IsInt($x/3) Then WM_PAINT()
Next
WM_PAINT()
$t = TimerDiff($t)
ConsoleWrite('Dauer für ' & $iAnz^2 & ' Kacheln: ' & Round($t/1000, 2) & 's' & @TAB & ' Zeit pro Kachel: ' & Round($t /$iAnz^2, 2) & 'ms' & @CRLF)
EndFunc
; Von BugFix
Func _XYZ_to_RGB($iX, $iY, $iZ)
Local $iR, $iG, $iB
$iR = ($iX * 3.2406) + ($iY * -1.5372) + ($iZ * -0.4986)
$iG = ($iX * -0.9689) + ($iY * 1.8758) + ($iZ * 0.0415)
$iB = ($iX * 0.0557) + ($iY * -0.2040) + ($iZ * 1.0570)
If $iR > 0.0031308 Then
$iR = 1.055 * ($iR ^ (1/2.4)) - 0.055
Else
$iR *= 12.92
EndIf
If $iG > 0.0031308 Then
$iG = 1.055 * ($iG ^ (1/2.4)) - 0.055
Else
$iG *= 12.92
EndIf
If $iB > 0.0031308 Then
$iB = 1.055 * ($iB ^ (1/2.4)) - 0.055
Else
$iB *= 12.92
EndIf
Return '0xFF' & Hex(Int($iR*255), 2) & Hex(Int($iG*255), 2) & Hex(Int($iB*255), 2)
EndFunc ;==>_XYZ_to_RGB
lg
Mars