2. Given that the longest diagonal of a regular octagon is equal to $a$, and the shortest diagonal is equal to $b$. Then the area of this regular octagon is ( ).
(A) $a^{2}+b^{2}$
(B) $a^{2}-b^{2}$
(C) $a+b$
(D) $a b$
2. D.

As shown in Figure 3, in the regular octagon, the longest diagonal is
$$
\begin{array}{c}
A E=B F=C G \\
=D H=a,
\end{array}
$$

the shortest diagonal is
$$
\begin{array}{l}
A C=B D=C E \\
=D F=E G=F H \\
=G A=H B=b .
\end{array}
$$

By cutting and rearranging as shown in Figure 3, we get
$$
S_{\text {regular octagon } A B C D E F G H}=S_{\text {quadrilateral } P Q M N}=a b \text {. }
$$