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

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

set sgidata \
{AdoBAQADABAADAADAAAAAAAAAP8AAAAAbm8gbmFtZQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARAAAAEJQAABAoAAAPvAAAD1AAAA7kAAAOe
AAADgwAAA3QAAANWAAADNQAAAyAAAARFAAAELgAABBMAAAP4AAAD3QAAA8IAAAOnAAADjAAA
A3kAAANgAAADQAAAAycAAARKAAAENwAABBwAAAQBAAAD5gAAA8sAAAOwAAADlQAAA34AAANq
AAADSwAAAy4AAAAFAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAUAAAAKAAAACwAA
AAcAAAAFAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAUAAAAKAAAACwAAAAcAAAAF
AAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAUAAAAKAAAACwAAAAcD2QQACdkAA9kE
AAnZAAPZBAAJ2QCD2dkABPCBAAjZAIPZ2QAE/4EACNkAg9nZAASAgQAI2QCC2QAG8IEAB9kA
gtkABv+BAAfZAILZAAaAgQAH2QANAAPZAA0AA9kADQAD2QCBAAvwgQAD2QCBAAv/gQAD2QCB
AAuAgQAD2QCBAAvwgQAD2QCBAAv/gQAD2QCBAAuAgQAD2QCBAAvwgQAD2QCBAAv/gQAD2QCB
AAuAgQAD2QCBAAvwgQAD2QCBAAv/gQAD2QCBAAuAgQAD2QCBAAvwgQAD2QCBAAv/gQAD2QCB
AAuAgQAD2QCBAAvwgQAD2QCBAAv/gQAD2QCBAAuAgQAD2QCBAAvwgQAD2QCBAAv/gQAD2QCB
AAuAgQAD2QANAAPZAA0AA9kADQAD2QA=}

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