Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works
Anything · Lazarus or Delphi
Random projectRandom project

ASCii-Generator

Generate ASCii Image Pictures

View on GitHub

Member rating

No ratings yet.

Sign in to rate this project.

README

ASCii-Generator:

Compiler 10 Seattle 10 1 Berlin 10 2 Tokyo 10 3 Rio 10 4 Sydney 11 Alexandria 12 Athens
Components None

With the ASCII Generator, you can convert your images to ASCII. Images can be rendered in Monochrome, full color, or Grayscale. The tool uses all TrueType fonts (TryTypeFonts) files installed on your Windows system, as well as the specific font settings.

TrueType was known during its development stage, first by the codename "Bass" and later on by the codename "Royal". The system was developed and eventually released as TrueType with the launch of Mac System 7 in May 1991. The initial TrueType outline fonts, four-weight families of Times Roman, Helvetica, Courier, and the pi font "Symbol" replicated the original PostScript fonts of the Apple LaserWriter. Apple also replaced some of their Bitmap Fonts used by the graphical user-interface of previous Macintosh System versions (including Geneva, Monaco and New York) with scalable TrueType outline-fonts. For compatibility with older systems, Apple shipped these fonts, a TrueType Extension and a TrueType-aware version of Font/DA Mover for System 6. For compatibility with the Laserwriter II, Apple developed fonts like ITC Bookman and ITC Chancery in TrueType format.

Features:

  • Import Formats (*.BMP; *.JPG); *.PNG; *.GIF)
  • Export Formats (*.BMP; *.JPG); *.PNG; *.GIF)
  • Load System TTF Files
  • Select TColors
  • Set RGB Colors
  • Bumpmap (RGB) on Image
  • Invert Image
  • Highlight Image
  • Sepia Effect (10%)
  • Resample Image (1%)
  • Blur (1%)
  • Flip Image (X, Y)
  • Rotate Image 90°
  • Export Tranzparent Images
  • Select Custom ASCii Term

Colors:

The various color calculations are somewhat more complex than with a single primary color. Here, both the entire RGB color set and each individual RGB channel can be defined, in all possible colors.

The colors can be modified as desired.

pascal
// The entire RGB output.
// Main Color Calculation for (RGB)
function CalcGrayValue(Color: Cardinal): byte;
  var c: TRGBTRIPLE; // h: Byte;
  begin
    c.rgbtRed   := GetRValue(Color);
    c.rgbtGreen := GetGValue(Color);
    c.rgbtBlue  := GetBValue(Color);
    Result := round((c.rgbtRed + c.rgbtGreen + c.rgbtBlue) / 3);
  end;

{..}

// Or each individual RGB channel

{..}

 // Calculate Red (R) for Select TColor
function CalcRed(Color: Cardinal): byte;      // red
var c: TRGBTRIPLE;  h: Byte;
  begin
    c.rgbtRed   := GetRValue(Color); c.rgbtGreen := GetGValue(Color);
    c.rgbtBlue  := GetBValue(Color);
    h := HiByte(c.rgbtRed * SpinEdit1.Value + c.rgbtGreen * 0 + c.rgbtBlue * 0);
    Result := RGB(h + Round((c.rgbtRed - h) / 255),
                  h + Round((c.rgbtGreen - h) / 255),
                  h + Round((c.rgbtBlue - h) / 255));
end;

  // Calculate Green (G) for Select TColor
function CalcGreen(Color: Cardinal): byte;     // green
var c: TRGBTRIPLE;  h: Byte;
  begin
    c.rgbtRed   := GetRValue(Color); c.rgbtGreen := GetGValue(Color);
    c.rgbtBlue  := GetBValue(Color);
    h := HiByte(c.rgbtRed * 0 + c.rgbtGreen * SpinEdit2.Value + c.rgbtBlue * 0);
    Result := RGB(h + Round((c.rgbtRed - h) / 255),
                  h + Round((c.rgbtGreen - h) / 255),
                  h + Round((c.rgbtBlue - h) / 255));
end;

  // Calculate Blue (B) for Select TColor
function CalcBlue(Color: Cardinal): byte;     // blue
var c: TRGBTRIPLE;  h: Byte;
  begin
    c.rgbtRed   := GetRValue(Color); c.rgbtGreen := GetGValue(Color);
    c.rgbtBlue  := GetBValue(Color);
    h := HiByte(c.rgbtRed * 0 + c.rgbtGreen * 0 + c.rgbtBlue * SpinEdit3.Value);
    Result := RGB(h + Round((c.rgbtRed - h) / 255),
                  h + Round((c.rgbtGreen - h) / 255),
                  h + Round((c.rgbtBlue - h) / 255));
end;

The calculated colors must be specified in this section.

pascal
// Calcualte Colors
         Case RadioGroup1.ItemIndex of
          0: bmp.Canvas.Font.Color := RGB(CalcGrayValue(aColor), 0, 0); // Red
          1: bmp.Canvas.Font.Color := RGB(0, CalcGrayValue(aColor), 0); // Green
          2: bmp.Canvas.Font.Color := RGB(0, 0, CalcGrayValue(aColor)); // Blue
          3: bmp.Canvas.Font.Color := RGB(CalcGrayValue(aColor), CalcGrayValue(aColor), CalcGrayValue(aColor));
          4: bmp.Canvas.Font.Color := aColor; // Calculate RGB Complete to Font
        end;

        // Calculate Individuall TColor to RGB on Font
        if (RadioGroup1.Buttons[0].Checked = false) and
           (RadioGroup1.Buttons[1].Checked = false) and
           (RadioGroup1.Buttons[2].Checked = false) and
           (RadioGroup1.Buttons[3].Checked = false) and
           (RadioGroup1.Buttons[4].Checked = false) then begin
            bmp.Canvas.Font.Color := RGB(CalcRed(aColor),
                                     CalcGreen(aColor),
                                     CalcBlue(aColor));
          end;

Have Fun with ASCii !