@Patrik96Here a function that you could try. If images are not too too big, you should get a decent response time.
Func ClearAll($nColorPreserved, $nColorClear)
Local $iSize = $iGS_Width * $iGS_Height
$nColorPreserved = BitOR($nColorPreserved, 0xFF000000)
$nColorClear = BitOR($nColorClear, 0xFF000000)
For $i = 1 To $iSize
If DllStructGetData($tGS_Struct, "color", $i) <> $nColorPreserved Then DllStructSetData($tGS_Struct, "color", $nColorClear, $i)
Next
EndFunc