forked from ganlvtech/genshin-impact-ahk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
小游戏版 按着持续按和按一下连点.ahk
3719 lines (3574 loc) · 119 KB
/
小游戏版 按着持续按和按一下连点.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
bSwitch=0
vSwitch=0
nSwitch=0
;重启
^home::
suspend permit
reload
return
^+home::
Goto findtext91
return
home:: ;暂停
suspend permit
;SetTimer, loopLbutton, Off
suspend toggle
return
;说明:
; v:连击z;
; b:按着shift;
; n:按着z
~shift::
bSwitch=0
return
#if WinActive("ahk_exe Game.exe") or WinActive("ahk_exe Game_zh-CN.exe")
;~c:: ;按一下donw再按一下z
; if WinActive("ahk_exe Game.exe")
{
KeyWait, c ,t0.5
send {down down}
sleep 15
send {down up}
sleep 250
send {z down}
sleep 15
send {z up}
}
return
~v:: ;按一下v就连按z,再按一下v取消
; if WinActive("ahk_exe Game_zh-CN.exe") or WinActive("ahk_exe Game.exe")
{
if(vSwitch==0)
{
SetTimer, loopzbutton, 100
vSwitch=1
}
else if(vSwitch==1)
{
SetTimer, loopzbutton, Off
vSwitch=0
}
}
return
; ~Lbutton::
~space::
~Rbutton::
~x::
~z::
~q::
SetTimer, loopzbutton, Off
vSwitch=0
if(nSwitch==1)
{
send {z up}
nSwitch=0
}
return
loopzbutton:
{
Random, vloopPeriod, 300, 350
SetTimer, loopzbutton, %vloopPeriod% ;引入随机数反作弊(聊胜于无
Send {z down}
Random, vAnXiaShiChang, 5, 7
Sleep %vAnXiaShiChang% ;按下时长
Send {z up}
}
return
;~v:: ;按着v就连按z,松开v取消
; if WinActive("ahk_exe Game_zh-CN.exe") or WinActive("ahk_exe Game.exe")
{
Loop
{
If Not GetKeyState("v", "P")
Break
Send {z down}
Sleep 50 ; try various milliseconds
Send {z up}
Sleep 75
}
}
Return
~b:: ;按一下b就持续按shift,再按一下b取消
; if WinActive("ahk_exe Game_zh-CN.exe") or WinActive("ahk_exe Game.exe")
{
if(bSwitch==0)
{
send {shift down}
bSwitch=1
}
else if(bSwitch==1)
{
send {shift up}
bSwitch=0
}
}
return
mbutton::
~n:: ;按一下n就持续按z,再按一下n取消
; if WinActive("ahk_exe Game_zh-CN.exe") or WinActive("ahk_exe Game.exe")
{
if(nSwitch==0)
{
send {z down}
nSwitch=1
}
else if(nSwitch==1)
{
send {z up}
nSwitch=0
}
}
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#if WinActive
Findtext91:
;/*
;===========================================
; FindText - Capture screen image into text and then find it
; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=17834
;
; Author : FeiYue
; Version : 9.1
; Date : 2023-07-30
;
; Usage: (required AHK v1.1.34+)
; 1. Capture the image to text string.
; 2. Test find the text string on full Screen.
; 3. When test is successful, you may copy the code
; and paste it into your own script.
; Note: Copy the "FindText()" function and the following
; functions and paste it into your own script Just once.
; 4. The more recommended way is to save the script as
; "FindText.ahk" and copy it to the "Lib" subdirectory
; of AHK program, instead of copying the "FindText()"
; function and the following functions, add a line to
; the beginning of your script: #Include <FindText>
; 5. If you want to call a method in the "FindTextClass" class,
; use the parameterless FindText() to get the default object
;
;===========================================
;*/
;/*
;===========================================
; FindText - 屏幕抓字生成字库工具与找字函数
; https://autohotkey.com/boards/viewtopic.php?f=6&t=17834
;
; 脚本作者 : FeiYue
; 最新版本 : 8.9
; 更新时间 : 2022-05-28
;
; 用法: (需要最新版本 AHK v1.1.31+)
; 1. 将本脚本保存为“FindText.ahk”并复制到AHK程序的Lib子目录中
; 2. 抓图并生成调用FindText()的代码
; 2.1 方式一:直接点击“抓图”按钮
; 2.2 方式二:先设定截屏热键,使用热键截屏,再点击“截屏抓图”按钮
; 3. 测试一下调用的代码是否成功:直接点击“测试”按钮
; 4. 复制调用的代码到自己的脚本中
; 4.1 方式一:直接点击“复制”按钮,然后粘贴到自己的脚本中(不推荐)
; 4.2 方式二:取消“附加FindText()函数”的选框,然后点击“复制”按钮,
; 然后粘贴到自己的脚本中,然后在自己的脚本开头加上一行:
; #Include <FindText> ; Lib目录中必须有FindText.ahk
; 5. 多色查找模式可以一定程度上适应图像的放大缩小,也可以找图
; 6. 这个库还可以用于快速截屏、获取颜色、写入颜色、编辑后另存图片
; 7. 如果要调用FindTextClass类中的函数,请用无参数的FindText()获取默认对象
;
;===========================================
;*/
;--------------------------------
; FindText - 屏幕找字函数
;--------------------------------
; 返回变量 := FindText(
; OutputX --> 保存返回的X坐标的变量名称
; , OutputY --> 保存返回的Y坐标的变量名称
; , X1 --> 查找范围的左上角X坐标
; , Y1 --> 查找范围的左上角Y坐标
; , X2 --> 查找范围的右下角X坐标
; , Y2 --> 查找范围的右下角Y坐标
; , err1 --> 文字的黑点容错百分率(0.1=10%)
; , err0 --> 背景的白点容错百分率(0.1=10%)
; , Text --> 由工具生成的查找图像的数据,可以一次查找多个,用“|”分隔
; , ScreenShot --> 是否截屏,为0则使用上一次的截屏数据
; , FindAll --> 是否搜索所有位置,为0则找到一个位置就返回
; , JoinText --> 如果想组合查找,可以为1,或者是要查找单词的数组
; , offsetX --> 组合图像的每个字和前一个字的最大横向间隔
; , offsetY --> 组合图像的每个字和前一个字的最大高低间隔
; , dir --> 查找的方向,有上、下、左、右、中心9种
; , zoomW --> 图像宽度的缩放百分率(1.0=100%)
; , zoomH --> 图像高度的缩放百分率(1.0=100%)
; )
;
; 返回变量 --> 如果没找到结果会返回0。否则返回一个二级数组,
; 第一级是每个结果对象,第二级是结果对象的具体信息数组:
; { 1:左上角X, 2:左上角Y, 3:图像宽度W, 4:图像高度H
; , x:中心点X, y:中心点Y, id:图像识别文本 }
; 坐标都是相对于屏幕,颜色使用RGB格式
;
; 如果 OutputX 等于 "wait" 或 "wait1" 意味着等待图像出现,
; 如果 OutputX 等于 "wait0" 意味着等待图像消失
; 此时 OutputY 设置等待时间的秒数,如果小于0则无限等待
; 如果超时则返回0,意味着失败,如果等待图像出现成功,则返回位置数组
; 如果等待图像消失成功,则返回 1
; 例1: FindText(X:="wait", Y:=3, 0,0,0,0,0,0,Text) ; 等待3秒等图像出现
; 例2: FindText(X:="wait0", Y:=-1, 0,0,0,0,0,0,Text) ; 无限等待等图像消失
;--------------------------------
if (!A_IsCompiled && A_LineFile=A_ScriptFullPath)
FindText().Gui("Show")
;===== Copy The Following Functions To Your Own Code Just once =====
FindText(ByRef x:="FindTextClass", ByRef y:="", args*)
{
static obj:=new FindTextClass()
return (x=="FindTextClass" && !args.Length()) ? obj : obj.FindText(x, y, args*)
}
Class FindTextClass
{ ;// Class Begin
__New()
{
this.bits:={ Scan0: 0, hBM: 0, oldzw: 0, oldzh: 0 }
this.bind:={ id: 0, mode: 0, oldStyle: 0 }
this.Lib:=[]
this.Cursor:=0
}
__Delete()
{
if (this.bits.hBM)
DllCall("DeleteObject", "Ptr",this.bits.hBM)
}
help()
{
return "
(
;--------------------------------
; FindText - Capture screen image into text and then find it
; Version : 9.1 (2023-07-30)
;--------------------------------
; returnArray:=FindText(
; OutputX --> The name of the variable used to store the returned X coordinate
; , OutputY --> The name of the variable used to store the returned Y coordinate
; , X1 --> the search scope's upper left corner X coordinates
; , Y1 --> the search scope's upper left corner Y coordinates
; , X2 --> the search scope's lower right corner X coordinates
; , Y2 --> the search scope's lower right corner Y coordinates
; , err1 --> Fault tolerance percentage of text (0.1=10%)
; , err0 --> Fault tolerance percentage of background (0.1=10%)
; , Text --> can be a lot of text parsed into images, separated by '|'
; , ScreenShot --> if the value is 0, the last screenshot will be used
; , FindAll --> if the value is 0, Just find one result and return
; , JoinText --> if you want to combine find, it can be 1, or an array of words to find
; , offsetX --> Set the max text offset (X) for combination lookup
; , offsetY --> Set the max text offset (Y) for combination lookup
; , dir --> Nine directions for searching: up, down, left, right and center
; , zoomW --> Zoom percentage of image width (1.0=100%)
; , zoomH --> Zoom percentage of image height (1.0=100%)
; )
;
; The function returns an Array containing all lookup results,
; any result is a object with the following values:
; {1:X, 2:Y, 3:W, 4:H, x:X+W//2, y:Y+H//2, id:Comment}
; If no image is found, the function returns 0.
; All coordinates are relative to Screen, colors are in RGB format
;
; If the return variable is set to 'ok', ok[1] is the first result found.
; ok[1].1, ok[1].2 is the X, Y coordinate of the upper left corner of the found image,
; ok[1].3 is the width of the found image, and ok[1].4 is the height of the found image,
; ok[1].x <==> ok[1].1+ok[1].3//2 ( is the Center X coordinate of the found image ),
; ok[1].y <==> ok[1].2+ok[1].4//2 ( is the Center Y coordinate of the found image ),
; ok[1].id is the comment text, which is included in the <> of its parameter.
;
; If OutputX is equal to 'wait' or 'wait1'(appear), or 'wait0'(disappear)
; it means using a loop to wait for the image to appear or disappear.
; the OutputY is the wait time in seconds, time less than 0 means infinite waiting
; Timeout means failure, return 0, and return other values means success
; If you want to appear and the image is found, return the found array object
; If you want to disappear and the image cannot be found, return 1
; Example 1: FindText(X:='wait', Y:=3, 0,0,0,0,0,0,Text) ; Wait 3 seconds for appear
; Example 2: FindText(X:='wait0', Y:=-1, 0,0,0,0,0,0,Text) ; Wait indefinitely for disappear
;--------------------------------
)"
}
FindText(ByRef OutputX:="", ByRef OutputY:=""
, x1:=0, y1:=0, x2:=0, y2:=0, err1:=0, err0:=0, text:=""
, ScreenShot:=1, FindAll:=1, JoinText:=0, offsetX:=20, offsetY:=10
, dir:=1, zoomW:=1, zoomH:=1)
{
local
if (OutputX ~= "i)^\s*wait[10]?\s*$")
{
found:=!InStr(OutputX,"0"), time:=Round(OutputY,3)
, timeout:=A_TickCount+Round(time*1000)
Loop
{
; Wait for the image to remain stable
While (ok:=this.FindText(,, x1, y1, x2, y2
, err1, err0, text, ScreenShot, FindAll
, JoinText, offsetX, offsetY, dir, zoomW, zoomH))
&& (found)
{
x:=ok[1].1, y:=ok[1].2, w:=ok[1].3, h:=ok[1].4
Sleep 10
if this.FindText(,, x, y, x+w-1, y+h-1
, err1, err0, text, ScreenShot, FindAll
, JoinText, offsetX, offsetY, dir, zoomW, zoomH)
{
OutputX:=ok[1].x, OutputY:=ok[1].y, this.ok:=ok
return ok
}
}
if (!found && !ok)
return 1
if (time>=0 && A_TickCount>=timeout)
Break
Sleep 50
}
return 0
}
SetBatchLines, % (bch:=A_BatchLines)?"-1":"-1"
x1:=Floor(x1), y1:=Floor(y1), x2:=Floor(x2), y2:=Floor(y2)
if (x1=0 && y1=0 && x2=0 && y2=0)
n:=150000, x:=y:=-n, w:=h:=2*n
else
x:=Min(x1,x2), y:=Min(y1,y2), w:=Abs(x2-x1)+1, h:=Abs(y2-y1)+1
bits:=this.GetBitsFromScreen(x,y,w,h,ScreenShot,zx,zy)
, x-=zx, y-=zy, info:=[], this.ok:=0
Loop Parse, text, |
if IsObject(j:=this.PicInfo(A_LoopField))
info.Push(j)
if (w<1 || h<1 || !(num:=info.Length()) || !bits.Scan0)
{
SetBatchLines, %bch%
return 0
}
arr:=[], info2:=[], k:=0, s:=""
, mode:=(IsObject(JoinText) ? 2 : JoinText ? 1 : 0)
For i,j in info
{
k:=Max(k, j[2]*j[3]), v:=(mode=1 ? i : j[10]) . ""
if (mode && v!="")
s.="|" v, (!info2.HasKey(v) && info2[v]:=[]), info2[v].Push(j)
}
sx:=x, sy:=y, sw:=w, sh:=h
, JoinText:=(mode=1 ? [s] : JoinText)
, VarSetCapacity(s1, k*4), VarSetCapacity(s0, k*4)
, VarSetCapacity(ss, sw*(sh+2))
, FindAll:=(dir=9 ? 1 : FindAll)
, allpos_max:=(FindAll || JoinText ? 10240 : 1)
, ini:={ sx:sx, sy:sy, sw:sw, sh:sh, zx:zx, zy:zy
, mode:mode, bits:bits, ss:&ss, s1:&s1, s0:&s0
, err1:err1, err0:err0, allpos_max:allpos_max
, zoomW:zoomW, zoomH:zoomH }
Loop 2
{
if (err1=0 && err0=0) && (num>1 || A_Index>1)
ini.err1:=err1:=0.05, ini.err0:=err0:=0.05
if (!JoinText)
{
VarSetCapacity(allpos, allpos_max*4), allpos_ptr:=&allpos
For i,j in info
Loop % this.PicFind(ini, j, dir, sx, sy, sw, sh, allpos_ptr)
{
pos:=NumGet(allpos, 4*A_Index-4, "uint")
, x:=Mod(pos,sw)+sx+zx, y:=pos//sw+sy+zy
, w:=Floor(j[2]*zoomW), h:=Floor(j[3]*zoomH), comment:=j[10]
, arr.Push({1:x, 2:y, 3:w, 4:h, x:x+w//2, y:y+h//2, id:comment})
if (!FindAll)
Break 3
}
}
else
For k,v in JoinText
{
v:=RegExReplace(v, "\s*\|[|\s]*", "|")
, v:=StrSplit(Trim(v,"|"), (InStr(v,"|")?"|":""), " `t")
if (v.Length()<1)
Continue
this.JoinText(ini, arr, info2, v, offsetX, offsetY, FindAll
, 1, v.Length(), dir, 0, 0, sx, sy, sw, sh)
if (!FindAll && arr.Length())
Break 2
}
if (err1!=0 || err0!=0 || arr.Length() || info[1][4] || info[1][7]=5)
Break
}
if (dir=9 && arr.Length())
arr:=this.Sort2(arr, (x1+x2)//2, (y1+y2)//2)
SetBatchLines, %bch%
if (arr.Length())
{
OutputX:=arr[1].x, OutputY:=arr[1].y, this.ok:=arr
return arr
}
return 0
}
; the join text object <==> [ "abc", "xyz", "a1|a2|a3" ]
JoinText(ini, arr, info2, text, offsetX, offsetY, FindAll
, index, Len, dir, minY, maxY, sx, sy, sw, sh)
{
local
VarSetCapacity(allpos, ini.allpos_max*4), allpos_ptr:=&allpos
, zoomW:=ini.zoomW, zoomH:=ini.zoomH
For i,j in info2[text[index]]
if (ini.mode=1 || text[index]==j[10])
Loop % this.PicFind(ini, j, dir, sx, sy, sw1:=(index=1 ? sw
: Min(sx+offsetX+Floor(j[2]*zoomW),ini.sx+ini.sw)-sx), sh, allpos_ptr)
{
pos:=NumGet(allpos, 4*A_Index-4, "uint")
, x:=Mod(pos,sw1)+sx, y:=pos//sw1+sy
, w:=Floor(j[2]*zoomW), h:=Floor(j[3]*zoomH)
, (index=1) && (ini.x:=x, minY:=y, maxY:=y+h)
if (index<Len)
{
minY1:=Min(y, minY), maxY1:=Max(y+h, maxY)
, sy1:=Max(minY1-offsetY, ini.sy)
, sh1:=Min(maxY1+offsetY, ini.sy+ini.sh)-sy1
if this.JoinText(ini, arr, info2, text, offsetX, offsetY, FindAll
, index+1, Len, 5, minY1, maxY1, x+w, sy1, 0, sh1)
&& (index>1 || !FindAll)
return 1
}
else
{
comment:=""
For k,v in text
comment.=(ini.mode=1 ? info2[v][1][10] : v)
w:=x+w-ini.x, x:=ini.x+ini.zx
, h:=Max(y+h,maxY)-Min(y,minY), y:=Min(y,minY)+ini.zy
, arr.Push({1:x, 2:y, 3:w, 4:h, x:x+w//2, y:y+h//2, id:comment})
if (index>1 || !FindAll)
return 1
}
}
}
PicFind(ini, j, dir, sx, sy, sw, sh, allpos_ptr)
{
local
static MyFunc:=""
if (!MyFunc)
{
x32:=""
. "5557565383EC7483BC2488000000058BBC24C00000000F84DA0900008B8424C4"
. "00000085C00F8EBE0F0000C744240800000000C74424100000000031EDC70424"
. "00000000C7442414000000008D7426008B8424BC0000008B4C241431F631DB01"
. "C885FF8944240C7F3DE98F00000066900FAF8424A800000089C189F099F7FF01"
. "C18B44240C803C1831744D8B8424B800000083C30103B424D8000000890CA883"
. "C50139DF74538B44240899F7BC24C400000083BC24880000000375B40FAF8424"
. "9C00000089C189F099F7FF8D0C818B44240C803C183175B38B04248B9424B400"
. "000083C30103B424D8000000890C8283C00139DF89042475AD017C2414834424"
. "10018B9C24DC0000008B442410015C2408398424C40000000F8532FFFFFF8B04"
. "24BBAD8BDB68896C24080FAF8424C800000089C1F7EB89C88B4C24080FAF8C24"
. "CC000000C1F81F89C589D6C1FE0C29EE8974244889C8C1F91FF7EBC1FA0C29CA"
. "8954245083BC2488000000030F84770A00008B84249C0000008BB424A0000000"
. "0FAF8424A40000008BBC24880000008D2CB08B8424A80000008BB4249C000000"
. "F7D885FF8D04868944241C0F856D0300008B84248C0000008BB424AC000000C7"
. "44241800000000C7442420000000008B7C2404C1E8100FB6C08944240C8B8424"
. "8C0000000FB6C4894424100FB684248C000000894424148B8424A8000000C1E0"
. "0285F68944242889E80F8EBA0000008B9C24A800000085DB0F8E8D0000008BB4"
. "24980000008B6C242003AC24B000000001C60344242889442424038424980000"
. "00894424040FB67E028B4C240C0FB646010FB6162B4424102B54241489FB01CF"
. "29CB8D8F000400000FAFC00FAFCBC1E00B0FAFCB01C1B8FE05000029F80FAFC2"
. "0FAFD001CA399424900000000F93450083C60483C5013B74240475A98B9C24A8"
. "000000015C24208B44242483442418010344241C8B74241839B424AC0000000F"
. "854AFFFFFF897C24048B34248B5C2448B80000000039DE89C30F4FDE8B742450"
. "39742408891C240F8EDC0800008B34248B44240839C60F4DC6894424648B8424"
. "8800000083E80383E0FD0F84AF0600008B8424A80000002B8424D8000000C784"
. "24A400000000000000C78424A0000000000000008944245C8B8424AC0000002B"
. "8424DC0000008944243C8B84249400000083E80183F8070F87100600008BB424"
. "A000000083F80389442444897424588BB424A4000000897424680F8EF5050000"
. "8B74245C397424580F8F7F0C00008B44245C8B3424C744242C00000000894424"
. "608B8424B40000008D04B08B7424448944245489F083E0018944244C89F08BB4"
. "249800000083E0038944246C8B4424688B5C243C39D80F8F1C010000837C246C"
. "018B7C24580F4F7C2460895C243089442420897C24408B7C24648DB600000000"
. "8B4C244C8B44243085C90F44442420837C244403894424240F8F7702000083BC"
. "2488000000058B442440894424288B4424280F847F02000083BC248800000003"
. "0F84BA0300000FAF8424A80000000344242485FF89C2894424180F8464030000"
. "8B6C24508B5C244831C0039424B00000008B0C2489742414896C2410895C240C"
. "8B6C2408EB158D76008DBC270000000083C00139C70F842503000039C873188B"
. "9C24B40000008B348301D6803E007507836C240C01781C39C576D58B9C24B800"
. "00008B348301D6803E0175C4836C24100179BD8B74241489F68DBC2700000000"
. "8344242001836C2430018B4424203944243C0F8D08FFFFFF8344245801836C24"
. "60018B4424583944245C0F8DBCFEFFFF8B44242C83C4745B5E5F5DC2580083BC"
. "2488000000010F84E409000083BC2488000000020F84AD0700008B84248C0000"
. "000FB6BC248C000000C744241800000000C744242800000000C1E8100FB6D08B"
. "84248C0000008954240C0FB69424900000000FB6DC8B842490000000C1E8100F"
. "B6C88B8424900000000FB6F48B44240C29C8034C240C8944242C89D829F001DE"
. "8944241089D089FA29C201F889742414894424248BB424AC0000008B8424A800"
. "0000894C240C89E9895424208B6C242CC1E00285F6894424300F8EEAFCFFFF8B"
. "9C24A800000085DB0F8E880000008B8424980000008B542428039424B0000000"
. "01C8034C243089CF894C242C03BC2498000000EB34395C240C7C3D394C24107F"
. "37394C24147C3189F30FB6F3397424200F9EC3397424240F9DC183C00483C201"
. "21D9884AFF39F8741E0FB658020FB648010FB63039DD7EBD31C983C00483C201"
. "884AFF39F875E28BB424A8000000017424288B4C242C8344241801034C241C8B"
. "442418398424AC0000000F854FFFFFFFE934FCFFFF8B44242483BC2488000000"
. "05894424288B442440894424248B4424280F8581FDFFFF0FAF84249C0000008B"
. "5C242485FF8D0498894424100F848B0000008B6C244831C9897C240C8D742600"
. "8B8424B40000008B5C2410031C888B8424B80000008B3C880FB6441E0289FAC1"
. "EA100FB6D229D00FB6541E010FB61C1E0FAFC03B4424047F2789F80FB6C429C2"
. "0FAFD23B5424047F1789F80FB6C029C30FAFDB3B5C24047E108DB42600000000"
. "83ED010F880702000083C101394C240C758E89BC248C0000008B7C240C8B8424"
. "D00000008344242C018B5C242C85C00F846BFDFFFF8B5424282B9424A4000000"
. "0FAF9424A80000008B4424242B8424A00000008B8C24D000000001D03B9C24D4"
. "000000894499FC0F8C33FDFFFF8B44242C83C4745B5E5F5DC25800908D742600"
. "8B7424148B142485D274928B9C24B00000008B4C24188B8424B400000001D98B"
. "5C24548B1083C00401CA39D8C6020075F2E967FFFFFF8D76008DBC2700000000"
. "0FAF84249C0000008B5C24248D0498894424100384248C00000085FF0FB65C06"
. "02895C24140FB65C06010FB60406895C24188944241C0F8421FFFFFF8B442450"
. "31DB897C240C894424388B442448894424348B4424048D76008DBC2700000000"
. "3B1C2473658B8424B40000008B4C24108B7C2414030C980FB6440E020FB6540E"
. "010FB60C0E2B5424182B4C241C89C501F829FD8DB8000400000FAFD20FAFFDC1"
. "E20B0FAFFDBDFE05000029C50FAFE901FA0FAFCD01D13B8C2490000000760B83"
. "6C2434010F8896000000395C240876618B8424B80000008B4C24108B7C241403"
. "0C980FB6440E020FB6540E010FB60C0E2B5424182B4C241C89C501F829FD8DB8"
. "000400000FAFD20FAFFDC1E20B0FAFFDBDFE05000029C50FAFE901FA0FAFCD01"
. "D13B8C24900000007707836C243801782F83C301395C240C0F8522FFFFFF8944"
. "24048B7C240CE912FEFFFF908D74260089BC248C0000008B7C240CE980FBFFFF"
. "894424048B7C240CE973FBFFFFC7442444000000008B44243C8B74245C894424"
. "5C8B8424A40000008974243C894424588B8424A000000089442468E9E0F9FFFF"
. "C744246400000000C744245000000000C744240800000000C70424000000008B"
. "8424A8000000038424A00000002B8424D80000008944245C8B8424A400000003"
. "8424AC0000002B8424DC0000008944243CE954F9FFFF8B84248C0000000FAFC0"
. "894424048B84249000000085C00F841C0200008B842490000000C1E8100FB6C0"
. "894424188B8424900000000FB6C4894424200FB684249000000081AC24900000"
. "0000000001894424288B8424C400000085C00F8EC20500008D04BD0000000031"
. "F689BC24C0000000C744241400000000C744241C0000000089F78944242C31C0"
. "8B9424C000000085D20F8EE20000008BAC24BC000000C704240000000001C503"
. "44242C89442424038424BC000000894424100FB645000FB64D020FB65D0189C6"
. "894424088B84249000000085C0743189C82B4424188B5424040FAFC039C27C20"
. "89D82B4424200FAFC039C27C1389F02B4424280FAFC039C27D5C8DB600000000"
. "8B442414C1E1108D34BD0000000099F7BC24C40000000FAF84249C0000008944"
. "240C8B042499F7BC24C00000008B54240C8D04828B9424B40000008904BA89D8"
. "83C701C1E00809C10B4C24088B8424B8000000890C3083C5048BB424D8000000"
. "0134243B6C24100F8545FFFFFF8B4424248344241C018B8C24DC0000008B7424"
. "1C014C241439B424C40000000F85EEFEFFFF893C248B34248B8C24C8000000BA"
. "AD8BDB680FAFCE89C8C1F91FF7EAC1FA0C89D029C839C6894424480F8EDFFDFF"
. "FFC7442450000000008B3424B800000000C74424080000000089C385F60F49DE"
. "895C2464E914F7FFFF8B84248C000000C1E8100FAF8424DC00000099F7BC24C4"
. "0000000FAF84249C00000089C10FB784248C0000000FAF8424D800000099F7FF"
. "8D04818984248C000000E99AF6FFFF8BAC24BC00000031DB31F6C70424000000"
. "00EB19B80A0000006BF60AF7E331DB01F289DE89CB01C311D683C5010FB64500"
. "85C00F842DFFFFFF8D48D083F90976D383F82F75E48B04248D14850000000089"
. "54240889DA0FACF2100FB7C20FAF8424DC00000099F7BC24C40000008B94249C"
. "0000000FAFD00FB7C331DB0FAF8424D800000089D199F7FF8B9424B40000008D"
. "04818B0C2489048A89C88B54240883C00189042489F08BB424B8000000890416"
. "31F6E972FFFFFF8BB424A80000008B8424B0000000C744240C00000000C74424"
. "10000000008D04708944242489F0C1E002894424148B8424AC00000085C00F8E"
. "A5F5FFFF8B8424A800000085C07E598B8C24980000008B5C24248BBC24980000"
. "00035C241001E9036C241401EF8D76000FB651020FB6410183C1040FB671FC83"
. "C3016BC04B6BD22601C289F0C1E00429F001D0C1F8078843FF39CF75D38BB424"
. "A8000000017424108344240C01036C241C8B44240C398424AC00000075868B84"
. "24A8000000C74424140000000031FF83E8018944241C8B8424AC00000083E801"
. "894424208B8424A800000085C00F8E220100008B6C241489FB8B4424248BB424"
. "A80000008D4F0185ED8BAC24B00000008D14380F944424182B9C24A800000001"
. "FE01C601EF897C241001C331C0895C240C85C00F84B4000000807C2418000F85"
. "A90000003944241C0F849F0000008B7C2414397C24200F84910000000FB63A0F"
. "B66AFF03BC248C00000089BC249000000039AC2490000000BF0100000072600F"
. "B66A0139AC249000000072538B5C240C0FB62B39AC249000000072430FB62E39"
. "AC249000000072370FB66BFF39AC2490000000722A0FB66B0139AC2490000000"
. "721D0FB66EFF39AC249000000072100FB67E0139BC24900000000F92C389DF8B"
. "6C241089FB89CF885C0500EB0A8B5C241089CFC604030283C00183C10183C201"
. "83C6018344240C01398424A80000000F851CFFFFFF83442414018B4424143984"
. "24AC0000000F85B9FEFFFFE9B9F3FFFF8B84248C0000008B8C24AC000000C744"
. "240C00000000C74424100000000083C001C1E0078984248C0000008B8424A800"
. "0000C1E00285C98944241489E88BAC248C0000000F8E6FF3FFFF8B9424A80000"
. "0085D27E658B8C24980000008B5C2410039C24B000000001C103442414894424"
. "180384249800000089C78DB6000000000FB651020FB641010FB6316BC04B6BD2"
. "2601C289F0C1E00429F001D039C50F970383C10483C30139F975D58B9C24A800"
. "0000015C24108B4424188344240C010344241C8B74240C39B424AC0000000F85"
. "76FFFFFFE9E0F2FFFFC744245000000000C744244800000000C7442408000000"
. "00C7042400000000E957F1FFFFC744242C00000000E9F6F4FFFFC74424480000"
. "0000C7042400000000C744245000000000E993FBFFFF90909090909090909090"
x64:=""
. "4157415641554154555756534881EC88000000488BBC24F00000004C8BA42420"
. "01000083F905898C24D000000089542468448944240C44898C24E80000004C8B"
. "AC2428010000488B9C24300100004C8B942438010000448BBC24400100000F84"
. "DA090000448B8424480100004585C00F8EB60F000044897424144889BC24F000"
. "00004531DB4C89AC24280100008BBC244801000031F6448BAC24D0000000448B"
. "B4247001000031EDC7442410000000004531C04C89A424200100000F1F440000"
. "4531C94585FF478D24077F36EB7C66900FAF84241001000089C14489C89941F7"
. "FF01C143803C0231418D4001743F4863D64501F183C6014439E0890C934189C0"
. "74484489D899F7FF4183FD0375C20FAF8424F800000089C14489C89941F7FF43"
. "803C02318D0C81418D400175C14C8B8424280100004863D54501F183C5014439"
. "E041890C904189C075B8834424100144039C24780100008B44241039C70F855D"
. "FFFFFF8B8C245001000041B8AD8BDB68448B742414488BBC24F00000004C8BA4"
. "24200100004C8BAC24280100000FAFCD89C8C1F91F4189CA8B8C245801000041"
. "F7E80FAFCEC1FA0C4189D14529D189C8C1F91F44894C243C41F7E8C1FA0C29CA"
. "8954244483BC24D0000000030F84320A00008B8424F80000008B8C2400010000"
. "0FAF8424080100008D04888B8C24F8000000894424108B842410010000F7D88D"
. "0481894424188B8424D000000085C00F856C0300008B4C24684889C84189CB0F"
. "B6C441C1EB1089C20FB6C1450FB6DB89C18B84241801000085C00F8EFB000000"
. "8B842410010000448B7C240C4531D2896C24204C89AC242801000089D5C74424"
. "1400000000897424244189CDC1E00248899C24300100008944241C8BB4241001"
. "00008B842410010000448B4C24104401D685C07E70418D41024489CA4489D10F"
. "B61417440FB63407418D41010FB6040789D34589F04501DE4429EB418D960004"
. "00004529D829E8410FAFD00FAFC0410FAFD0C1E00B8D0402BAFE0500004429F2"
. "0FAFD30FAFD301D04139C7410F93040C4183C2014183C1044139F275988B5C24"
. "1C015C241083442414018B7424188B44241401742410398424180100000F8558"
. "FFFFFF8B6C24208B7424244C8BAC2428010000488B9C24300100003B6C243CB8"
. "000000000F4EE83B7424440F8E9F08000039F54189F3440F4DDD8B8424D00000"
. "0083E80383E0FD0F849A0600008B8424100100002B842470010000C784240801"
. "000000000000C784240001000000000000894424708B8424180100002B842478"
. "010000894424308B8424E800000083E80183F8070F870B0600008B8C24000100"
. "0083F80389442438894C246C8B8C2408010000894C24780F8EF00500008B4C24"
. "70394C246C0F8F590C00008B4424708B4C24384C89A424200100004C89AC2428"
. "0100004589DC4C8B9C2420010000C744242000000000894424748D45FF498D44"
. "85044189ED89F5488BB42428010000488944244889C883E0018944244089C883"
. "E0038944247C8B4424788B4C243039C80F8FFB000000837C247C018B54246C0F"
. "4F54247448899C24300100004889F3488BB42430010000894C24248944241489"
. "5424348B44244085C08B4424240F44442414837C243803894424180F8F6F0200"
. "0083BC24D0000000058B4424348944241C0F847702000083BC24D0000000030F"
. "847B0300008B4C241C0FAF8C2410010000034C24184585E40F8437030000448B"
. "542444448B4C243C31C0EB110F1F40004883C0014139C40F86180300004439E8"
. "89C273144189C84403048343803C030075064183E901781839D576D489CA0314"
. "8641803C130175C84183EA0179C266908344241401836C2424018B4424143944"
. "24300F8D3BFFFFFF4889F04889DE4889C38344246C01836C2474018B44246C39"
. "4424700F8DDDFEFFFF8B4424204881C4880000005B5E5F5D415C415D415E415F"
. "C383BC24D0000000010F84D709000083BC24D0000000020F84D70600008B5424"
. "68448B4C240C89D0440FB6DA450FB6C1C1E810440FB6D04889D00FB6CC4489C8"
. "4589D7C1E8100FB6D04C89C84189C90FB6C44129D74401D289C14489C84189D2"
. "29C831D24401C9894424244489C04589D84129C04401D84531C9448944241489"
. "44241C448B8424180100008B842410010000C1E0024585C0894424200F8E19FD"
. "FFFF896C242C4C89AC24280100008B6C2424448B6C2410448974242889742430"
. "4189CE48899C24300100004489D64489CB448B9C24100100008B8C2410010000"
. "4489E84101D385C97F38EB6D0F1F40004439CE7C4E4439C57F494539C67C4444"
. "39542414410F9EC1443954241C410F9DC083C20183C0044521C84139D3448801"
. "74328D4802440FB60C0F8D4801440FB6040F89C1440FB6140F89D14C01E14539"
. "CF7EAD83C2014531C083C0044139D344880175CE44036C242083C30144036C24"
. "18399C24180100000F8563FFFFFF448B7424288B6C242C8B7424304C8BAC2428"
. "010000488B9C2430010000E92BFCFFFF8B44241883BC24D0000000058944241C"
. "8B442434894424180F8589FDFFFF8B44241C8B4C24180FAF8424F80000004585"
. "E4448D14887473448B4C243C4531C04989DF4489D243031487428B1C8689D98D"
. "4202C1E9100FB6C90FB6040729C88D4A010FB614170FAFC00FB60C0F4439F07F"
. "1F0FB6C729C10FAFC94439F17F120FB6C329C20FAFD24439F27E0F0F1F440000"
. "4183E9010F88FB0100004983C0014539C4779F895C24684C89FB834424200148"
. "83BC246001000000448B5424200F845DFDFFFF8B54241C2B9424080100004963"
. "C20FAF9424100100008B4C24182B8C240001000001CA443B942468010000488B"
. "8C2460010000895481FC0F8C20FDFFFFE954FDFFFF4585ED74A04C8B44244848"
. "89D889CA03104883C0044C39C041C604130075EEEB84662E0F1F840000000000"
. "8B44241C8B4C24180FAF8424F80000008D04884189C7034424684585E48D5002"
. "0FB60C178D50010FB604070FB61417895424100F8441FFFFFF8B5424444989D9"
. "4C895C245048895C24584989F24531C04589FB89C348897424608954242C8B54"
. "243C89542428662E0F1F8400000000004539E873634489DA4103118D4202440F"
. "B634078D42010FB614170FB604072B4424104589F74101CE29DA418DB6000400"
. "004129CF410FAFF70FAFC0410FAFF741BFFE050000C1E00B4529F7440FAFFA01"
. "F0410FAFD701C23B54240C760B836C2428010F88990000004439C5765F4489DA"
. "4103128D4202440FB634078D42010FB614170FB604072B4424104589F74101CE"
. "29DA418DB6000400004129CF410FAFF70FAFC0410FAFF741BFFE050000C1E00B"
. "4529F7440FAFFA01F0410FAFD701C23B54240C7707836C242C0178354183C001"
. "4983C2044983C1044539C40F851FFFFFFF4C8B5C2450488B5C2458488B742460"
. "E915FEFFFF895C24684C89FBE97FFBFFFF4C8B5C2450488B5C2458488B742460"
. "E96BFBFFFFC7442438000000008B4424308B4C2470894424708B842408010000"
. "894C24308944246C8B84240001000089442478E9E5F9FFFF4531DBC744244400"
. "00000031F631ED8B842410010000038424000100002B84247001000089442470"
. "8B842408010000038424180100002B84247801000089442430E969F9FFFF8B44"
. "24688B4C240C4189C6440FAFF085C90F84F00100008B74240C8B942448010000"
. "89F0C1E8100FB6C0894424184889F00FB6C48944242089F0400FB6F62D000000"
. "0185D2897424288944240C0F8EC0050000428D04BD00000000C7442410000000"
. "00C744241C0000000031EDC74424240000000044897424148944242C4889BC24"
. "F00000004C89A4242001000031F64531E44585FF448B5C24240F8EAC00000090"
. "418D4302450FB60402418D4301410FB60C024489D8450FB60C028B44240C85C0"
. "742E4489C02B4424188B7C24140FAFC039C77C1C89C82B4424200FAFC039C77C"
. "0F4489C82B4424280FAFC039C77D3C908B44241041C1E010C1E1084409C14C63"
. "F583C5014409C999F7BC24480100000FAF8424F800000089C789F09941F7FF8D"
. "0487438944B50042890CB34183C4014183C30403B424700100004539E70F855D"
. "FFFFFF8B7C242C017C24248344241C018BB424780100008B44241C0174241039"
. "8424480100000F8520FFFFFF448B742414488BBC24F00000004C8BA424200100"
. "008B8C2450010000BAAD8BDB680FAFCD89C8C1F91FF7EAC1FA0C29CA39D58954"
. "243C0F8E10FEFFFFC74424440000000085EDB8000000000F49C531F64189C3E9"
. "56F7FFFF448B5424684489D0C1E8100FAF84247801000099F7BC24480100000F"
. "AF8424F800000089C1410FB7C20FAF8424700100009941F7FF8D048189442468"
. "E9F6F6FFFF4531DB31ED31C08D4801410FB6040285C00F8465FFFFFF8D50D083"
. "FA090F879F0200004B8D049B4C8D1C4289C8EBD88B842410010000448B942418"
. "0100004531C0C74424140000000001C048984D8D1C048B842410010000C1E002"
. "4585D28944241C0F8E8EF6FFFF448BBC2410010000448B8C24100100008B4C24"
. "104501C74585C97E510F1F80000000008D41024489C24183C001440FB60C078D"
. "41010FB60407456BC9266BC04B4101C189C883C104440FB614074489D0C1E004"
. "4429D04401C8C1F8074539F84188041375BE8B4C241C014C241083442414018B"
. "5424188B44241401542410398424180100000F8575FFFFFF8B8424100100008B"
. "4C240C4531D2448B8C24100100004889BC24F00000004531FF48899C24300100"
. "0044897424204489D383E801896C24248974242889C28B8424180100004C89AC"
. "242801000089D783E801894424108B842410010000F7D08944241C4585C90F8E"
. "0701000085DB4489FE478D2C0F400F94C54429CE458D77FF8974240C8B74241C"
. "41B80100000031C04401FE89742414428D343F89742418660F1F840000000000"
. "85C0418D14070F84040100004084ED0F85FB00000039C70F84F3000000395C24"
. "100F84E9000000458D1406410FB60C134C01E2034C2468430FB6341341BA0100"
. "000039F1726F438D3407410FB6343339F172628B74240C01C6410FB6343339F1"
. "7253428D3428410FB6343339F172468B74241401C6410FB6343339F172378B74"
. "240C4401C6410FB6343339F172278B742418448D1406430FB6341341BA010000"
. "0039F17210478D1428470FB614134439D1410F92C283C0014183C00144881241"
. "39C10F8538FFFFFF4589EF83C301399C24180100000F85E0FEFFFF448B742420"
. "8B6C24248B742428894C240C488BBC24F00000004C8BAC2428010000488B9C24"
. "30010000E952F4FFFF0F1F800000000083C0014183C00141C60414024139C10F"
. "85DBFEFFFFEBA183F82F0F8560FDFFFF4C89D84C63CD83C50148C1E8100FB7C0"
. "0FAF84247801000099F7BC24480100000FAF8424F80000004189C0410FB7C349"
. "C1EB200FAF8424700100009941F7FF418D04804389448D0046891C8B89C84531"
. "DBE9E6FCFFFF8B4424684531FF4531C083C001C1E007894424688B8424100100"
. "00C1E002894424148B84241801000085C00F8EA4F3FFFF448974241C448B7424"
. "68448B9C24100100008B8424100100008B4C24104501C385C07E500F1F440000"
. "8D41024489C2440FB60C078D41010FB60407456BC9266BC04B4101C189C8440F"
. "B614074489D0C1E0044429D04401C84139C6410F9704144183C00183C1044539"
. "C375BD8B4C2414014C24104183C7018B4C2418014C24104439BC241801000075"
. "80448B74241CE910F3FFFFC744244400000000C744243C0000000031F631EDE9"
. "80F1FFFFC744242000000000E918F5FFFFC744243C0000000031EDC744244400"
. "000000E988FBFFFF9090909090909090"
this.MCode(MyFunc, A_PtrSize=8 ? x64:x32)
}
text:=j[1], w:=j[2], h:=j[3]
, err1:=(j[4] ? j[5] : ini.err1)
, err0:=(j[4] ? j[6] : ini.err0)
, mode:=j[7], color:=j[8], n:=j[9]
return (!ini.bits.Scan0) ? 0 : DllCall(&MyFunc
, "int",mode, "uint",color, "uint",n, "int",dir
, "Ptr",ini.bits.Scan0, "int",ini.bits.Stride
, "int",sx, "int",sy, "int",sw, "int",sh
, "Ptr",ini.ss, "Ptr",ini.s1, "Ptr",ini.s0
, (mode=5 && n>0 ? "Ptr":"AStr"),text, "int",w, "int",h
, "int",Floor(err1*10000), "int",Floor(err0*10000)
, "Ptr",allpos_ptr, "int",ini.allpos_max
, "int",Floor(w*ini.zoomW), "int",Floor(h*ini.zoomH))
}
code()
{
return "
(
//***** C source code of machine code *****
int __attribute__((__stdcall__)) PicFind(
int mode, unsigned int c, unsigned int n, int dir
, unsigned char * Bmp, int Stride
, int sx, int sy, int sw, int sh
, unsigned char * ss, unsigned int * s1, unsigned int * s0
, unsigned char * text, int w, int h, int err1, int err0
, unsigned int * allpos, int allpos_max
, int new_w, int new_h )
{
unsigned int o, i, j;
int ok, v, e1, e0, len1, len0, max;
int x, y, x1, y1, x2, y2, x3, y3, r, g, b, rr, gg, bb;
int r_min, r_max, g_min, g_max, b_min, b_max;
unsigned char * gs;
unsigned long long sum;
ok=0; o=0; len1=0; len0=0;
//----------------------
// MultiColor or PixelSearch or ImageSearch Mode
if (mode==5)
{
v=c*c;
if (n>0)
{
rr=(n>>16)&0xFF; gg=(n>>8)&0xFF; bb=n&0xFF; n-=0x1000000;
for (y=0; y<h; y++)
{
for (x=0; x<w; x++, o+=4)
{
r=text[2+o]; g=text[1+o]; b=text[o];
if (n==0 || (r-rr)*(r-rr)>v
|| (g-gg)*(g-gg)>v || (b-bb)*(b-bb)>v)
{
s1[len1]=(y*new_h/h)*Stride+(x*new_w/w)*4;
s0[len1++]=(r<<16)|(g<<8)|b;
}
}
}
}
else
{
for (sum=0; (j=text[o++])!='\0';)
{
if (j>='0' && j<='9')
sum = sum*10 + (j-'0');
else if (j=='/')
{
y=(sum>>16)&0xFFFF; x=sum&0xFFFF;
s1[len1]=(y*new_h/h)*Stride+(x*new_w/w)*4;
s0[len1++]=sum>>32; sum=0;
}
}
}
goto StartLookUp;
}
//----------------------
// Generate Lookup Table
for (y=0; y<h; y++)
{
for (x=0; x<w; x++)
{
if (mode==3)
i=(y*new_h/h)*Stride+(x*new_w/w)*4;
else
i=(y*new_h/h)*sw+(x*new_w/w);
if (text[o++]=='1')
s1[len1++]=i;
else
s0[len0++]=i;
}
}
//----------------------
// Color Position Mode
// only used to recognize multicolored Verification Code
if (mode==3)
{
y=c>>16; x=c&0xFFFF;
c=(y*new_h/h)*Stride+(x*new_w/w)*4;
goto StartLookUp;
}
//----------------------
// Generate Two Value Image
o=sy*Stride+sx*4; j=Stride-sw*4; i=0;
if (mode==0) // Color Mode
{
rr=(c>>16)&0xFF; gg=(c>>8)&0xFF; bb=c&0xFF;
for (y=0; y<sh; y++, o+=j)
for (x=0; x<sw; x++, o+=4, i++)
{
r=Bmp[2+o]-rr; g=Bmp[1+o]-gg; b=Bmp[o]-bb; v=r+rr+rr;
ss[i]=((1024+v)*r*r+2048*g*g+(1534-v)*b*b<=n) ? 1:0;
}
}
else if (mode==1) // Gray Threshold Mode
{
c=(c+1)<<7;
for (y=0; y<sh; y++, o+=j)
for (x=0; x<sw; x++, o+=4, i++)
ss[i]=(Bmp[2+o]*38+Bmp[1+o]*75+Bmp[o]*15<c) ? 1:0;
}
else if (mode==2) // Gray Difference Mode
{
gs=ss+sw*2;
for (y=0; y<sh; y++, o+=j)
{
for (x=0; x<sw; x++, o+=4, i++)
gs[i]=(Bmp[2+o]*38+Bmp[1+o]*75+Bmp[o]*15)>>7;
}
for (i=0, y=0; y<sh; y++)
for (x=0; x<sw; x++, i++)
{
if (x==0 || y==0 || x==sw-1 || y==sh-1)
ss[i]=2;
else
{
n=gs[i]+c;
ss[i]=(gs[i-1]>n || gs[i+1]>n
|| gs[i-sw]>n || gs[i+sw]>n
|| gs[i-sw-1]>n || gs[i-sw+1]>n
|| gs[i+sw-1]>n || gs[i+sw+1]>n) ? 1:0;
}
}
}
else // (mode==4) Color Difference Mode
{
r=(c>>16)&0xFF; g=(c>>8)&0xFF; b=c&0xFF;
rr=(n>>16)&0xFF; gg=(n>>8)&0xFF; bb=n&0xFF;
r_min=r-rr; g_min=g-gg; b_min=b-bb;
r_max=r+rr; g_max=g+gg; b_max=b+bb;
for (y=0; y<sh; y++, o+=j)
for (x=0; x<sw; x++, o+=4, i++)
{
r=Bmp[2+o]; g=Bmp[1+o]; b=Bmp[o];
ss[i]=(r>=r_min && r<=r_max
&& g>=g_min && g<=g_max
&& b>=b_min && b<=b_max) ? 1:0;
}
}
//----------------------
StartLookUp:
err1=len1*err1/10000;
err0=len0*err0/10000;
if (err1>=len1) len1=0;
if (err0>=len0) len0=0;
max=(len1>len0) ? len1 : len0;
if (mode==5 || mode==3)
{
x1=sx; y1=sy; x2=sx+sw-new_w; y2=sy+sh-new_h;
}
else
{
x1=0; y1=0; x2=sw-new_w; y2=sh-new_h; sx=0; sy=0;
}
// 1 ==> ( Left to Right ) Top to Bottom
// 2 ==> ( Right to Left ) Top to Bottom
// 3 ==> ( Left to Right ) Bottom to Top
// 4 ==> ( Right to Left ) Bottom to Top
// 5 ==> ( Top to Bottom ) Left to Right
// 6 ==> ( Bottom to Top ) Left to Right
// 7 ==> ( Top to Bottom ) Right to Left
// 8 ==> ( Bottom to Top ) Right to Left
if (dir<1 || dir>8) dir=1;
if (--dir>3) { r=y1; y1=x1; x1=r; r=y2; y2=x2; x2=r; }
for (y3=y1; y3<=y2; y3++)
{
for (x3=x1; x3<=x2; x3++)
{
y=((dir&3)>1) ? y1+y2-y3 : y3;
x=(dir&1) ? x1+x2-x3 : x3;
if (dir>3) { r=y; y=x; x=r; }
//----------------------
e1=err1; e0=err0;
if (mode==5)
{
o=y*Stride+x*4;
for (i=0; i<max; i++)
{
j=o+s1[i]; c=s0[i]; r=Bmp[2+j]-((c>>16)&0xFF);
g=Bmp[1+j]-((c>>8)&0xFF); b=Bmp[j]-(c&0xFF);
if ((r*r>v || g*g>v || b*b>v) && (--e1)<0)
goto NoMatch;
}
}
else if (mode==3)
{
o=y*Stride+x*4;
j=o+c; rr=Bmp[2+j]; gg=Bmp[1+j]; bb=Bmp[j];
for (i=0; i<max; i++)
{
if (i<len1)
{
j=o+s1[i]; r=Bmp[2+j]-rr; g=Bmp[1+j]-gg; b=Bmp[j]-bb; v=r+rr+rr;
if ((1024+v)*r*r+2048*g*g+(1534-v)*b*b>n && (--e1)<0)
goto NoMatch;
}
if (i<len0)
{
j=o+s0[i]; r=Bmp[2+j]-rr; g=Bmp[1+j]-gg; b=Bmp[j]-bb; v=r+rr+rr;
if ((1024+v)*r*r+2048*g*g+(1534-v)*b*b<=n && (--e0)<0)
goto NoMatch;
}
}
}
else
{
o=y*sw+x;
for (i=0; i<max; i++)
{
if (i<len1 && ss[o+s1[i]]==0 && (--e1)<0) goto NoMatch;
if (i<len0 && ss[o+s0[i]]==1 && (--e0)<0) goto NoMatch;
}
// Clear the image that has been found