English
Source / code snippets

colour find Hpic Pixel Search

 

CompileMarkSeparationor.
CompileMarkSeparation
 $H windows.ph
STRUCT BITMAPINFOHEADER=BISIZE&,BIWIDTH&,BIHEIGHT&,BIPLANES%,BIBITCOUNT%,BICOMPRESSION&,BISIZEIMAGE&,BIXPELSPERMETER&,BIYPELSPERMETER&,BICLRUSED&,BICLRIMPORTANT&
RANDOMIZE
CLS
var HPIC&=CREATE(hNewPic,1024,1024,0)
var X&=RND(1024)
var Y&=RND(1024)
var COL&=$00FF00
STARTPAINT HPIC&
SETPIXEL X&,Y&,COL&
ENDPAINT
var SOMEPOS&=HPIC.PIXELSEARCH(HPIC&,COL&,1024,1024)
PRINT X&,Y&
PRINT HIWORD(SOMEPOS&),LOWORD(SOMEPOS&)
WAITINPUT
END

proc HPIC.BGR2STRING

    PARAMETERS H&,_WIDTH&,_HEIGHT&
    var SZ&=( (_WIDTH&*328-1) | 3 +1) * ABS(_HEIGHT&)
    DECLARE MEM#
    DIM MEM#,BITMAPINFOHEADER

    WITH MEM#

        .BISIZE&=SIZEOF(MEM#)
        .BIWIDTH&=_WIDTH&
        .BIHEIGHT&=_HEIGHT&
        .BIPLANES%=1
        .BIBITCOUNT%=32
        .BICOMPRESSION&=0
        .BISIZEIMAGE&=SZ&

    ENDWITH

    DECLARE DATA#
    DIM DATA#,SZ&
    var RET$=

    IF ~GetDIBits(%HDC,H&,0,_HEIGHT&,DATA#,MEM#,0)

        RET$=CHAR$(DATA#,0,SZ&)

    ENDIF

    DISPOSE DATA#
    DISPOSE MEM#
    RETURN +RET$

endproc

proc HPIC.PIXELSEARCH

    PARAMETERS H&,COLORTOFIND&,_WIDTH&,_HEIGHT&
    var RAWDATA$=HPIC.BGR2STRING(H&,_WIDTH&,_HEIGHT&)
    var _FND&=HPIC.FINDCOLORINRAWDATA(COLORTOFIND&,RAWDATA$)

    IF _FND&=-1

        RETURN _FND&

    ENDIF

    var X&=_FND& MOD _WIDTH&
    var Y&=0

    IF _FND& > 0

        Y&=_FND&\_WIDTH&

    ENDIF

    RETURN X&*65536+(_HEIGHT&-Y&-1)

endproc

proc HPIC.FINDCOLORINRAWDATA

    PARAMETERS COL&,DATA$
    var C&=1
    var P&=0
    var RET&=-1
    var SCOL$=CHR$(GETBVALUE(COL&))+CHR$(GETGVALUE(COL&))+CHR$(GETRVALUE(COL&))

    WHILE 1

        P&=INSTR(SCOL$,DATA$,C&)

        IFNOT P&

            BREAK

        ENDIF

        IFNOT (P&-1) MOD 4

            RET&=P&*0.25
            BREAK

        ENDIF

        C&=P&+1

    ENDWHILE

    RETURN RET&

endproc

end

426 kB
Hochgeladen:03/03/09
Downloadcounter81
Download
 
03/03/09  
 



Hello, if I The Search 3x one after another particular eingebe, functions it.
but in a While-Loop comes The Error Message : Scol$ not declariert.
CompileMarkSeparation
 $H windows.ph
STRUCT BITMAPINFOHEADER=BISIZE&,BIWIDTH&,BIHEIGHT&,BIPLANES%,BIBITCOUNT%,BICOMPRESSION&,BISIZEIMAGE&,BIXPELSPERMETER&,BIYPELSPERMETER&,BICLRUSED&,BICLRIMPORTANT&
RANDOMIZE
CLS
var HPIC&=CREATE(hNewPic,1024,1024,0)
var X&=RND(1024)
var Y&=RND(1024)
var COL&=$00FF00
STARTPAINT HPIC&
SETPIXEL X&,Y&,COL&
ENDPAINT
var SOMEPOS&=HPIC.PIXELSEARCH(HPIC&,COL&,1024,1024)
PRINT X&,Y&
PRINT HIWORD(SOMEPOS&),LOWORD(SOMEPOS&)
SOMEPOS&=HPIC.PIXELSEARCH(HPIC&,COL&,1024,1024)
PRINT X&,Y&
PRINT HIWORD(SOMEPOS&),LOWORD(SOMEPOS&)
SOMEPOS&=HPIC.PIXELSEARCH(HPIC&,COL&,1024,1024)
PRINT X&,Y&
PRINT HIWORD(SOMEPOS&),LOWORD(SOMEPOS&)

whileloop 1,10

    SOMEPOS&=HPIC.PIXELSEARCH(HPIC&,COL&,1024,1024)
    PRINT X&,Y&
    PRINT HIWORD(SOMEPOS&),LOWORD(SOMEPOS&)

endwhile

WAITINPUT
END

proc HPIC.BGR2STRING

    PARAMETERS H&,_WIDTH&,_HEIGHT&
    var SZ&=( (_WIDTH&*328-1) | 3 +1) * ABS(_HEIGHT&)
    DECLARE MEM#
    DIM MEM#,BITMAPINFOHEADER

    WITH MEM#

        .BISIZE&=SIZEOF(MEM#)
        .BIWIDTH&=_WIDTH&
        .BIHEIGHT&=_HEIGHT&
        .BIPLANES%=1
        .BIBITCOUNT%=32
        .BICOMPRESSION&=0
        .BISIZEIMAGE&=SZ&

    ENDWITH

    DECLARE DATA#
    DIM DATA#,SZ&
    var RET$=

    IF ~GetDIBits(%HDC,H&,0,_HEIGHT&,DATA#,MEM#,0)

        RET$=CHAR$(DATA#,0,SZ&)

    ENDIF

    DISPOSE DATA#
    DISPOSE MEM#
    RETURN +RET$

endproc

proc HPIC.PIXELSEARCH

    PARAMETERS H&,COLORTOFIND&,_WIDTH&,_HEIGHT&
    var RAWDATA$=HPIC.BGR2STRING(H&,_WIDTH&,_HEIGHT&)
    var _FND&=HPIC.FINDCOLORINRAWDATA(COLORTOFIND&,RAWDATA$)

    IF _FND&=-1

        RETURN _FND&

    ENDIF

    var X&=_FND& MOD _WIDTH&
    var Y&=0

    IF _FND& > 0

        Y&=_FND&\_WIDTH&

    ENDIF

    RETURN X&*65536+(_HEIGHT&-Y&-1)

endproc

proc HPIC.FINDCOLORINRAWDATA

    PARAMETERS COL&,DATA$
    var C&=1
    var P&=0
    var SCOL$=CHR$(GETBVALUE(COL&))+CHR$(GETGVALUE(COL&))+CHR$(GETRVALUE(COL&))

    WHILE 1

        P&=INSTR(SCOL$,DATA$,C&)

        IFNOT P&

            BREAK

        ENDIF

        IFNOT (P&-1) MOD 4

            RETURN P&*0.25

        ENDIF

        C&=P&+1

    ENDWHILE

    RETURN ass=s2>-1

endproc

 
03/05/09  
 



Jupp, my code has whom Error within of/ one While-Loop one Return abzusetzen.

Do I paraphrase...
 
03/05/09  
 




Christian
Schneider
updated: runs now too in creep:
CompileMarkSeparation
 $H windows.ph
STRUCT BITMAPINFOHEADER=BISIZE&,BIWIDTH&,BIHEIGHT&,BIPLANES%,BIBITCOUNT%,BICOMPRESSION&,BISIZEIMAGE&,BIXPELSPERMETER&,BIYPELSPERMETER&,BICLRUSED&,BICLRIMPORTANT&
Declare SEARCHPOSITION&,SOMEPOS&[],Rawdata$
RANDOMIZE
CLS
var HPIC&=CREATE(hNewPic,1024,1024,0)
var X&=RND(1024)
var Y&=RND(1024)
var COL&=$00FF00
STARTPAINT HPIC&
SETPIXEL 1,999,COL&
SETPIXEL 100,230,COL&
SETPIXEL 100,220,COL&
SETPIXEL 100,231,COL&
ENDPAINT

Whileloop 10

    suchfunktion(1024,1024,COL&)

    Whileloop Sizeof(Somepos&[])

        PRINT HIWORD(SOMEPOS&[&Loop-1]),LOWORD(SOMEPOS&[&loop-1])

    Endwhile

Endwhile

WAITINPUT
END

proc suchfunktion

    SEARCHPOSITION&=1
    Clear Rawdata$
    Clear Somepos&[]
    Parameters searchx&,searchy&,color&
    var durchlauf&=0
    var arraysize&=2
    Somepos&[0]=0

    Whilenot SOMEPOS&[arraysize&-2]=-709309

        SOMEPOS&[durchlauf&]=HPIC.PIXELSEARCH(HPIC&,color&,1024,1024)
        SOMEPOS&[durchlauf&+1]=0
        arraysize&=sizeof(somepos&[])
        inc durchlauf&

    Endwhile

    SetSize Somepos&[], (Sizeof(Somepos&[])-2)
    clear durchlauf&

endproc

proc HPIC.BGR2STRING

    PARAMETERS H&,_WIDTH&,_HEIGHT&
    var SZ&=( (_WIDTH&*328-1) | 3 +1) * ABS(_HEIGHT&)
    DECLARE MEM#
    DIM MEM#,BITMAPINFOHEADER

    WITH MEM#

        .BISIZE&=SIZEOF(MEM#)
        .BIWIDTH&=_WIDTH&
        .BIHEIGHT&=_HEIGHT&
        .BIPLANES%=1
        .BIBITCOUNT%=32
        .BICOMPRESSION&=0
        .BISIZEIMAGE&=SZ&

    ENDWITH

    DECLARE DATA#
    DIM DATA#,SZ&
    var RET$=

    IF ~GetDIBits(%HDC,H&,0,_HEIGHT&,DATA#,MEM#,0)

        RET$=CHAR$(DATA#,0,SZ&)

    ENDIF

    DISPOSE DATA#
    DISPOSE MEM#
    RETURN +RET$

endproc

proc HPIC.PIXELSEARCH

    PARAMETERS H&,COLORTOFIND&,_WIDTH&,_HEIGHT&

    if @len(rawdata$)<1

        RAWDATA$=HPIC.BGR2STRING(H&,_WIDTH&,_HEIGHT&)

    endif

    var _FND&=HPIC.FINDCOLORINRAWDATA(COLORTOFIND&,RAWDATA$)

    IF _FND&=-1

        RETURN _FND&

    ENDIF

    var X&=_FND& MOD _WIDTH&
    var Y&=0

    IF _FND& > 0

        Y&=_FND&\_WIDTH&

    ENDIF

    RETURN X&*65536+(_HEIGHT&-Y&-1)

endproc

proc HPIC.FINDCOLORINRAWDATA

    PARAMETERS COL&,DATA$
    var C&=SEARCHPOSITION&
    var P&=0
    var SCOL$=CHR$(GETBVALUE(COL&))+CHR$(GETGVALUE(COL&))+CHR$(GETRVALUE(COL&))
    P&=INSTR(SCOL$,DATA$,C&)
    SEARCHPOSITION&=P&+1

    IFNOT P&

        RETURN -1000000000000

    ENDIF

    IFNOT (P&-1) MOD 4

        RETURN P&*0.25

    EndIF

    C&=P&+1
    RETURN -1

endproc

 
XProfan 11| Vista(64) SP2
03/05/09  
 



The Solution Search I do not. i want dauernd a point to check on let, as long as The graphic The position changed.

mfg
 
03/05/09  
 



You can to this take action even integrally fix complex body in the graphic find let - Zeilenweise.

(pity that I now here no Programming-Environment Have)
 
03/05/09  
 



therefore goes it me Yes. therefore The Whileloop... The hopefully soon goes...

mfg
 
03/05/09  
 




Christian
Schneider
have my obiges example updated. even if You The Mehrfachsuche not need: it's running now too in creep. The 1. Fundstelle you can easily by
CompileMarkSeparation
HIWORD(SOMEPOS&[0]),LOWORD(SOMEPOS&[0])
>
read.
 
XProfan 11| Vista(64) SP2
03/05/09  
 




Christian
Schneider
has someone a idea How one on the best Toleranzen with whom Farbwerten performant install could (z.B. +/- 5 with R G B). The possible colours Generate and particular work out lasts well plenty too long.
 
XProfan 11| Vista(64) SP2
03/05/09  
 



One Pass over any Bytes lay z.B. whom ByteWert through 8 sharing.
 
03/05/09  
 



Integerzahl through 8 = 2^3
cls
declare a%
a% = 16
print a%>>3
WaitInput
end
 
03/05/09  
 



have whom Return-bow the Codes in the Ausgangsposting fixed.

@Peter: Schade the MAT not Strings functions or. Strings not nativ in byte Arrays (and back) konvertieren let.
 
03/05/09  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

7.610 Views

Untitledvor 0 min.
Sven Bader08/18/21
Normann Strübli06/09/20
Ernst04/10/14
funkheld01/12/14
More...

Themeninformationen



Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie