From the Super Mario Wiki, the Mario encyclopedia
In Luigi's Mansion, King Boo sends Mario and Luigi an invitation to Luigi's new house. Mario arrives first in an attempt to welcome Luigi, only to be caught by Boos while walking in. King Boo traps Mario in the painting and rests in the Storage Room until Luigi releases him and his minions. Upon being released, King Boo watched over Mario in the Secret Altar, hoping no one rescues Mario and to trap Luigi as well. Upon Luigi's arrival at the altar, King Boo turns Mario into Bowser, which inhales Luigi inside.
After Luigi captures King Boo, he escapes the painting, grabs Mario, and heads to the lab. Using the Ghost Portrificationizer, he reverts Mario back to normal (but in a rather comical yet painful overwhelming way); afterwards, Mario is left very dizzy while Luigi laughs very tearfully that Mario is safe.
Luigi's Mansion: Dark Moon
In Luigi's Mansion: Dark Moon, after destroying the Dark Moon, King Boo captures Mario once more, but puts him in a "still-image" painting instead, so he wouldn't listen to Mario crying for help. Mario remains this way until Luigi reverts him back using the Dark-Light Device, where he thanks him and calls him "Number 1".
Throughout the game, the Security Images show part of Mario's painting in a sack guarded by Boos. In the Haunted Towers (B-4) and Secret Mine (D-2), his shoes are seen, and in the Old Clockworks (3-Boss), his hat is seen. The Treacherous Mansion exposes Mario's full painting (E-3).
Luigi's Mansion 3
In Luigi's Mansion 3, King Boo traps Mario in a painting again, along with Princess Peach and the Toads. Mario's painting is found before the final boss with King Boo, and Luigi must free him using the Dark-Light Device.