/// <summary>
 /// Loads a stream with Targa image data into a Bitmap object.
 /// </summary>
 /// <param name="sFileName">The Targa image stream</param>
 /// <returns>A Bitmap object with the Targa image loaded into it.</returns>
 public static Bitmap LoadTargaImage(Stream ImageStream)
 {
     using (TargaImage ti = new TargaImage(ImageStream))
     {
         return CopyToBitmap(ti);
     }
 }
 private static Bitmap CopyToBitmap(TargaImage ti)
 {
     Bitmap b = null;
     if (ti.Image.PixelFormat == PixelFormat.Format8bppIndexed)
     {
         b = (Bitmap)ti.Image.Clone();
     }
     else
     {
         b = new Bitmap(ti.Image.Width, ti.Image.Height, ti.Image.PixelFormat);
         using (Graphics g = Graphics.FromImage(b))
         {
             g.DrawImage(ti.Image, 0, 0, new Rectangle(0, 0, b.Width, b.Height), GraphicsUnit.Pixel);
         }
     }
     return b;
 }
 /// <summary>
 /// Loads a Targa image file into a Bitmap object.
 /// </summary>
 /// <param name="sFileName">The Targa image filename</param>
 /// <returns>A Bitmap object with the Targa image loaded into it.</returns>
 public static Bitmap LoadTargaImage(string sFileName)
 {
     using (TargaImage ti = new TargaImage(sFileName))
     {
         return CopyToBitmap(ti);
     }
 }