I'd suggest you start with this CodeProject article "Fast Optimizing Rectangle Packing Algorithm for Building CSS Sprites" by Matt Perdeck: [
^]. The article contains a good overview of the packing problem, and goes on to develop, and improve, an algorithm.
The "Nuclex" rectangle packing algorithms by Kossovsky Alexander are, also, probably good resources for you, and you can read about them, and download C# source, here: [
^].
Kossovsky provides three different packing algorithms. His code is licensed under the IBM Public License, and uses the Microsoft XNA FrameWork.