# utils.tcl --
#
#       This file contains utilities to use in combination with
#       the test suite of imgtools
#
# Copyright (c) 2016 by Simon Bachmann <simonbachmann@bluewin.ch>
# All rights reserved.
#
# Permission is hereby granted, without written agreement and without
# license or royalty fees, to use, copy, modify, and distribute this
# software and its documentation for any purpose, provided that the
# above copyright notice and the following two paragraphs appear in
# all copies of this software.
# 

namespace eval ::imgtools::test {
    
}

# imagesAreEqual --
#
#       Tests if two images are identical
#       Not used anymore - we have C versoin thath compares alpha too.
# 
# Result:
#       1 if images are equal, 0 if the differ
#
# Side Effects:
#       none
#
# Warning: does not check the alpha channel (cannot do that 
# at script level)
#
if 0 {
proc ::imgtools::test::imagesAreEqual {srcImg destImg} {
# srcImg, destImg:  existing images to compare    
    if {[image width $srcImg] != [image width $destImg || [image height $srcImg] != [image height $destImg]} {
        return 0
    }
    
    set result 1
    for {set x 0} {$x < [image width $srcImg]} {incr x} {
        for {set y 0} {$y < [image height $srcImg]} {incr y} {
            if {[$srcImg get $x $y] ne [$destImg get $x $y]} {
                set result 0
                set x [image width $srcImg]
                break
            }
        }
    }
    return $result
}
}
