# This file is a Tcl script to test out TGA reading and writing.
# It is organized in the standard fashion for Tcl tests.
#

if {[string compare test [info procs test]] == 1} {
    source defs
}

set tgadata \
{AAAKAAAAAAAAAAAAUgAMABgg0d/b3wDf29+JAAAAiP///wAAAACIAAD/AAAAAIgA/wAAAAAA
iP8AAAAAAACI//8AAAAAAIj/AP8AAAAAiAD//wEAAADf298A39vfiQAAAIj///8AAAAAiAAA
/wAAAACIAP8AAAAAAIj/AAAAAAAAiP//AAAAAACI/wD/AAAAAIgA//8BAAAA39vfAN/b34kA
AACI////AAAAAIgAAP8AAAAAiAD/AAAAAACI/wAAAAAAAIj//wAAAAAAiP8A/wAAAACIAP//
AQAAAN/b3wDf29+JAAAAiP///wAAAACIAAD/AAAAAIgA/wAAAAAAiP8AAAAAAACI//8AAAAA
AIj/AP8AAAAAiAD//wEAAADf298A39vfiQAAAIj///8AAAAAiAAA/wAAAACIAP8AAAAAAIj/
AAAAAAAAiP//AAAAAACI/wD/AAAAAIgA//8BAAAA39vfAN/b34kAAACI////AAAAAIgAAP8A
AAAAiAD/AAAAAACI/wAAAAAAAIj//wAAAAAAiP8A/wAAAACIAP//AQAAAN/b3wDf29+JAAAA
iP///wAAAACIAAD/AAAAAIgA/wAAAAAAiP8AAAAAAACI//8AAAAAAIj/AP8AAAAAiAD//wEA
AADf298A39vfiQAAAIj///8AAAAAiAAA/wAAAACIAP8AAAAAAIj/AAAAAAAAiP//AAAAAACI
/wD/AAAAAIgA//8BAAAA39vfAN/b34kAAACI////AAAAAIgAAP8AAAAAiAD/AAAAAACI/wAA
AAAAAIj//wAAAAAAiP8A/wAAAACIAP//AQAAAN/b3wDf29/PAAAAAN/b39Hf298=}


test tga-1.1 {} {
    catch {image delete i}
    image create photo i -file hori.tga
    i data -format tga
} $tgadata
test tga-1.2 {} {
    catch {image delete i}
    image create photo i -data $tgadata
    set data [i data -format tga]
} $tgadata
test tga-1.3 {} {
    i blank
    i put $tgadata
    set data [i data -format tga]
} $tgadata
test tga-1.4 {} {
    i blank
    i put $tgadata -format tga
    set data [i data -format tga]
} $tgadata
if {[info tclversion] < 8.0} {
    return
}

test tga-2.0 {Binary I/O with TGA images} {
    i blank
    set f [open hori.tga r]
    fconfigure $f -translation binary
    set return [catch {i put [read $f]} msg]
    close $f
    lappend return $msg
} {0 {}}
