Added sparsity and width calculation to createFromBitmap