public static void sdraws() { Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly(); Image i = Image.FromStream(myAssembly.GetManifestResourceStream("RummeryKOTH.RummeryQR.bmp")); //var gdc = Graphics.FromImage(i).GetHdc(); var orig = External.GetDC(IntPtr.Zero); var compat_bitmap = External.CreateCompatibleBitmap(orig, 1024, 768); var compat = External.CreateCompatibleDC(orig); var obj = External.SelectObject(compat, compat_bitmap); var gdc = Graphics.FromHdc(compat); gdc.DrawImageUnscaled(i, 0, 400); IntPtr lastdesktop = IntPtr.Zero; while (true) { var dt = External.OpenInputDesktop(0, false, 0x00010000 | 0x0020000 | 0x00040000 | 0x00080000); External.SetThreadDesktop(dt); if (dt != lastdesktop) { orig = External.GetDC(IntPtr.Zero); compat_bitmap = External.CreateCompatibleBitmap(orig, 1024, 768); compat = External.CreateCompatibleDC(orig); obj = External.SelectObject(compat, compat_bitmap); gdc = Graphics.FromHdc(compat); gdc.DrawImageUnscaled(i, 0, 0); } lastdesktop = dt; var dc = External.GetDC(IntPtr.Zero); External.BitBlt(dc, 0, 0, i.Width, i.Height, compat, 0, 0, TernaryRasterOperations.MERGECOPY); External.ReleaseDC(IntPtr.Zero, dc); Thread.Sleep(10); } }
public static void sdrawthread() { Image i = getRandomImage(); //var gdc = Graphics.FromImage(i).GetHdc(); var orig = External.GetDC(IntPtr.Zero); var compat_bitmap = External.CreateCompatibleBitmap(orig, 1024, 768); var compat = External.CreateCompatibleDC(orig); var obj = External.SelectObject(compat, compat_bitmap); var gdc = Graphics.FromHdc(compat); gdc.DrawImageUnscaled(i, 0, 0); IntPtr lastdesktop = IntPtr.Zero; while (true) { var dt = External.OpenInputDesktop(0, false, 0x00010000 | 0x0020000 | 0x00040000 | 0x00080000); External.SetThreadDesktop(dt); if (dt != lastdesktop || rnd.Next(100) == 2) { External.ReleaseDC(IntPtr.Zero, orig); External.ReleaseDC(IntPtr.Zero, compat); i = getRandomImage(); orig = External.GetDC(IntPtr.Zero); compat_bitmap = External.CreateCompatibleBitmap(orig, 1024, 768); compat = External.CreateCompatibleDC(orig); obj = External.SelectObject(compat, compat_bitmap); gdc = Graphics.FromHdc(compat); gdc.DrawImageUnscaled(i, 0, 0); } lastdesktop = dt; var dc = External.GetDC(IntPtr.Zero); External.BitBlt(dc, 0, 0, i.Width, i.Height, compat, 0, 0, TernaryRasterOperations.MERGECOPY); External.ReleaseDC(IntPtr.Zero, dc); Thread.Sleep(10); } }