improved halftone functions

improved halftone functions  for adaptive image sizes