public void SizeUpdater_Tick(object sender, EventArgs e) { Location = new Point(-8, -31); if (open) { RECT size = new RECT(); InGameUser32.GetWindowRect(Data.mcWindow, ref size); Size = new Size( (size.Right - size.Left), (size.Bottom - size.Top)); } else { Size = new Size(0, 0); } }
Bitmap GetMCWindowImage() { IntPtr processId = Data.mcWindow; IntPtr src = InGameUser32.GetWindowDC(processId); RECT rct = new RECT(); InGameUser32.GetWindowRect(processId, ref rct); int w, h; w = rct.Right - rct.Left; h = rct.Bottom - rct.Top; IntPtr destPtr = InGameGdi32.CreateCompatibleDC(src); IntPtr bmPtr = InGameGdi32.CreateCompatibleBitmap(src, w, h); IntPtr oldW = InGameGdi32.SelectObject(destPtr, bmPtr); InGameGdi32.BitBlt(destPtr, 0, 0, w, h, src, 0, 0, 13369376 /*SRCCOPY*/); InGameGdi32.SelectObject(destPtr, oldW); InGameGdi32.DeleteDC(destPtr); InGameUser32.ReleaseDC(processId, src); Bitmap temp = Image.FromHbitmap(bmPtr); InGameGdi32.DeleteObject(bmPtr); var gb = new GaussianBlur(temp); var res = gb.Process(5, darken); /* If you're an internet user looking through the src for MarsClient, I guess I should explain why I'm * calling GC.Collect(). You should never call this function unless you think you know better than the * Auto-GC, which in most cases you don't, but here the GaussianBlur object takes up about 4x-5x the * memory of a typical Bitmap object which, if not IMMEDIATELY collected will cause a crash on worse * systems. Therefore in this specific case it IS valid to call GC.Collect() on the GaussianBlur object. */ gb = null; GC.Collect(); return(res); }