Macro-fu to simplify repetitive switch statements in imagebufalgo.cpp