[PATCH v4 2/2] gdiplus: Move Flatten() tests into the same function