冒险解谜游戏中文网 ChinaAVG

标题: 【图像识别汉化研究】DX屏幕像素颜色判断 [打印本页]

作者: shane007    时间: 2009-5-29 11:47
标题: 【图像识别汉化研究】DX屏幕像素颜色判断
几个老外关于DX屏幕像素颜色判断的热烈讨论
, @, A0 f* k! U/ ]http://www.xtremedotnettalk.com/showthread.php?p=466159# M* x0 p% l5 P- `/ ?# N

% J3 q/ |# B# E$ ^& h) |Surface s = dxDevice.GetBackBuffer(0, 0, BackBufferType.Mono);+ l- {9 G; d7 d  o
uint[,] data = (uint[,])s.LockRectangle(new Rectangle(0, 0, 32, 32), LockFlags.ReadOnly);
3 p& e( S5 V  W: Z
0 u0 Z$ w" Y! Z! h7 N! D2 ifor (int n = 0; n < 100; i++)
; }: O( {8 F9 d, t{
6 w0 P0 E- P, X8 b    for (int j = 0; j < 100; j++)% j5 I" a$ k/ L2 C2 P' }2 z
    {# L' |' ^: ]# q+ C
        data[n, j] = (uint)Color.White.ToArgb();4 `8 g% t. n) ^' w8 k' \& g1 a7 ?$ v, P
    }0 ]1 ]! P3 i+ C. ?: M
}8 K1 p2 h, n3 B0 ^, U
, a  i: w# R! q8 J( _
----------------------------------------------------, W# @4 Q1 [2 K
Surface s = dxDevice.GetBackBuffer(0, 0, BackBufferType.Mono);
- M9 d, M; l4 A( V2 YStream stream = SurfaceLoader.SaveToStream(ImageFileFormat.Bmp, s, new Rectangle(int locationX, int locationY, 1, 1));9 m/ e5 W; C( i( @" q4 W4 l" {
Bitmap bmp = new Bitmap(stream);; Q  }  h1 T5 A; J4 G* C( T$ W
stream.Dispose();
* N7 c; @" g0 ^/ I6 T' N) X
8 z) B+ F6 O$ D8 ~6 @Color c = bmp.GetPixel(0, 0);
# N& S* B2 R' ]* mif (c.R == 255 && c.G == 0 && c.B == 0)
& A% N: b3 ?7 i, j! o# g( k{" {6 i, Q5 {  ?3 D
    // do something7 x- j3 z( v, |" P
    break;
% ^6 F: U8 N6 E  ^! ~4 `6 L! s}




欢迎光临 冒险解谜游戏中文网 ChinaAVG (https://chinaavg.com/) Powered by Discuz! X3.2