Zitatirgendwas geht nicht aber ich weiß nich was (sonst würd ichs ja nicht schrieben^^)
Ließt du meine Beiträge eigentlich?
Zitatirgendwas geht nicht aber ich weiß nich was (sonst würd ichs ja nicht schrieben^^)
Ließt du meine Beiträge eigentlich?
klar sonst würd ich dich ja nich fragn ich hab mir das tut von bugFix angeguckt
Zitatklar sonst würd ich dich ja nich fragn
Hast du den Beispielcode von mir übersehen? Das wäre zumindest schonmal ein Ansatz in die richtige Richtung.
ja damit siehts so aus aber geht halt auch nich:
#include <GuiConstants.au3>
#include <GdiPlus.au3>
#include <Misc.au3>
#include <Color.au3>
$file = FileOpenDialog("SnakeLvLEditor", @DesktopDir &"\Eigene Programme\Snake", "Bilder (*.jpg)")
$iniFile = StringReplace($file, ".jpg", ".ini")
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$hBmp = _GDIPlus_ImageLoadFromFile($file)
$PicWidth = _GDIPlus_ImageGetWidth($file)
$PicHeight = _GDIPlus_ImageGetWidth($file)
$hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp) ; erstelle ein Bitmap aus Screenshot zur Verwendung mit GDI+
_WinAPI_DeleteObject($hBmp) ; lösche Screenshot aus Speicher
_GreyScale($hBitmap, 0, 0, $PicWidth, $PicHeight) ; Bereich wird in Graustufen umberechnet
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_BitmapDispose($hBitmap) ; lösche Bild aus dem Speicher
_GDIPlus_Shutdown()
Func _GreyScale($hBitmap, $iX, $iY, $iW, $iH)
Local $BitmapData = _GDIPlus_BitmapLockBits($hBitmap, $iX, $iY, $iW, $iH, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32RGB)
Local $Stride = DllStructGetData($BitmapData, "Stride") ; Stride ist der Offset von einer Reihe zur nächsten
Local $Width = DllStructGetData($BitmapData, "Width") ; Anzahl der Spalten
Local $Height = DllStructGetData($BitmapData, "Height") ; Anzahl der Reihen
Local $Scan0 = DllStructGetData($BitmapData, "Scan0") ; Die Bilddaten im Speicher
Local $PixelData, $Color
For $row = 0 To $Height - 1 ; Reihe für Reihe
For $col = 0 To $Width - 1 ; Spalte für Spalte
; lese Farbinformation des aktuellen Pixels(Spalte,Reihe) aus
$PixelData = DllStructCreate("dword", $Scan0 + ($row * $Stride) + ($col * 4))
$Color = DllStructGetData($PixelData, 1)
If $Color = 0 Then
IniWrite($iniFile, "Pixel", $row, $col)
EndIf
Next
Next
_GDIPlus_BitmapUnlockBits($hBitmap, $BitmapData)
EndFunc ;==>_GreyScale
Zitatja damit siehts so aus
Nein tut es nicht.
Es sieht so aus:
#include <GuiConstants.au3>
#include <GdiPlus.au3>
#include <Misc.au3>
#include <Color.au3>
$file = FileOpenDialog("SnakeLvLEditor", @DesktopDir &"\Eigene Programme\Snake", "Bilder (*.jpg)")
$iniFile = StringReplace($file, ".jpg", ".ini")
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$hBitmap = _GDIPlus_BitmapCreateFromFile($file)
$height = _GDIPlus_ImageGetHeight($hBitmap)
$width = _GDIPlus_ImageGetWidth($hBitmap)
Local $BitmapData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $width, $height, $GDIP_ILMREAD, $GDIP_PXF32RGB)
Local $Stride = DllStructGetData($BitmapData, "Stride") ; Stride ist der Offset von einer Reihe zur nächsten
Local $Scan0 = DllStructGetData($BitmapData, "Scan0") ; Die Bilddaten im Speicher
Local $PixelData
For $row = 0 To $height - 1 ; Reihe für Reihe
For $col = 0 To $width - 1 ; Spalte für Spalte
; lese Farbinformation des aktuellen Pixels(Spalte,Reihe) aus
$PixelData = DllStructCreate("dword", $Scan0 + ($row * $Stride) + ($col * 4))
$Color = DllStructGetData($PixelData, 1)
If $Color = 0 Then
IniWrite($iniFile, "Pixel", $row, $col)
EndIf
Next
Next
_GDIPlus_BitmapUnlockBits($hBitmap, $BitmapData)
_GDIPlus_Shutdown()
MsgBox(0,"","fertig")
Wo liegt das Problem?
geht immer noch nicht es schreibt einfach jedesmal in die ini:
[Pixel]
0=0
und das wars
EDIT: Ich hab den Fehler und weiß natürlich nix damit anzufangen... Der Rückgabewert für "Weiß" ist 4294967295 also nicht einheitlich 0 oder dezimal #000 oder hexadezimal #000000
Hab den funktionerenden Code:
#include <GuiConstants.au3>
#include <GdiPlus.au3>
#include <Misc.au3>
#include <Color.au3>
$file = FileOpenDialog("Compiler", @DesktopDir &"\Eigene Programme\Snake", "Bilder (*.jpg)")
If @error = 1 Then Exit
$iniFile = StringReplace($file, ".jpg", ".ini")
ProgressOn("Compiler","Compiliere...", "0%")
_GDIPlus_Startup()
$hBitmap = _GDIPlus_BitmapCreateFromFile($file)
$height = _GDIPlus_ImageGetHeight($hBitmap)
$width = _GDIPlus_ImageGetWidth($hBitmap)
Local $BitmapData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $width, $height, $GDIP_ILMREAD, $GDIP_PXF32RGB)
Local $Stride = DllStructGetData($BitmapData, "Stride") ; Stride ist der Offset von einer Reihe zur nächsten
Local $Scan0 = DllStructGetData($BitmapData, "Scan0") ; Die Bilddaten im Speicher
Local $PixelData
For $row = 0 To $height - 1 ; Reihe für Reihe
For $col = 0 To $width - 1 ; Spalte für Spalte
$Percent = Round((100 / $height) * $row + (100 / $height) * (((100 / $width) * $col) / 100), 1)
ProgressSet($Percent, $Percent &"%")
; lese Farbinformation des aktuellen Pixels(Spalte,Reihe) aus
$PixelData = DllStructCreate("dword", $Scan0 + ($row * $Stride) + ($col * 4))
$Color = DllStructGetData($PixelData, 1)
$Color = _ColorGetRed($Color) + _ColorGetGreen($Color) + _ColorGetBlue($Color)
If $Color = 0 Then
IniWrite($iniFile, "Pixel", $row, $col)
EndIf
Next
Next
_GDIPlus_BitmapUnlockBits($hBitmap, $BitmapData)
_GDIPlus_Shutdown()
ProgressOff()
MsgBox(0,"Compiler","fertig")