Example #1
0
        /// <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)
        {
            Bitmap b = null;
            using (TargaImage ti = new TargaImage(sFileName))
            {
                b = new Bitmap(ti.Image);
            }

            return b;
        }
Example #2
0
        private void PreviewTex(ZipReader.ZipEntryFull ent, bool dds)
        {
            try
            {
                Bitmap img;
                if (dds)
                {
                    byte[] data = ent.Extract(true);
                    if (data == null)
                        throw new NullReferenceException("Data returned was null");

                    using (ImageEngineImage ddsimg = new ImageEngineImage(data))
                        img = ddsimg.GetGDIBitmap(true);
                }
                else
                {
                    ent.Extract(false, "preview.tga");
                    img = new TargaImage("preview.tga").Image;
                    File.Delete("preview.tga");
                }
                if (pictureBox1.Image != null)
                    pictureBox1.Image.Dispose();

                if (_resize)
                    pictureBox1.Image = resizeImage(img, new System.Drawing.Size(512, 512));
                else
                    pictureBox1.Image = img;
                pictureBox1.Visible = true;
                pictureBox1.Refresh();
            }
            catch (Exception exc)
            {
                MessageBox.Show("An error occurred: " + exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }