Calculating minimal rectangle set to cover a bitmap