Computer Science Canada

text picture genereator

Author:  zylum [ Wed Mar 10, 2004 11:55 pm ]
Post subject:  text picture genereator

i'm trying to make a program that generates text pictures out of normal black and white pictures... here is what i have so far...

code:
var clr : int
var pic : int
pic := Pic.FileNew ("flamebw.bmp")
pic := Pic.Scale (pic, 100, 100)
Pic.Draw (pic, 0, 0, picCopy)
var dots : array 1 .. 100, 1 .. 100 of int
var numbers : array 1 .. 16 of string := init ("1", "7", "3", "C", "2", "6", "4", "5", "0", "A", "D", "F", "9", "8", "B", "E")

for x : 1 .. 100
    for y : 1 .. 100
        if whatdotcolor (x, y) = 0 then
            dots (x, y) := 16
        elsif whatdotcolor (x, y) = 7 then
            dots (x, y) := 1
        elsif whatdotcolor (x, y) = 8 then
            dots (x, y) := 15
        elsif whatdotcolor (x, y) = 15 then
            dots (x, y) := 7
        else
            clr := whatdotcolor (x, y)
            dots (x, y) := clr - 16
        end if
    end for
end for

var file : int
var row : string
open : file, "picture.txt", put
for decreasing y : 100 .. 1
    for x : 1 .. 100
        if x < 100 then
            put : file, numbers (17 - dots (x, y)) ..
        else
            put : file, numbers (17 - dots (x, y))
        end if
    end for
end for


its not that great but works (somewhat)

later ill probably make it so that its only binary instead of hex...

btw, heres the image: http://members.rogers.com/zylum/images/flamebw.bmp

-zylum

Author:  Tony [ Thu Mar 11, 2004 12:54 am ]
Post subject: 

not bad, but the image would work better with a font that is square... image looks vertically stretched using most (if not all) fonts Confused

Author:  octopi [ Thu Mar 11, 2004 1:16 am ]
Post subject: 

looks better if you change the
code:
"1"

to a

code:
" "


in your 'init' line

Author:  Paul [ Thu Mar 11, 2004 4:51 pm ]
Post subject: 

Very nice, you can actually make the shape out, but it only worked for me with a black and white pic. With a color pic, it said:
array subscript is out of range on
code:

 put : file, numbers (17 - dots (x, y)) ..


Author:  zylum [ Thu Mar 11, 2004 6:48 pm ]
Post subject:  Re: text picture genereator

zylum wrote:
i'm trying to make a program that generates text pictures out of normal black and white pictures... here is what i have so far...
-zylum


Shocked


Laughing

Author:  Paul [ Thu Mar 11, 2004 7:29 pm ]
Post subject: 

oh oops, see thats why I do the matching on the history test but don't explain it.

Author:  jonos [ Fri Mar 12, 2004 12:45 am ]
Post subject: 

pretty funky shite, worked really nice for me, it would be awesome with colour pictures, but awesome prog. just gave me an idea.

Author:  Tony [ Fri Mar 12, 2004 12:58 am ]
Post subject: 

what you could do for color pictures is to convert them to greyscale using RGB module and then output text in color sampled from the original picture.

code:

var clr : int
var pic : int
pic := Pic.FileNew ("flamebw.bmp")
pic := Pic.Scale (pic, 100, 100)
Pic.Draw (pic, 0, 0, picCopy)
var dots : array 1 .. 100, 1 .. 100 of int
var numbers : array 1 .. 16 of string := init ("1", "7", "3", "C", "2", "6", "4", "5", "0", "A", "D", "F", "9", "8", "B", "E")

var dotcolor:array 1..100, 1..100 of int
var fontID:int := Font.New("lucon:8")

for x : 1 .. 100
    for y : 1 .. 100
        if whatdotcolor (x, y) = 0 then
            dots (x, y) := 16
        elsif whatdotcolor (x, y) = 7 then
            dots (x, y) := 1
        elsif whatdotcolor (x, y) = 8 then
            dots (x, y) := 15
        elsif whatdotcolor (x, y) = 15 then
            dots (x, y) := 7
        else
            clr := whatdotcolor (x, y)
            dots (x, y) := clr - 16
        end if
       
        dotcolor(x,y):=whatdotcolor(x,y)
       
    end for
end for

cls

for decreasing y : 100 .. 1
    for x : 1 .. 100

        Font.Draw(numbers (17 - dots (x, y)),x*Font.Width("*",fontID),y*Font.Width("*",fontID),fontID,dotcolor(x,y))

    end for
end for


shaded greyscale picture

Author:  Delos [ Fri Mar 12, 2004 1:03 pm ]
Post subject: 

Seeing as people love their colour pics...how about you just convert all pics into greyscale before you run your procedures on them. jawaharyousuf has a fairly decent greyscale filter...and what would you know, so do I!

For jy's:
http://www.compsci.ca/v2/viewtopic.php?t=4009

For mine:
http://www.compsci.ca/v2/viewtopic.php?t=3316

PM me if you'd like some code with that...but seeing as you are zylum you shouldn't have too much trouble emulating it...

Author:  SuperGenius [ Mon Mar 15, 2004 3:09 pm ]
Post subject: 

Jonos, why is it that you have 0% of your status bar above your avatar filled, even though you have close to 750 posts?

Author:  octopi [ Mon Mar 15, 2004 3:10 pm ]
Post subject: 

Its cause jonos is a LAMER

Author:  Cervantes [ Mon Mar 15, 2004 7:57 pm ]
Post subject: 

*In a last ditch effort to get things back on topic (the discussion veered off when a question was asked about Jonos' status bar *glare*), Cervantes tries a revelutionary new tactic!*

Cervantes: Nice program Zylum! My only complaint is that its kinda big. I guess there's no way to make the font size outputted smaller.. Thinking I wonder if that's similar to how they did the ascii matrix that can be found here.

EDIT: Unfortunately, Cervantes' valiant effort is shrouded by the fact that his post was half spam.


Cervantes: Shucks! Next time....

Author:  SuperGenius [ Mon Mar 15, 2004 8:40 pm ]
Post subject: 

octopi wrote:
Its cause jonos is a LAMER


I gathered that much, but what did he do to deserve that lowly status?

Author:  AsianSensation [ Mon Mar 15, 2004 8:42 pm ]
Post subject: 

do remain on topic please. And to answer your question, jonos asked for it. (He literally did, not joking)

Author:  Paul [ Mon Mar 15, 2004 8:43 pm ]
Post subject: 

He asked for it, I mean literally cause he thought it would be cool.
Anyway, is it possible to have the text in different colors?

Author:  SuperGenius [ Mon Mar 15, 2004 8:44 pm ]
Post subject: 

Jonos.... why would you ask for that? lol

by the way do you guys like these cars? becuase I think they rule.

Author:  Mazer [ Mon Mar 15, 2004 8:47 pm ]
Post subject: 

Oh come on, SuperGenius could you please stay on topic?

Author:  AsianSensation [ Mon Mar 15, 2004 8:48 pm ]
Post subject: 

don't particularly like the car, but I do like the fact that it says GTO (assuming GTO stands for Great Teacher Onizuka).

btw, -20 bits

told you to remain on topic.

Author:  jonos [ Mon Mar 15, 2004 9:07 pm ]
Post subject: 

you can't put colour to the text, unless you put it to wordpad and found a way to use tags or something to do that, using sgml or something like that.

wo wait, you could do it, you make it a .txt with html tags, and then copy it and make it an html document, and you could then do it!

Author:  SuperGenius [ Tue Mar 16, 2004 1:06 pm ]
Post subject: 

sorry for wandering... but this little app is reather neat.
My question is: Is there some practical application that it would have?
if no, why did you decide to make it?


: