几个老外关于DX屏幕像素颜色判断的热烈讨论
3 n. Y4 \1 m5 u v+ Uhttp://www.xtremedotnettalk.com/showthread.php?p=4661598 t5 f5 ?; s8 x* k! A3 u. k
) l$ u: X$ H0 i6 o; KSurface s = dxDevice.GetBackBuffer(0, 0, BackBufferType.Mono);
) G, X, y+ \* W! Zuint[,] data = (uint[,])s.LockRectangle(new Rectangle(0, 0, 32, 32), LockFlags.ReadOnly);" o2 e/ y% ?' ^* a
5 m, y2 D1 A* E- i
for (int n = 0; n < 100; i++)
% w# N$ N0 _3 g6 }% e0 R9 L0 A0 A{4 M. X% X: {* n P4 S) K
for (int j = 0; j < 100; j++)5 f+ Q6 B0 ^0 i+ b; z
{
8 w+ x' S% R( F3 ?) } data[n, j] = (uint)Color.White.ToArgb();! T$ F7 [: `: U$ T6 {2 I3 V* G
}
6 ~( D- |6 `; E ~% D l/ ?0 G}
, N4 K, ^- u9 n6 g. @3 N! N: O& d/ U5 Z$ K( V( g& e
----------------------------------------------------
! ?$ I% V- x* _, D: z* Q% J: ?Surface s = dxDevice.GetBackBuffer(0, 0, BackBufferType.Mono);
' E& z9 S) b0 h; Z, W# mStream stream = SurfaceLoader.SaveToStream(ImageFileFormat.Bmp, s, new Rectangle(int locationX, int locationY, 1, 1));; M. L; K; e0 B% l5 c1 }9 I0 {
Bitmap bmp = new Bitmap(stream);
# S) k- b8 ^ vstream.Dispose();# G' G5 T: R' j# f* r
5 X0 r J1 J7 s- I* s. ^2 g
Color c = bmp.GetPixel(0, 0);
6 ^, c" K9 }+ v* t0 o1 {- Y& O( sif (c.R == 255 && c.G == 0 && c.B == 0)& H) J/ O$ G; N7 M. |, N6 K
{: S v9 Z' Z/ k9 M' T
// do something" K) T0 ?" [/ E% L
break;# }! ]9 G/ X0 x+ O
} |