Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 text picture genereator
Index -> Programming, Turing -> Turing Submissions
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
zylum




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Mar 11, 2004 12:54 am   Post subject: (No 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
octopi




PostPosted: Thu Mar 11, 2004 1:16 am   Post subject: (No subject)

looks better if you change the
code:
"1"

to a

code:
" "


in your 'init' line
Paul




PostPosted: Thu Mar 11, 2004 4:51 pm   Post subject: (No 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)) ..

zylum




PostPosted: 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
Paul




PostPosted: Thu Mar 11, 2004 7:29 pm   Post subject: (No subject)

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




PostPosted: Fri Mar 12, 2004 12:45 am   Post subject: (No subject)

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




PostPosted: Fri Mar 12, 2004 12:58 am   Post subject: (No 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Delos




PostPosted: Fri Mar 12, 2004 1:03 pm   Post subject: (No 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...
SuperGenius




PostPosted: Mon Mar 15, 2004 3:09 pm   Post subject: (No 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?
octopi




PostPosted: Mon Mar 15, 2004 3:10 pm   Post subject: (No subject)

Its cause jonos is a LAMER
Cervantes




PostPosted: Mon Mar 15, 2004 7:57 pm   Post subject: (No 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....
SuperGenius




PostPosted: Mon Mar 15, 2004 8:40 pm   Post subject: (No subject)

octopi wrote:
Its cause jonos is a LAMER


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




PostPosted: Mon Mar 15, 2004 8:42 pm   Post subject: (No subject)

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




PostPosted: Mon Mar 15, 2004 8:43 pm   Post subject: (No 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?
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 20 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: