Last active
March 15, 2022 21:15
-
-
Save TayIorRobinson/208c49db374a1d215ba61e660d2804d0 to your computer and use it in GitHub Desktop.
fuck you, transes your computer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define THROW_ON_ERROR | |
using System; | |
using System.Drawing; | |
using System.Runtime.InteropServices; | |
using System.Windows.Forms; | |
namespace Blitter { | |
class Program { | |
[DllImport("user32.dll", EntryPoint = "GetDC")] | |
static extern IntPtr GetWindowDC(IntPtr hWnd); | |
[DllImport("user32.dll", SetLastError = false)] | |
static extern IntPtr GetDesktopWindow(); | |
[DllImport("gdi32.dll", EntryPoint = "CreateCompatibleDC", SetLastError = true)] | |
static extern IntPtr CreateCompatibleDC([In] IntPtr hdc); | |
private static void assert(bool condition, string error) { | |
if (!condition) throw new Exception(error); | |
} | |
static void Main(string[] args) { | |
Rectangle primary = Screen.PrimaryScreen.Bounds; | |
int sw = primary.Width; | |
int sh = primary.Height; | |
IntPtr hwnd = GetDesktopWindow(); | |
IntPtr wDc = GetWindowDC(hwnd); | |
assert(wDc != IntPtr.Zero, "getdc"); | |
Graphics graphic = Graphics.FromHdc(wDc); | |
Bitmap bitmap = new Bitmap(1, sh); | |
Color CYAN = Color.FromArgb(64, 0, 255, 255); | |
Color PINK = Color.FromArgb(64, 255, 0, 255); | |
Color WHITE = Color.FromArgb(64, 255, 255, 255); | |
for (int y = 0; y < sh; y++) { | |
int c = y / (sw / 9); | |
if (c == 0 || c >= 4) bitmap.SetPixel(0, y, CYAN); | |
else if (c == 1 || c == 3) bitmap.SetPixel(0, y, PINK); | |
else bitmap.SetPixel(0, y, WHITE); | |
} | |
TextureBrush brush = new TextureBrush(bitmap); | |
while (true) { | |
graphic.FillRectangle(brush, 0, 0, sw, sh); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment