public Bitmap GetBackgroundImage() { Bitmap image = null; Graphics graphics; Rectangle bounds = this._homeScreen.Bounds; if (Settings.Default.UseBackgroundColor) { image = new Bitmap(bounds.Width, bounds.Height, PixelFormat.Format32bppArgb); using (graphics = Graphics.FromImage(image)) { graphics.Clear(Settings.Default.BackgroundColor); } return(image); } if (Settings.Default.UseBackgroundImage) { return(PhotoInfo.ConstrainSize((Bitmap)Image.FromFile(Settings.Default.BackgroundImage), bounds.Width, bounds.Height, false)); } image = new Bitmap(bounds.Width, bounds.Height, PixelFormat.Format32bppArgb); using (graphics = Graphics.FromImage(image)) { graphics.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy); } return(image); }
private void CreateSnapshotImage(PhotoInfo originalPhoto) { int height = (this.imageBuffer + this.imageHeight) + this.imageBuffer; int width = (this.imageBuffer + this.imageWidth) + this.imageBuffer; if (Settings.Default.RenderCaption) { height += this.imageBuffer * 3; } Bitmap bitmap = new Bitmap(width, height); Image image = PhotoInfo.ConstrainSize(originalPhoto.SourceBitmap, this.imageWidth, this.imageHeight, true); using (Graphics graphics = Graphics.FromImage(bitmap)) { PhotoInfo.SetDrawingQuality(graphics); graphics.Clear(Color.FromArgb(240, 240, 240)); graphics.DrawRectangle(new Pen(Brushes.Gray, 3f), 0, 0, bitmap.Width - 1, bitmap.Height - 1); switch (ExifSupport.GetExifShort(originalPhoto.SourceBitmap, 0x112, 1)) { case 3: image.RotateFlip(RotateFlipType.Rotate180FlipNone); break; case 6: image.RotateFlip(RotateFlipType.Rotate90FlipNone); break; case 8: image.RotateFlip(RotateFlipType.Rotate270FlipNone); break; } graphics.DrawImage(image, this.imageBuffer, this.imageBuffer); graphics.DrawRectangle(Pens.LightGray, this.imageBuffer, this.imageBuffer, this.imageWidth - 1, this.imageHeight - 1); if (Settings.Default.RenderCaption) { this.RenderCaption(originalPhoto, width, graphics); } } originalPhoto.SourceBitmap = null; originalPhoto.WorkingBitmap = bitmap; }