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

puts "img::tga [package require img::tga]"

set tgadata \
{AAAKAAAAAAAAAAAAUgAMACAg0d/b3/8A39vf/4kAAAD/iP////8AAAAA/4gAAP//AAAAAP+I
AP8A/wAAAAD/iP8AAP8AAAAA/4j//wD/AAAAAP+I/wD//wAAAAD/iAD///8BAAAA/9/b3/8A
39vf/4kAAAD/iP////8AAAAA/4gAAP//AAAAAP+IAP8A/wAAAAD/iP8AAP8AAAAA/4j//wD/
AAAAAP+I/wD//wAAAAD/iAD///8BAAAA/9/b3/8A39vf/4kAAAD/iP////8AAAAA/4gAAP//
AAAAAP+IAP8A/wAAAAD/iP8AAP8AAAAA/4j//wD/AAAAAP+I/wD//wAAAAD/iAD///8BAAAA
/9/b3/8A39vf/4kAAAD/iP////8AAAAA/4gAAP//AAAAAP+IAP8A/wAAAAD/iP8AAP8AAAAA
/4j//wD/AAAAAP+I/wD//wAAAAD/iAD///8BAAAA/9/b3/8A39vf/4kAAAD/iP////8AAAAA
/4gAAP//AAAAAP+IAP8A/wAAAAD/iP8AAP8AAAAA/4j//wD/AAAAAP+I/wD//wAAAAD/iAD/
//8BAAAA/9/b3/8A39vf/4kAAAD/iP////8AAAAA/4gAAP//AAAAAP+IAP8A/wAAAAD/iP8A
AP8AAAAA/4j//wD/AAAAAP+I/wD//wAAAAD/iAD///8BAAAA/9/b3/8A39vf/4kAAAD/iP//
//8AAAAA/4gAAP//AAAAAP+IAP8A/wAAAAD/iP8AAP8AAAAA/4j//wD/AAAAAP+I/wD//wAA
AAD/iAD///8BAAAA/9/b3/8A39vf/4kAAAD/iP////8AAAAA/4gAAP//AAAAAP+IAP8A/wAA
AAD/iP8AAP8AAAAA/4j//wD/AAAAAP+I/wD//wAAAAD/iAD///8BAAAA/9/b3/8A39vf/4kA
AAD/iP////8AAAAA/4gAAP//AAAAAP+IAP8A/wAAAAD/iP8AAP8AAAAA/4j//wD/AAAAAP+I
/wD//wAAAAD/iAD///8BAAAA/9/b3/8A39vf/88AAAD/AN/b3//R39vf/w==}


test tga-1.1 {} {
    catch {image delete i}
    image create photo i -file [file join $tcltest::testsDirectory 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 [file join $tcltest::testsDirectory hori.tga] r]
    fconfigure $f -translation binary
    set return [catch {i put [read $f]} msg]
    close $f
    lappend return $msg
} {0 {}}
