Skip to content

Instantly share code, notes, and snippets.

@TayIorRobinson
Last active Mar 15, 2022
Embed
What would you like to do?
fuck you, transes your computer
#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