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

Username:   Password: 
 RegisterRegister   
 View Online Images
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ecliptical




PostPosted: Wed Dec 21, 2005 4:03 am   Post subject: View Online Images

This only works with JPEGS (as the current Turing only supports JPEGS however Turing 4.1 does support animated GIF's! So maybe I'll create something similair when that version becomes available.

Usage: IMGSRC ("fileName",scale,"alt")

Bugs: For some reason images above 1KB come out looking like this.
My Best guess would be that a couple of bits/bites are lost along the way...
Posted Image, might have been reduced in size. Click Image to view fullscreen.

Turing Bug: Trying to do a OpenURLConnection -> www.google.com WILL crash your Turing or at least did crash mine.


code:
procedure IMGSRC (url : string, x,y,scale : int, alt : string)
    var netStream : int
    var net_line : char
    netStream := Net.OpenURLConnection (url)
    if netStream <= 0 then
        put "Unable to download jpeg ", url, "!"
        return
    end if
    var fileNo : int
    open : fileNo, "render.jpg", write
    loop
        exit when eof (netStream)
        get : netStream, net_line
        write : fileNo, net_line
    end loop
    Net.CloseConnection (netStream)
    close : fileNo
    var newPic : int
    newPic := Pic.FileNew ("render.jpg")
    var width : int := Pic.Width (newPic)
    var height : int := Pic.Height (newPic)
    newPic := Pic.Scale (newPic, scale * width,
        scale * height)

    Pic.Draw (newPic, x, y, picCopy)
    Pic.Free (newPic)
end IMGSRC


Future

/*You probably want to change this address to something on your server ... also note that I have used my IP->~path to my site (www.eclipticalmedia.net) because there is a small redireciton issue with some sites that you will encounter....*/
IMGSRC ("http://72.29.76.231/~eclipti/turing/picture.jpg", 0,0,2, "")



[list=]
Fix Large Image Error: This could be Turing, Net, or Jpeg compression method but probably Net.

Loading Place Holder: Getting bigger images takes a bit...some sort of loader might be nice...




[/list]
Sponsor
Sponsor
Sponsor
sponsor
ecliptical




PostPosted: Wed Dec 21, 2005 4:13 am   Post subject: side note...

On a side note the resulting "effect" turing creates would take a long time to re-create in say photoshop so if I can't fix it...i'll just rename this procedure

AntiPornNetFilter
Tony




PostPosted: Wed Dec 21, 2005 10:14 am   Post subject: (No subject)

the problem might be that you're geting the content
code:

get : netStream, net_line

instead of binary read. Some information could be lost in the conversion back and forth. Try experimenting with a binary read.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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 1  [ 3 Posts ]
Jump to:   


Style:  
Search: