public static void PasteTile(FreeImageAlgorithmsBitmap dst, FreeImageAlgorithmsBitmap src, Point location, bool blending) { if (blending) { if (!dst.GradientBlendPasteFromTopLeft(src, location)) { string errorStr = String.Format( "Can not paste freeimage. Dst image bpp {0}, Src image bpp {1}", dst.ColorDepth, src.ColorDepth); throw new FormatException(errorStr); } } else { if (!dst.PasteFromTopLeft(src, location)) { string errorStr = String.Format( "Can not paste freeimage. Dst image bpp {0}, Src image bpp {1}", dst.ColorDepth, src.ColorDepth); throw new FormatException(errorStr); } } }
public static int guessFibMaxValue(FreeImageAlgorithmsBitmap fib) { uint bpp = FreeImage.GetBPP(fib.Dib); FREE_IMAGE_TYPE type = FreeImage.GetImageType(fib.Dib); double min, max; if (bpp == 8) { return(256); } if (bpp >= 24 && type == FREE_IMAGE_TYPE.FIT_BITMAP) // colour image { return(256); } fib.FindMinMaxIntensity(out min, out max); if (max < 256) // 8 bit { return(256); } if (max < 4096) // 12 bit { return(4096); } if (max < 65536) // 16 bit { return(65536); } return(100000); // who knows! }
public void CreateOverview() { float aspectRatio = (float)(MosaicWindow.MosaicInfo.TotalWidth) / MosaicWindow.MosaicInfo.TotalHeight; // Largest dimension should be 300 pixels if (MosaicWindow.MosaicInfo.TotalWidth >= (MosaicWindow.MosaicInfo.TotalHeight)) { this.scaledWidth = Math.Min(MosaicWindow.MosaicInfo.TotalWidth, 300); this.scaledHeight = (int)(this.scaledWidth / aspectRatio + 0.5); } else { this.scaledHeight = Math.Min(MosaicWindow.MosaicInfo.TotalHeight, 300); this.scaledWidth = (int)(this.scaledHeight * aspectRatio + 0.5); } this.scaledImage = new FreeImageAlgorithmsBitmap(this.scaledWidth, this.scaledHeight, MosaicWindow.MosaicInfo.ColorDepth); // int xBorderSize = this.Size.Width - this.ClientRectangle.Width; // int yBorderSize = this.Size.Height - this.ClientRectangle.Height; this.bitmap = new FreeImageAlgorithmsBitmap(this.scaledWidth, this.scaledHeight, 24); this.Size = new Size(this.scaledWidth, this.scaledHeight); this.threadController.ThreadStart("TileOverview", new ThreadStart(this.ThreadCreateOverview)); }
public void AddTile(Rectangle bounds, FreeImageAlgorithmsBitmap fib) { if (fib == null) { return; } try { Rectangle imageBounds = TranslateVirtualRectangleToImageRectangle(bounds); if (this.xScaleFactor < 1.0f || this.yScaleFactor < 1.0f) { fib.Rescale(imageBounds.Size, FREE_IMAGE_FILTER.FILTER_BILINEAR); } fib.ConvertToStandardType(true); if (this.forceGreyscale && !fib.IsGreyScale) { fib.ConvertToGreyscale(); } this.image.PasteFromTopLeft(fib, imageBounds.Location, this.blending); } catch (Exception e) { MessageBox.Show(e.Message); } }
public static FreeImageAlgorithmsBitmap LoadFreeImageBitmapFromFile(string filepath) { // This method is independant of Tile IcsFile icsFile; FreeImageAlgorithmsBitmap fib = null; try { if (IcsFile.IsIcsFile(filepath)) { icsFile = new IcsFile(filepath); fib = icsFile.FreeImageAlgorithmsBitmap; icsFile.Close(); } else { fib = new FreeImageAlgorithmsBitmap(filepath); } } catch (Exception e) { throw; } // Resample seems to only work for uint16 not int16 currently if (fib.ImageType == FREE_IMAGE_TYPE.FIT_INT16) { fib.ConvertInt16ToUInt16(); } return(fib); }
public ThumbnailMap(int thumbnailWidth, int thumbnailHeight, Stream imageStream) { this.thumbnailWidth = thumbnailWidth; this.thumbnailHeight = thumbnailHeight; // Create Large Bitmap to hold all the thumbnals this.bmp = new FreeImageAlgorithmsBitmap(imageStream, FREE_IMAGE_FORMAT.FIF_BMP); }
public FreeImageAlgorithmsBitmap GetImage(int position) { Point pt = this.RealPosition(position); FreeImageAlgorithmsBitmap fib = this.bmp.Copy(pt.X, pt.Y, pt.X + this.thumbnailWidth - 1, pt.Y + this.thumbnailHeight - 1); return(fib); }
private void CreateCurveForGreylevelImageLineData(Point start, Point end) { TileView viewer = this.mosaicWindow.TileView; List <Tile> tiles = viewer.GetVisibleTiles(); if (tiles == null) { return; } if (MosaicWindow.MosaicInfo.ColorDepth >= 24) { return; } int max_pixels = Math.Abs((end.X - start.X)) + Math.Abs((end.Y - start.Y)); double[] values = new double[max_pixels]; int len = 0; foreach (Tile tile in tiles) { if (tile.IsDummy) { continue; } FreeImageAlgorithmsBitmap dib = tile.LoadFreeImageBitmap(); len = dib.GetGreyScalePixelValuesAsDoublesForLine(start, end, out values); dib.Dispose(); } PointPairList list = new PointPairList(); double x, y; for (int i = 0; i < len; i++) { x = (double)i; y = (double)values[i]; list.Add(x, y); } if (this.curve != null) { this.zedGraphControl.GraphPane.CurveList.Remove(this.curve); } this.curve = new LineItem("Profile", list, Color.Black, SymbolType.None); this.zedGraphControl.GraphPane.CurveList.Insert(0, curve); this.zedGraphControl.AxisChange(); }
private void DestroyIntermediateBitmap() { if (this.intermediateBitmap != null) { this.intermediateBitmap.Dispose(); this.intermediateBitmap = null; this.intermediateBitmapDrawn = false; } }
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); } }
protected void SendTileCorrelatationBegin(CorrelationTile tile, FreeImageAlgorithmsBitmap fib) { if (this.ThreadController.ThreadAborted) { return; } Object[] objects = { tile, fib }; this.threadController.InvokeObject.BeginInvoke(this.TileCorrelationBeginHandler, objects); }
public void TileImage(Tile tile) { lock (tile) { if (tile.Thumbnail == null) { return; } float xscaleFactor = (float)this.scaledWidth / MosaicWindow.MosaicInfo.TotalWidth; float yscaleFactor = (float)this.scaledHeight / MosaicWindow.MosaicInfo.TotalHeight; Size scaledSize = new Size((int)(tile.Width * xscaleFactor + 0.5), (int)(tile.Height * yscaleFactor + 0.5)); Point scaledPosition = new Point(); scaledPosition.X = (int)(tile.Position.X * xscaleFactor + 0.5); scaledPosition.Y = (int)(tile.Position.Y * yscaleFactor + 0.5); Rectangle dstRect = new Rectangle(scaledPosition, scaledSize); FreeImageAlgorithmsBitmap thumb = null; lock (tile.ThumbnailLock) { thumb = new FreeImageAlgorithmsBitmap(tile.Thumbnail); } thumb.ConvertToStandardType(true); if (thumb.IsGreyScale) { thumb.LinearScaleToStandardType(MosaicWindow.MosaicInfo.ThumbnailScaleMinIntensity, MosaicWindow.MosaicInfo.ThumbnailScaleMaxIntensity); thumb.SetGreyLevelPalette(); } if (thumb.ImageType != FREE_IMAGE_TYPE.FIT_BITMAP) { MessageBox.Show("Failed to convert tile thumbnail to a standard type ?"); } thumb.Rescale(dstRect.Size, FREE_IMAGE_FILTER.FILTER_BOX); thumb.ConvertTo24Bits(); this.bitmap.PasteFromTopLeft(thumb, dstRect.Location, this.imageViewer.BlendingEnabled); thumb.Dispose(); } this.Invalidate(); }
public FreeImageAlgorithmsBitmap LoadFreeImageBitmap(int width, int height) { FreeImageAlgorithmsBitmap fib = this.LoadFreeImageBitmap(this.FilePath); if (width != 0 || height != 0) { fib.Rescale(width, height, FREE_IMAGE_FILTER.FILTER_BOX); } return(fib); }
internal Tile(Stream imageStream, string filepath, int number, Point position, int width, int height, int pixelFormat, int minIntensity, int maxIntensity, FREE_IMAGE_TYPE type) : this(filepath, number, position, width, height, pixelFormat, type) { FreeImageAlgorithmsBitmap fib = new FreeImageAlgorithmsBitmap(imageStream); this.thumbnail = fib; GC.KeepAlive(this.thumbnail); this.minIntensity = minIntensity; this.maxIntensity = maxIntensity; }
private void CreateBackgroundImage() { // All tiles are assumed to be the same size. Tile tile = this.MosaicInfo.Items[0]; int width = tile.Width * 3; int height = tile.Height * 3; // Create a full res scratch image // This should be 3x3 images in size and should never need to be larger as // it is only used for correlation a small region of the tiles at a time. // if (this.MosaicInfo.IsGreyScale) this.backgroundImage = new FreeImageAlgorithmsBitmap(width, height, 8); // else // this.backgroundImage = new FreeImageAlgorithmsBitmap(width, height, 24); }
public static void ResizeToThumbnail(FreeImageAlgorithmsBitmap fib) { int height = Tile.ThumbnailHeight; // Scale to a width of around 200 pixels if (fib.Width <= Tile.ThumbnailWidth) { return; } if (height == 0) { height = (int)(((float)ThumbnailWidth / fib.Width) * fib.Height); } fib.Rescale(Tile.ThumbnailWidth, height, FREE_IMAGE_FILTER.FILTER_BILINEAR); }
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 void AddImage(FreeImageAlgorithmsBitmap image) { //Graphics g = Graphics.FromImage(this.bmp); if (this.thumbnailWidth != 0 && this.thumbnailWidth != image.Width && this.thumbnailHeight != image.Height) { throw new MosaicException("Thumbnails must all be the same size"); } this.thumbnailWidth = image.Width; this.thumbnailHeight = image.Height; Point pt = this.RealPosition(this.lastPosition++); this.bmp.PasteFromTopLeft(image, pt); this.count++; }
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 FreeImageAlgorithmsBitmap TileImage(Tile tile) { FreeImageAlgorithmsBitmap fib = tile.LoadFreeImageBitmap(); fib.ConvertToStandardType(true); if (!fib.IsGreyScale) { if (this.channel == FREE_IMAGE_COLOR_CHANNEL.FICC_RGB) { fib.ConvertToGreyscale(); } else { fib.GetChannel(this.channel); } } return(fib); }
private void CreateHighResBitmap() { if (this.ClientRectangle.Width == 0 || this.ClientRectangle.Height == 0) { return; } if (this.highResBitmap != null) { if (this.highResBitmap.Width == this.ClientRectangle.Width && this.highResBitmap.Height == this.ClientRectangle.Height) { this.highResBitmap.Clear(); return; } } this.highResBitmap = new FreeImageAlgorithmsBitmap(this.ClientRectangle.Width, this.ClientRectangle.Height, 24); }
private void PlaceFirstTile() { // puts the first tile in the sorted list at its default place CorrelationTile firstTile = this.CorrelationTiles[0]; CorrelationTile.Origin = firstTile.BackgroundBoundsWithinMosaic.Location; // FreeImageAlgorithmsBitmap fib = firstTile.Tile.LoadFreeImageBitmap(); FreeImageAlgorithmsBitmap fib = TileImage(firstTile.Tile); firstTile.Tile.IsAdjusted = true; firstTile.PerformedCorrelation = true; NumberOfCorrelatedTiles++; firstTile.Tile.AdjustedPosition = firstTile.Tile.OriginalPosition; this.SendTileCorrelatationBegin(firstTile, fib); this.SendTileCorrelated(firstTile, firstTile.Tile.Bounds, fib, true); this.ThreadController.ReportThreadPercentage(this, "Placed Tile " + firstTile.Tile.FileName + Environment.NewLine, NumberOfCorrelatedTiles, CorrelationTiles.Count); //fib.Dispose(); }
public ThumbnailMap(int thumbnailWidth, int thumbnailHeight, bool colour) { this.thumbnailWidth = thumbnailWidth; this.thumbnailHeight = thumbnailHeight; // Create Large Bitmap to hold all the thumbnals this.colour = colour; int bpp = 8; if (this.colour) { bpp = 24; } this.bmp = new FreeImageAlgorithmsBitmap(thumbnailWidth * ThumbnailMap.widthMax, thumbnailHeight * ThumbnailMap.heightMax, bpp); if (bpp == 8) { this.bmp.SetGreyLevelPalette(); } }
public void Initialise(MosaicInfo info, Rectangle virtualArea, Size imageSize, bool forceGreyscale) { this.info = info; this.virtualArea = virtualArea; this.forceGreyscale = forceGreyscale; float aspectRatio = (float)(virtualArea.Width) / virtualArea.Height; if (imageSize.Width < imageSize.Height) { imageSize.Width = (int)(imageSize.Height * aspectRatio + 0.5); } else { imageSize.Height = (int)(imageSize.Width / aspectRatio + 0.5); } if (this.info != null) { xScaleFactor = (float)imageSize.Width / virtualArea.Width; yScaleFactor = (float)imageSize.Height / virtualArea.Height; // Set the view zoom factor so the large background image is fit to window // by default. float factor = Math.Min((float)this.Width / imageSize.Width, (float)this.Height / imageSize.Height); this.Zoom = factor; } if (this.forceGreyscale || info.IsGreyScale) { this.image = new FreeImageAlgorithmsBitmap(imageSize.Width, imageSize.Height, 8); } else { this.image = new FreeImageAlgorithmsBitmap(imageSize.Width, imageSize.Height, 24); } }
private void DrawPreviouslyPlacedTiles(CorrelationTile tile) { this.BackgroundImage.Clear(); // Paste the previous placed images (correlated) onto the temporary (bg) image foreach (CorrelationTile t in this.CorrelationTiles) { if (t.PerformedCorrelation == false) { continue; } if (!t.BoundsRelativeToMosaic.IntersectsWith(tile.BoundsRelativeToMosaic)) { continue; } // FreeImageAlgorithmsBitmap fib = Tile.LoadFreeImageBitmapFromFile(t.Tile.FilePath); // fib.ConvertToStandardType(true); FreeImageAlgorithmsBitmap fib = TileImage(t.Tile); // Paste first image. We blend as it may improve the correlation. try { this.BackgroundImage.PasteFromTopLeft(fib, t.CorrelatedBoundsRelativeToOrigin.Location, true); } catch (FreeImageException) { this.SendFeedback("Tile positions do not intersect for pasting together" + Environment.NewLine , Color.Red); } finally { fib.Dispose(); } } }
private void SaveScreenShot() { string filePath = Utilities.SaveDialog(true); if (filePath == null) { return; } Bitmap bitmap = this.imageView.ScreenBitmap; Graphics g = Graphics.FromImage(bitmap); g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear; OnSavingScreenShot(g, new MosaicWindowEventArgs(MosaicWindow.MosaicInfo)); FreeImageAlgorithmsBitmap fib = new FreeImageAlgorithmsBitmap(bitmap); fib.ConvertTo24Bits(); g.Dispose(); bitmap.Dispose(); string extension = Path.GetExtension(filePath); if (extension != ".ics") { fib.SaveToFile(filePath); } else { IcsFile.SaveToFile(fib, filePath, true); } fib.Dispose(); }
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); }
protected override void ReadHeader(TileLoadInfo info) { int count = 0; List <TilePosition> tilePositions = new List <TilePosition>(); string prefix = IniParser.IniFile.GetIniFileString(this.FilePath, info_ini_name, "file format", ""); info.Prefix = prefix; string iniValue = IniParser.IniFile.GetIniFileString(this.FilePath, info_ini_name, "roi left", "0.0"); double roiLeft = Convert.ToDouble(iniValue, CultureInfo.InvariantCulture); iniValue = IniParser.IniFile.GetIniFileString(this.FilePath, info_ini_name, "roi top", "0.0"); double roiTop = Convert.ToDouble(iniValue, CultureInfo.InvariantCulture); iniValue = IniParser.IniFile.GetIniFileString(this.FilePath, info_ini_name, "Roi Height", "0.0"); double roiHeight = Convert.ToDouble(iniValue, CultureInfo.InvariantCulture); iniValue = IniParser.IniFile.GetIniFileString(this.FilePath, info_ini_name, "Horizontal Overlap", "0.0"); // This is overlap in % decimal overlapX = Convert.ToDecimal(iniValue); info.OverLapPercentageX = (double)overlapX; iniValue = IniParser.IniFile.GetIniFileString(this.FilePath, info_ini_name, "Vertical Overlap", "0.0"); // This is overlap in % decimal overlapY = Convert.ToDecimal(iniValue); info.OverLapPercentageY = (double)overlapY; iniValue = IniParser.IniFile.GetIniFileString(this.FilePath, info_ini_name, "Horizontal Frames", "0.0"); info.WidthInTiles = Convert.ToInt32(iniValue, CultureInfo.InvariantCulture); iniValue = IniParser.IniFile.GetIniFileString(this.FilePath, info_ini_name, "Vertical Frames", "0.0"); info.HeightInTiles = Convert.ToInt32(iniValue, CultureInfo.InvariantCulture); iniValue = IniParser.IniFile.GetIniFileString(this.FilePath, info_ini_name, "Max Intensity", "0.0"); info.TotalMinIntensity = 0; info.TotalMaxIntensity = Convert.ToDouble(iniValue, CultureInfo.InvariantCulture); info.ScaleMinIntensity = info.TotalMinIntensity; info.ScaleMaxIntensity = info.TotalMaxIntensity; string extension = IniParser.IniFile.GetIniFileString(this.FilePath, info_ini_name, "Extension", ".ics"); iniValue = IniParser.IniFile.GetIniFileString(this.FilePath, info_ini_name, "Tile Width", "0"); int tileWidth = Convert.ToInt32(iniValue, CultureInfo.InvariantCulture); iniValue = IniParser.IniFile.GetIniFileString(this.FilePath, info_ini_name, "Tile Height", "0"); int tileHeight = Convert.ToInt32(iniValue, CultureInfo.InvariantCulture); iniValue = IniParser.IniFile.GetIniFileString(this.FilePath, info_ini_name, "Tile Bits Per Pixel", "0"); info.ColorDepth = Convert.ToInt32(iniValue, CultureInfo.InvariantCulture); iniValue = IniParser.IniFile.GetIniFileString(this.FilePath, info_ini_name, "Tile Image Type", "0"); int tileImageType = Convert.ToInt32(iniValue, CultureInfo.InvariantCulture); iniValue = IniParser.IniFile.GetIniFileString(this.FilePath, info_ini_name, "Pixels Per Micron", "1.0"); info.OriginalPixelsPerMicron = Convert.ToDouble(iniValue, CultureInfo.InvariantCulture); // This file format provides a list of tiles and their position relative // to the left, top of the first region of interest. DirectoryInfo dir = new DirectoryInfo(this.DirectoryPath); FileInfo[] filesInDir = dir.GetFiles(prefix + "*" + extension); count = info.WidthInTiles * info.HeightInTiles; Tile[] validTiles = new Tile[count]; Tile.IsCompositeRGB = false; // Check whether all the filenames will have are valid for (int i = 1; i <= count; i++) { string filename = BuildExpectedFilename(prefix, i, extension); string fullpath = this.DirectoryPath + Path.DirectorySeparatorChar + filename; validTiles[i - 1] = new Tile(fullpath, i, tileWidth, tileHeight); } int width = 0; int height = 0; int bpp = 8; FREE_IMAGE_TYPE type = FREE_IMAGE_TYPE.FIT_BITMAP; // Find the first tile that exists to get the sizes and color depth etc // but check all bool oneNotFound = false, atLeastOneFound = false; foreach (Tile tile in validTiles) { if (System.IO.File.Exists(tile.FilePath)) { if (!atLeastOneFound) { FreeImageAlgorithmsBitmap fib = tile.LoadFreeImageBitmap(); width = fib.Width; height = fib.Height; bpp = fib.ColorDepth; type = fib.ImageType; fib.Dispose(); atLeastOneFound = true; } } else { oneNotFound = true; } } if (!atLeastOneFound) // No images at all! { throw (new MosaicReaderException("No images found. Expecting prefix " + prefix + " as in seq file.")); } if (oneNotFound) { MessageBox.Show("At least 1 image is missing from the mosaic.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } foreach (Tile tile in validTiles) { if (this.ThreadController.ThreadAborted) { return; } Point position = new Point(); int row, col; // fileWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(filepath); // Ignore files in the directory that have shorter names than we expect. // if (fileWithoutExtension.Length < mosaicInfo.Fileinfo.Prefix.Length) // continue; // fileWithoutPrefix = fileWithoutExtension.Substring(prefix.Length); // fileNumber = Version2SequenceFileReader.ParseIntStringWithZeros(fileWithoutPrefix); row = ((tile.TileNumber - 1) / info.WidthInTiles) + 1; if ((row % 2) > 0) { // Odd row reversed order col = ((tile.TileNumber - 1) % info.WidthInTiles) + 1; } else { // Even row nornal order col = info.WidthInTiles - ((tile.TileNumber - 1) % info.WidthInTiles); } decimal overlapXInpixels = (overlapX / 100.0M) * (decimal)tileWidth; decimal overlapYInpixels = (overlapY / 100.0M) * (decimal)tileHeight; position.X = (int)Math.Round(((decimal)width - overlapXInpixels) * ((decimal)col - 1.0M)); position.Y = (int)Math.Round(((decimal)height - overlapYInpixels) * ((decimal)row - 1.0M)); tile.OriginalPosition = position; tile.Width = width; tile.Height = height; tile.ColorDepth = bpp; tile.FreeImageType = type; info.Items.Add(tile); } }
protected void SendTileCorrelated(CorrelationTile tile, Rectangle correlatedBounds, FreeImageAlgorithmsBitmap fib, bool success) { if (this.ThreadController.ThreadAborted) { return; } Object[] objects = { tile, correlatedBounds, fib, success }; this.threadController.InvokeObject.BeginInvoke(this.TileCorrelatedHandler, objects); }
internal void RegenerateThumbnails(TileLoadInfo info) { // this is never overidden by a TileReader double min = Double.MaxValue, max = Double.MinValue; double tmp_min = 0.0, tmp_max = 0.0; int count = 0; this.threadController.ReportThreadStarted(this, "Creating Thumbnails"); foreach (Tile tile in info.Items) { if (this.threadController.ThreadAborted) { return; } using (FreeImageAlgorithmsBitmap fib = tile.LoadFreeImageBitmap()) { Tile.ResizeToThumbnail(fib); if (info.TotalMaxIntensity == 0.0) { // We have to find the max intensity of all the images then linear scale later fib.FindMinMaxIntensity(out tmp_min, out tmp_max); if (tmp_min < min) { min = tmp_min; } if (tmp_max > max) { max = tmp_max; } info.TotalMinIntensity = min; info.TotalMaxIntensity = max; info.ScaleMinIntensity = min; info.ScaleMaxIntensity = max; } lock (tile.ThumbnailLock) { tile.Thumbnail = new FreeImageAlgorithmsBitmap(fib); if (tile.Thumbnail == null) { MessageBox.Show("Error creating thumbnail."); } if (fib.IsGreyScale) { tile.Thumbnail.LinearScaleToStandardType(info.ScaleMinIntensity, info.ScaleMaxIntensity); tile.Thumbnail.SetGreyLevelPalette(); } } this.threadController.ReportThreadPercentage(this, "Creating Thumbnails", count++, info.Items.Count); } } // Have to scale the bitmaps for Ros's formats if (info.TotalMaxIntensity != 0.0) { info.FreeImageType = info.Items[0].FreeImageType; info.ColorDepth = info.Items[0].ColorDepth; } else { info.ScaleMinIntensity = min; info.ScaleMaxIntensity = max; count = 0; info.FreeImageType = info.Items[0].FreeImageType; info.ColorDepth = info.Items[0].ColorDepth; } this.threadController.ReportThreadCompleted(this, "Loaded Thumbnails", false); }