Rerolling items
3 Perfect Gems (any type and mixture) + Magic Item (any type) --> New Magic Item (of the same type)
Monster drops: ilvl = mlvl (monster level).
Gambled items: ilvl = clvl - 5 + rnd(10) (character level). That is, from clvl - 5 to clvl + 4, uniformly distributed (10 % chance of each).
The ilvl of gambled items is capped below at 5 and above at 99.
The results of gambling are unaffected by vendor. Gamble in Hell.
Shopped items: ilvl = clvl + 5 (character level). Shopping Calculator:
http://members.iinet.net.au/~dcarson/shopcalc.html