Ejemplo n.º 1
0
        /// <summary>
        /// Dispose(bool disposing) executes in two distinct scenarios.
        /// If disposing equals true, the method has been called directly
        /// or indirectly by a user's code. Managed and unmanaged resources
        /// can be disposed.
        /// If disposing equals false, the method has been called by the 
        /// runtime from inside the finalizer and you should not reference 
        /// other objects. Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing">If true dispose all resources, else dispose only release unmanaged resources.</param>
        protected virtual void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!this.disposed)
            {
                // If disposing equals true, dispose all managed
                // and unmanaged resources.
                if (disposing)
                {
                    // Dispose managed resources.
                    if (this.bmpTargaImage != null)
                    {
                        this.bmpTargaImage.Dispose();
                    }

                    if (this.bmpImageThumbnail != null)
                    {
                        this.bmpImageThumbnail.Dispose();
                    }

                    if (this.ImageByteHandle != null)
                    {
                        if (this.ImageByteHandle.IsAllocated)
                        {
                            this.ImageByteHandle.Free();
                        }

                    }

                    if (this.ThumbnailByteHandle != null)
                    {
                        if (this.ThumbnailByteHandle.IsAllocated)
                        {
                            this.ThumbnailByteHandle.Free();
                        }

                    }

                    if (this.objTargaHeader != null)
                    {
                        objTargaHeader.ColorMap.Clear();
                        objTargaHeader = null;
                    }
                    if (this.objTargaExtensionArea != null)
                    {
                        objTargaExtensionArea.ColorCorrectionTable.Clear();
                        objTargaExtensionArea.ScanLineTable.Clear();
                        objTargaExtensionArea = null;
                    }

                    objTargaFooter = null;

                }
                // Release unmanaged resources. If disposing is false,
                // only the following code is executed.
                // ** release unmanged resources here **

                // Note that this is not thread safe.
                // Another thread could start disposing the object
                // after the managed resources are disposed,
                // but before the disposed flag is set to true.
                // If thread safety is necessary, it must be
                // implemented by the client.

            }
            disposed = true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Clears out all objects and resources.
        /// </summary>
        private void ClearAll()
        {
            if (this.bmpTargaImage != null)
            {
                this.bmpTargaImage.Dispose();
                this.bmpTargaImage = null;
            }

            if (this.bmpImageThumbnail != null)
            {
                this.bmpImageThumbnail.Dispose();
                this.bmpImageThumbnail = null;
            }

            if (this.ImageByteHandle != null && this.ImageByteHandle.IsAllocated)
                this.ImageByteHandle.Free();

            if (this.ThumbnailByteHandle != null && this.ThumbnailByteHandle.IsAllocated)
                this.ThumbnailByteHandle.Free();

            this.objTargaHeader = new TargaHeader();
            this.objTargaExtensionArea = new TargaExtensionArea();
            this.objTargaFooter = new TargaFooter();
            this.eTGAFormat = TGAFormat.UNKNOWN;
            this.intStride = 0;
            this.intPadding = 0;
            this.strFileName = string.Empty;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new instance of the TargaImage object.
 /// </summary>
 public TargaImage()
 {
     this.objTargaFooter = new TargaFooter();
     this.objTargaHeader = new TargaHeader();
     this.objTargaExtensionArea = new TargaExtensionArea();
     this.bmpTargaImage = null;
     this.bmpImageThumbnail = null;
 }