Coder Social home page Coder Social logo

bitmapascii's Introduction

BitmapASCII

Extends C#'s Bitmap class to add a PrintASCII() function that can be used in Windows console applications to render images as crude, colorful text.

The latest version is on the releases page.

PrintASCII()

void PrintASCII(this Bitmap src, int minSide, bool fit = true,bool useLongArray=false)

Parameters

  • minSide - the minimum width or height of the image specified as a number of columns or rows. The smallest dimension of the image is used.
  • fit - Should the image be resized to fit inside console window if minSide would overflow.
  • useLongArray - Two character shading arrays are provided to fill in each cell. The short one is used by default. The long one uses more characters but you might prefer one style over the other.

DominantConsoleColors()

ConsoleColor[] DominantConsoleColors(this Bitmap src, int num = 0, bool useLong = false)
  • num - the number of colors to return, default is all colors in descenting order.
  • useLongArray - Two character shading arrays are provided to fill in each cell. The short one is used by default. The long one uses more characters but you might prefer one style over the other.

DominantConsoleColor()

As above, but directly returns the most dominant ConsoleColor.

Examples

Bitmap bmp = new Bitmap(filePath);
bmp.PrintASCII();                  //print using default settings
bmp.PrintASCII(width);             //print at a desired width, but stay responsive
bmp.PrintASCII(width,false);       //print at a fixed width
bmp.PrintASCII(width, true, true); //print responsively and using the more detailed shading characters
ConsoleColor[] cols = bmp.DominantConsoleColors(3); //return an array of the three most dominant colors in the image
Console.ForegroundColor = bmp.DominantConsoleColor(); //set the console foreground color to match the image accent

dog

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.