To accommodate the latest head:

double sx = ((double)s.nAutoFitFactor / 100.0 * (double)width - decorationsSize.cx) / (double)arxy.cx;
double sy = ((double)s.nAutoFitFactor / 100.0 * (double)height - decorationsSize.cy) / (double)arxy.cy;