public static Bitmap GenerateDebugImage(int width, int height, string message) { GradientPattern pattern = new GradientPattern(); pattern.bottomLeft = (Color)QColor.generateRandomOpaque(128, 255); pattern.bottomRight = (Color)QColor.generateRandomOpaque(128, 255); pattern.topLeft = Color.Fuchsia; pattern.topRight = Color.Fuchsia; Bitmap bmp = pattern.makeBitmap(width, height); GDIPlusRenderer r = new GDIPlusRenderer(bmp); float fontSize = Math.Min(width, height) / 10.0f; fontSize = Range.clamp(fontSize, 10, 45); using (Font f = new Font("Arial", fontSize, FontStyle.Bold)) { TextFormat tf = new TextFormat(f, Color.Black, true, Color.White, false); tf.render(r, message, 0, height / 2); bmp = r.RenderTargetAsGDIBitmap(); } return(bmp); }