冒险解谜游戏中文网 ChinaAVG
标题:
【图像识别汉化研究】DX屏幕像素颜色判断
[打印本页]
作者:
shane007
时间:
2009-5-29 11:47
标题:
【图像识别汉化研究】DX屏幕像素颜色判断
几个老外关于DX屏幕像素颜色判断的热烈讨论
* e1 D7 n" D+ {6 d
http://www.xtremedotnettalk.com/showthread.php?p=466159
) c4 m# b( W; z+ H% W1 E6 P
, t! Z* b$ o/ o: C
Surface s = dxDevice.GetBackBuffer(0, 0, BackBufferType.Mono);
0 Z/ N, a4 D4 Y: Z7 q. }
uint[,] data = (uint[,])s.LockRectangle(new Rectangle(0, 0, 32, 32), LockFlags.ReadOnly);
$ W7 t; T q/ r5 s$ B
7 c+ _, ?, A; Y, f8 `7 y. R" q+ L
for (int n = 0; n < 100; i++)
+ t) ~! e9 ^" u$ Z- q" e
{
, Z* Z, g9 h- r8 L
for (int j = 0; j < 100; j++)
# A. V1 C- n; j1 [ r& F5 D
{
4 A) I9 y* w6 r+ ?0 s9 n% d5 b, m
data[n, j] = (uint)Color.White.ToArgb();
2 i+ [4 i) p# \2 L/ t* S' R
}
% @: `* ^7 S( [ }7 R4 ~
}
3 a6 ^6 b$ J5 m/ d
- e8 I' z: n: k2 j: `
----------------------------------------------------
& p& p3 \+ Q( D/ }' V* H$ q. m- ^8 {
Surface s = dxDevice.GetBackBuffer(0, 0, BackBufferType.Mono);
% q: A+ s( S6 b) b$ X& N
Stream stream = SurfaceLoader.SaveToStream(ImageFileFormat.Bmp, s, new Rectangle(int locationX, int locationY, 1, 1));
' _; n1 p& v! u
Bitmap bmp = new Bitmap(stream);
# k0 v" Z& l E( {) J
stream.Dispose();
% Q! i; z. g2 | ?
8 \/ j) {4 A: j/ ?
Color c = bmp.GetPixel(0, 0);
# \$ X" G9 L& F3 t" X
if (c.R == 255 && c.G == 0 && c.B == 0)
+ B2 f* X- Z3 g1 _
{
$ m; B0 [9 M$ K2 T
// do something
" b; P# ~4 p2 F, f9 N
break;
* |) W7 ~. a4 V$ F
}
欢迎光临 冒险解谜游戏中文网 ChinaAVG (https://chinaavg.com/)
Powered by Discuz! X3.2