Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
bullshit image converter to 0bpp because i was bored
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.IO;
namespace whythefuckwouldyouusethis
public class BSImage
public static Image Decode(byte[] bs)
if (bs?.Length != 12) return null;
int w = BitConverter.ToInt32(bs, 0);
int h = BitConverter.ToInt32(bs, 4);
Color c = Color.FromArgb(bs[8], bs[9], bs[10], bs[11]);
Bitmap img = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format1bppIndexed);
img.Palette.Entries[0] = c;
return img;
public static byte[] Encode(Image im)
int w = im.Width;
int h = im.Height;
Color c = im.Palette.Entries[0];
return BitConverter.GetBytes(w)
.Concat(new byte[] { c.R, c.G, c.B, c.A })
public static void Save(string loc, Image im)
File.WriteAllBytes(loc, Encode(im));
public static Image Load(string loc)
return Decode(File.ReadAllBytes(loc));
Copy link

OMGasm commented Aug 13, 2018

(i haven't even tested it)


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment