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

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

catch {image delete i}

set pngdata \
{iVBORw0KGgoAAAANSUhEUgAAABAAAAAMCAYAAAEc4A0XAAAABGdBTUEAAYagMeiWXwAAAJlJ
REFUKJGlkcsRgzAMRJ8yNMI9BVAEqohzKlqKoADulKIcEnuwIXgyvJM/611JNkkBYEBsMXwW
kmCLIYDIVwC9LZikcHckAWBfKQDrPPGgwiTFc3zlg96W/LzIr0nCg+VphLsDFNY/I9Z5KgX7
NvYkYbOG+wJLH+Lu1POoh3ZqAJw2ccXetAMOyVf0thT7Zo8tbht0cCzrH95fqko+eQjtmAAA
AABJRU5ErkJggg==}

test png-1.1 {} {
    image create photo i -file folder.png
    i data -format png
} $pngdata
test png-1.2 {} {
    catch {image delete i}
    image create photo i -data $pngdata
    set data [i data -format png]
} $pngdata
test png-1.3 {} {
    i blank
    i put $data
    set data [i data -format png]
} $pngdata
test png-1.4 {} {
    i blank
    i put $data -format png
    set data [i data -format png]
} $pngdata

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

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

