@name ImageDownloader
@inputs DI:wirelink
@outputs X Y C 
@persist [A A2 A3 A4]:array I X Y RGB Ix RGB2 I1 I2 I3 RGB3 On St TI TI2 TI3 Str:string URL:string IMG:string DIV
@trigger none
interval(1)
runOnHTTP(1)


if(first()){
    
    I=0
    St=0
    X=0
    Y=0
    I2=0

    #EDIT URL AND SIZE OF IMAGE 
    #EDIT URL AND SIZE OF IMAGE 
    #EDIT URL AND SIZE OF IMAGE 

    IMG="http://www.skyhippo.net/trollface.jpg"#png, gif and jpgs works
    DI[1048572]=512#width
    DI[1048573]=512#heigth

    #EDIT URL AND SIZE OF IMAGE 
    #EDIT URL AND SIZE OF IMAGE 
    #EDIT URL AND SIZE OF IMAGE 

    DI[1048574]=1
    DI[1048569]=2
}  


URL = "http://skyhippo.net/gmod.php?i="+IMG+""

if(changed(->DI)&->DI){
    httpRequest(URL)
}
if(httpClk()){
    Str = httpData()
    I2=1

}
if(I2&->DI){
    while(I<Str:length()*3&perf()){
        I+=3
        DI[I/3]=rgb2digi(vec(clamp(toByte(Str:index(I-2))+1,0,255),clamp(toByte(Str:index(I-1))+1,0,255),clamp(toByte(Str:index(I))+1,0,255)),2)
    }    
}  
