Added ResizeToLongEdge function

and fixed bug in resizing which allowed a bitmap to get freed before it
should have