08-27-2003, 11:37 PM
08-27-2003, 11:45 PM
http://www.glassgiant.com/misc_ascii.php
Jason Earl also wrote a PHP script to do something similar...plus there are also loads of programs that generate ASCII art from images...
Jason Earl also wrote a PHP script to do something similar...plus there are also loads of programs that generate ASCII art from images...
08-28-2003, 01:27 AM
I posted code a while ago. It is in C.
I'm a lazy person, so it uses Allegro too
If you want a compiled version, tell me do. I'll be bothered to upload it.
I'm a lazy person, so it uses Allegro too
Code:
#include <stdio.h>
#include <allegro.h>
#include <string.h>
// This uses a conversion for bitmap only images.
// the conversion is based on Rob Harley's (robert@vlsi.cs.caltech.edu)
// code mapping.
char mapping[]={
' ',',','.','_','-','i','v','g','-','c','i','s','=','e','z','m',
'\'','!','/','2','!',']','/','d','/','(','/','K','Y','4','Z','W',
'`','\\','|','L','\\','\\',')','G','!','t','[','b','+','N','D','W',
'~','T','7','X','V','Y','Z','8','f','5','P','K','*','M','A','@'} ;
// ordered by six-bit numbers in 2x3 cells.
int main(int argc, char *argv[])
{
BITMAP *bp;
FILE *pf;
PALETTE dummy;
int x,y,xx,yy;
int i;
char c;
char ct;
char invert=0;
allegro_init(); set_color_depth(8);
puts("2 colour bitmap to ASCII converter by Na Than");
puts("Based on Rob Harley's mapping for 2x3 bitmap cells.");
puts("Contact me at na_th_an@hotmail.com");
puts(" ");
if (argc<3) {puts("ERROR 1 :: Arguments required.");
puts("Usage: ASC_B&W INPUT.{BMP|PCX|LBM|TGA} OUTPUT.EXT [invert]");
return 1;}
if (!strcmp(argv[3],"invert"))
invert=1;
// Convert
if((bp = load_bitmap(argv[1],dummy))==NULL)
{
puts("ERROR 2 :: unable to open input file."); return 2;
}
if((pf = fopen(argv[2],"wb"))==NULL)
{
puts("ERROR 3 :: unable to open output file.");return 3;
}
puts("Now converting. If you see a wrong picture, maybe the BITMAP is not");
puts("maped to have 0 for black, 1 for white.");
if (invert) puts("Doing it inverting colours");
for(y=0;y<bp->h;y+=3)
{
for(x=0;x<bp->w;x+=2)
{
// build binary
c=0;ct=0;
for (yy=2;yy>=0;yy--)
for (xx=1;xx>=0;xx--)
{
if (getpixel(bp,x+xx,y+yy) == 0)
c += (1<<ct);
ct++;
}
printf("Done :: %i%\r",1+ (100 * (x+y*bp->w))/(bp->h*bp->w));
// output character
fputc(mapping[c],pf);
}
fputc(13,pf);fputc(10,pf);
}
fclose(pf);
printf("\n");
puts("Done :)");
destroy_bitmap(bp);
allegro_exit();
}
If you want a compiled version, tell me do. I'll be bothered to upload it.
08-28-2003, 02:18 AM
Ah... so it looks like there isn't any pattern matching, just density. Now, the first person who makes a color matcher + ascii matcher (extra points for pattern matching......) AND makes a Star Wars demo that's several minutes long wins... my appreciation!!!!!
08-28-2003, 07:22 AM
In fact there is a pattern matcher. The ASCII are selected so their shape match the dot patterns (this works with 1 bit files).
For example,
is translated to ( .
For example,
Code:
.X
X.
.X
is translated to ( .
08-28-2003, 08:23 PM
*scratches head*
Oh. Well I didn't really understand your example... or your code. Pointers make things obscure to me...... especially things like "(1<<ct)"..........
Oh. Well I didn't really understand your example... or your code. Pointers make things obscure to me...... especially things like "(1<<ct)"..........
08-29-2003, 12:43 PM
Just DL Nate's Jedi2 and Joe's FMV. Those we're koolness!!!!
08-29-2003, 05:31 PM
Quote:*scratches head*
Oh. Well I didn't really understand your example... or your code. Pointers make things obscure to me...... especially things like "(1<<ct)"..........
The program reads blocks of 2x3 pixels that can be ON or OFF (white or black, 1 bit GFX). Depending on the shape in the 2x3 pixels it selects a letter.
Code:
..
XX
..
would translate to "-", for example.
(1<<ct) is just like 2^ct, but faster.