private void DrawThumbnailImage(Graphics graphics, Tile tile) { if (tile.Thumbnail != null) { lock (tile.ThumbnailLock) { //tile.Thumbnail.ConvertToStandardType(); FreeImageAlgorithmsBitmap thumb = new FreeImageAlgorithmsBitmap(tile.Thumbnail); if (thumb.IsGreyScale) { thumb.LinearScaleToStandardType( mosaicInfo.ThumbnailScaleMinIntensity, mosaicInfo.ThumbnailScaleMaxIntensity); thumb.SetGreyLevelPalette(); } if (thumb.ImageType != FREE_IMAGE_TYPE.FIT_BITMAP) { MessageBox.Show("Failed to convert tile thumbnail to a standard type ?"); } graphics.DrawImage(thumb.ToBitmap(), tile.Bounds); thumb.Dispose(); } } /* * if (this.ShowFileNames) * { * // Create font and brush. * Font drawFont = new Font("Arial", 16); * SolidBrush drawBrush = new SolidBrush(Color.Black); * * Point location = new Point(tile.Bounds.Location.X + 100, tile.Bounds.Location.Y + 100); * * SizeF size = graphics.MeasureString(tile.FileName, drawFont); * * Brush brush = new SolidBrush(Color.FromArgb(50, Color.Gray)); * * graphics.FillRectangle(brush, location.X - 2, location.Y - 2, * size.Width + 4, size.Height + 4); * * graphics.DrawString(tile.FileName, drawFont, drawBrush, * new PointF(location.X, location.Y)); * } */ if (this.ShowJoins) { Pen pen = new Pen(Color.Red, 2.0f); graphics.DrawRectangle(pen, tile.Bounds); } }
private void OnTileCorrelated(CorrelationTile tile, Rectangle bounds, FreeImageAlgorithmsBitmap fib, bool success) { this.tiledImageViewer.AddTile(bounds, fib); this.tiledImageViewer.Refresh(); #if DEBUG if (success == false) { FreeImageAlgorithmsBitmap bg = new FreeImageAlgorithmsBitmap(this.correlator.BackgroundImage); bg.ConvertTo24Bits(); bg.DrawColourRect(tile.OriginalBoundsRelativeToOrigin, Color.Red, 2); this.debugForm.BackgroundImageView.Image = bg.ToBitmap(); bg.Dispose(); } this.debugForm.Refresh(); #endif }
private void OnTileCorrelationBegin(CorrelationTile tile, FreeImageAlgorithmsBitmap fib) { this.useCorrelationCheckBox.Checked = false; this.currentTile = tile; #if DEBUG FreeImageAlgorithmsBitmap fg = new FreeImageAlgorithmsBitmap(fib); fg.ConvertToStandardType(true); fg.ConvertTo24Bits(); this.debugForm.TileImageView.Image = fg.ToBitmap(); this.debugForm.BackgroundImageView.Refresh(); this.debugForm.TileImageView.Refresh(); fg.Dispose(); #endif }
public FreeImageAlgorithmsWPFImage(string filepath) : base() { this.FilePath = filepath; try { this.Fib = Tile.LoadFreeImageBitmapFromFile(filepath); } catch (Exception e) { throw; } ThumbnailFib = new FreeImageAlgorithmsBitmap(this.Fib); Tile.ResizeToThumbnail(ThumbnailFib); if (ThumbnailFib.IsGreyScale) { ThumbnailFib.LinearScaleToStandardType(0, 0); } else { ThumbnailFib.ConvertToStandardType(true); } Bitmap bitmap = ThumbnailFib.ToBitmap(); System.Windows.Int32Rect rect = new System.Windows.Int32Rect(); rect.X = 0; rect.Y = 0; rect.Width = bitmap.Width; rect.Height = bitmap.Height; this.Source = ConvertGdiToWPF(bitmap, rect); }