Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
graphics>text.....
#1
any way to convert....? Like nathan's star wars thingy?
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#2
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...
Reply
#3
I posted code a while ago. It is in C.

I'm a lazy person, so it uses Allegro too Big Grin

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.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#4
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!!!!! Smile
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#5
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,

Code:
.X
X.
.X

is translated to ( .
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#6
*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)"..........
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#7
Just DL Nate's Jedi2 and Joe's FMV. Those we're koolness!!!!
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#8
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.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)