Viewing .tga Images

I have a program the just views images, when it tries to view .tga files, it says it's out of memory.

Here is the simple code I have when it does this.

public partial class FormMain : Form
  {
    public FormMain()
    {
      InitializeComponent();
    }

    private void ButtonBrowse_Click(object sender, EventArgs e)
    {
      OpenFileDialogMain.ShowDialog();
    }

    private void OpenFileDialogMain_FileOk(object sender, CancelEventArgs e)
    {
      TextBoxImage.Text = OpenFileDialogMain.FileName;
      PictureBoxMain.Image = Image.FromFile(TextBoxImage.Text);
    }
  }


Answer this question

Viewing .tga Images

  • nonno

    Greg,
    this is the expected behaviour. Image.FromFile will throw an OutOfMemoryException when you try to use it with an image format, or a pixel format, it doesn't recognize. As far as I know, TGA is not supported directly.

    You may try with the FreeImage library, which includes a C# wrapper and supports TGA among the other formats.

    HTH
    --mc


  • Viewing .tga Images