// returns color at specified point. // the return value suited for current pixel format. // outrange point will raise an error. int getColorAt(int x, int y) { RECT r = new RECT(); r.Left = x; r.Top = y; r.Bottom = r.Top + 1; r.Right = r.Left + 1; DDSURFACEDESC2 desc = new DDSURFACEDESC2(); surface.GetSurfaceDesc(ref desc); surface.Lock(ref r, ref desc, CONST_DDLOCKFLAGS.DDLOCK_WAIT | CONST_DDLOCKFLAGS.DDLOCK_READONLY, 0); int c = surface.GetLockedPixel(x, y); surface.Unlock(ref r); return(c); }
internal Surface(DirectDrawSurface7 _handle) { this.surface = _handle; // compute the size of this surface DDSURFACEDESC2 desc = new DDSURFACEDESC2(); surface.GetSurfaceDesc(ref desc); this.size = new Size(desc.lWidth, desc.lHeight); resetClipRect(); // compute the bit shift width for color fill DDPIXELFORMAT pixelFormat = new DDPIXELFORMAT(); surface.GetPixelFormat(ref pixelFormat); widthR = countBitWidth(pixelFormat.lRBitMask); widthG = countBitWidth(pixelFormat.lGBitMask); widthB = countBitWidth(pixelFormat.lBBitMask); }
/// <summary> /// Initialize a new surface based on a previously created surface /// </summary> /// <param name="directDrawSurface">The native DirectDraw surface used as reference.</param> public DirectDrawSurface(DirectDrawSurface7 directDrawSurface) { directDrawSurface.GetSurfaceDesc(ref descriptor); surface = directDrawSurface; }
/// <summary> /// Initialize a new surface based on a previously created surface /// </summary> /// <param name="directDrawSurface">The native DirectDraw surface used as reference.</param> internal DirectDrawSurface(DirectDrawSurface7 directDrawSurface) { directDrawSurface.GetSurfaceDesc(ref _descriptor); _surface = directDrawSurface; }