In short, this can't be done.
In long, if fogfactor = 0..1, alpha = 0..1
if you just go setalpha( alpha ) for the image and setalpha( fogfactor * alpha) for the fog, the total alpha applied is fogfactor * alpha^2. You want to solve for:
useralpha = drawalpha^2 * fogfactor
or drawalpha = Sqr( useralpha / fogfactor )
That will get the alpha values correct, but not the result you're looking for (at least not perfect).
At least I think that is right, I haven't tested it.
In long, if fogfactor = 0..1, alpha = 0..1
if you just go setalpha( alpha ) for the image and setalpha( fogfactor * alpha) for the fog, the total alpha applied is fogfactor * alpha^2. You want to solve for:
useralpha = drawalpha^2 * fogfactor
or drawalpha = Sqr( useralpha / fogfactor )
That will get the alpha values correct, but not the result you're looking for (at least not perfect).
At least I think that is right, I haven't tested it.