Mit hilfe von Wikipedia hab ich mir diesen Code zusammengereimt.
Ich bekomme aber immer "0|0" zurück egal mit welcher Farbe.
http://de.wikipedia.org/wiki/Windows_Bitmap
Code: Alles auswählen
Procedure.s FindColorInScreen(Color)
Structure Pixel
x.l
y.l
r.c
b.c
g.c
EndStructure
NewList Pixel.Pixel()
;ScreenShot
CreateImage(0,GetSystemMetrics_(#SM_CXSCREEN),GetSystemMetrics_(#SM_CYSCREEN))
HDC = StartDrawing(ImageOutput(0))
BitBlt_(HDC,0,0,ImageWidth(0),ImageHeight(0),GetDC_(GetDesktopWindow_()),0,0,#SRCCOPY )
SaveImage(0,"temp.bmp")
OpenFile(0,"temp.bmp")
FreeImage(0)
For a = 0 To 53 ;Header
ReadByte(0)
Next a
ReadByte(0) ;überflüssiges Byte o.O
;BGR!! Blue Green Red? wtf
Repeat
AddElement(Pixel())
b = ReadByte(0)
If b = 0 ;Next line?
y = y + 1
b = ReadByte(0)
ElseIf b = 1 ;EndofBitmap?
Break
EndIf
Pixel()\b = b
Pixel()\g = ReadByte(0)
Pixel()\r = ReadByte(0)
Pixel()\x = x
Pixel()\y = y
x + 1
Until Not ReadByte(0)
CloseFile(0)
DeleteFile("temp.bmp")
ForEach Pixel()
PixelColor = RGB(Pixel()\r,Pixel()\g,Pixel()\b)
If PixelColor = Color
Break
EndIf
Next
ProcedureReturn Str(Pixel()\x) + "|" + Str(Pixel()\y)
EndProcedure
Debug FindColorInScreen(RGB(255,255,223))MfG Tompazi
ps: bin mir nicht sicher ob das hier reingehört wenn nicht, bitte verschieben.
//EDIT
Einige Fehler gefunden er gibt mir zwar vernünftige Koordinaten zurück aber die stimmen eindeutig nicht.
Code: Alles auswählen
Procedure.s FindColorInScreen(Color)
Structure Pixel
x.l
y.l
r.c
b.c
g.c
EndStructure
NewList Pixel.Pixel()
;ScreenShot
CreateImage(0,GetSystemMetrics_(#SM_CXSCREEN),GetSystemMetrics_(#SM_CYSCREEN))
HDC = StartDrawing(ImageOutput(0))
BitBlt_(HDC,0,0,ImageWidth(0),ImageHeight(0),GetDC_(GetDesktopWindow_()),0,0,#SRCCOPY )
SaveImage(0,"temp.bmp")
FreeImage(0)
OpenFile(0,"temp.bmp")
For a = 0 To 16 ;Header
ReadByte(0)
Next a
Width = ReadByte(0)
Width = Width + (16 * ReadByte(0))
Width = Width + (256 * ReadByte(0))
Width = Width + (4096 * ReadByte(0))
Height = ReadByte(0)
Height = Height + (16 * ReadByte(0))
Height = Height + (256 * ReadByte(0))
Height = Height + (4096 * ReadByte(0))
Debug Width
Debug Height
y = Height
For a = 26 To 53 ;Header
ReadByte(0)
Next a
;BGR!! Blue Green Red? wtf
For ky = 0 To Height
For kx = 0 To Width
AddElement(Pixel())
Pixel()\b = b = ReadByte(0)
Pixel()\g = ReadByte(0)
Pixel()\r = ReadByte(0)
Pixel()\x = x
Pixel()\y = y
x + 1
Next kx
x = 0
y = y - 1
Next ky
CloseFile(0)
DeleteFile("temp.bmp")
ForEach Pixel()
PixelColor = RGB(Pixel()\r,Pixel()\g,Pixel()\b)
If PixelColor = Color
Break
EndIf
Next
ProcedureReturn Str(Pixel()\x) + "|" + Str(Pixel()\y)
EndProcedure
Debug FindColorInScreen(RGB(255,0,0))