/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose(bool disposing) { if (m_photoDescr != null) { m_photoDescr.releaseImage(); m_photoDescr = null; } pictureBox.Image = null; if (m_image != null) { m_image.Dispose(); m_image = null; } if (disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing); }
public static Image rebuildThumbnailImage(string thumbSource) { Image ret = null; if (thumbSource.ToLower().StartsWith("http://")) { // a gallery, and actual URL of the thumbnail ret = ImageCache.getImage(thumbSource, true); } else { // local file, containing large image. PhotoDescr pd = PhotoDescr.FromFileOrZipEntry(null, null, thumbSource, "none"); float imageRatio = (float)pd.image.Width / (float)pd.image.Height; float panelRatio = (float)Project.thumbWidth / (float)Project.thumbHeight; int thumbWidth; int thumbHeight; if (imageRatio > panelRatio) // image wider { thumbWidth = Project.thumbWidth; thumbHeight = (int)(thumbWidth / imageRatio); } else { thumbHeight = Project.thumbHeight; thumbWidth = (int)(thumbHeight * imageRatio); } // make a thumbnail bitmap: Bitmap thumb = new Bitmap(pd.image, new Size(thumbWidth, thumbHeight)); // the following produces ugly big unfocused thumbnail, so we stay with Bitmap for now: //Image thumb = photoDescr.image.GetThumbnailImage(Project.thumbWidth, Project.thumbHeight, null, IntPtr.Zero); // rotate thumbnail based on photoDescr.Orientation. switch (pd.Orientation) { // see PhotoDescr.cs for EXIF orientation codes: case 4: thumb.RotateFlip(RotateFlipType.Rotate180FlipNone); break; case 8: thumb.RotateFlip(RotateFlipType.Rotate270FlipNone); break; case 6: thumb.RotateFlip(RotateFlipType.Rotate90FlipNone); break; } if (thumbSource.IndexOf("|") != -1) { ImageCache.putImage(thumb, thumbSource, null, true); // zipfile - putImage() will generate local temp file } else { ImageCache.putImage(thumb, thumbSource, thumbSource, true); } ret = thumb; pd.releaseImage(); } return(ret); }