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

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

set sgidata \
{AdoBAQADABAADAAEAAAAAAAAAP8AAAAAbm8gbmFtZQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATBAAAEowAABIUAAARnAAAESQAABCsAAAQN
AAAD7wAAA90AAAO8AAADmAAAA4AAAATGAAAErAAABI4AAARwAAAEUgAABDQAAAQWAAAD+AAA
A+IAAAPGAAADowAAA4cAAATLAAAEtQAABJcAAAR5AAAEWwAABD0AAAQfAAAEAQAAA+cAAAPQ
AAADrgAAA44AAATQAAAEvgAABKAAAASCAAAEZAAABEYAAAQoAAAECgAAA+wAAAPaAAADuQAA
A5UAAAAFAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAUAAAAKAAAACwAAAAcAAAAF
AAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAUAAAAKAAAACwAAAAcAAAAFAAAACQAA
AAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAUAAAAKAAAACwAAAAcAAAADAAAAAwAAAAMAAAAD
AAAAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAMD2QQACdkAA9kEAAnZAAPZBAAJ2QAQ
/wCD2dkABPCBAAjZAIPZ2QAE/4EACNkAg9nZAASAgQAI2QAQ/wCC2QAG8IEAB9kAgtkABv+B
AAfZAILZAAaAgQAH2QAQ/wANAAPZAA0AA9kADQAD2QAQ/wCBAAvwgQAD2QCBAAv/gQAD2QCB
AAuAgQAD2QAQ/wCBAAvwgQAD2QCBAAv/gQAD2QCBAAuAgQAD2QAQ/wCBAAvwgQAD2QCBAAv/
gQAD2QCBAAuAgQAD2QAQ/wCBAAvwgQAD2QCBAAv/gQAD2QCBAAuAgQAD2QAQ/wCBAAvwgQAD
2QCBAAv/gQAD2QCBAAuAgQAD2QAQ/wCBAAvwgQAD2QCBAAv/gQAD2QCBAAuAgQAD2QAQ/wCB
AAvwgQAD2QCBAAv/gQAD2QCBAAuAgQAD2QAQ/wANAAPZAA0AA9kADQAD2QAQ/wA=}

test sgi-1.1 {} {
    catch {image delete i}
    image create photo i -file [file join $tcltest::testsDirectory folder.rgb]
    i data -format sgi
} $sgidata
test sgi-1.2 {} {
    catch {image delete i}
    image create photo i -data $sgidata
    set data [i data -format sgi]
} $sgidata
test sgi-1.3 {} {
    i blank
    i put $data
    set data [i data -format sgi]
} $sgidata
test sgi-1.4 {} {
    i blank
    i put $data -format sgi
    set data [i data -format sgi]
} $sgidata

if {[info tclversion] < 8.0} {
    return
}


test sgi-2.0 {Binary I/O with SGI images} {
    i blank
    set f [open [file join $tcltest::testsDirectory folder.rgb] r]
    fconfigure $f -translation binary
    set return [catch {i put [read $f]} msg]
    close $f
    lappend return $msg
} {0 {}}
