Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS 

Compare two bitmap objects

        private bool PicsIdentical(Bitmap bmp1, Bitmap bmp2)
        {
            bool retVal = true;

            if (bmp1.Size != bmp2.Size)
                retVal = false;
            else
            {
                for (int x = 0; x < bmp1.Width; x++)
                {
                    for (int y = 0; y < bmp1.Height; y++)
                    {
                        if (bmp1.GetPixel(x, y) != bmp2.GetPixel(x, y))
                        {
                            retVal = false;
                            break;
                        }
                    }
                }
            }
            return retVal;
        }

Is a value between two other values?

between?: func [
    value bound-1 bound-2
    /exclusive
    /local low-bound high-bound
][
    set [low-bound high-bound] sort reduce [bound-1 bound-2]
    either exclusive [
        all [(value > low-bound) (value < high-bound)]
    ][
        ;-- Inclusive comparison
        all [(value >= low-bound) (value <= high-bound)]
    ]
]

Compare two files

    compare: func [a b /binary] [
        a: checksum either binary [read/binary a] [read a]
        b: checksum either binary [read/binary b] [read b]
        equal? a b
    ]
« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS