// Construct from image public ImageHandlerForm(Bitmap image, IDocumentsHost host) : this(host) { this.image = image; AForge.Imaging.Image.FormatImage(ref this.image); Init(); }
// Construct from file public ImageHandlerForm(string fileName, IDocumentsHost host) : this(host) { try { // load image image = (Bitmap)System.Drawing.Bitmap.FromFile(fileName); // format image AForge.Imaging.Image.FormatImage(ref image); this.fileName = fileName; } catch (Exception) { ((MainForm)host).ReadyToolStripStatusLabel.Text = "Failed loading image"; } Init(); }
// Constructors public FourierDoc( ComplexImage image, IDocumentsHost host ) { // // Required for Windows Form Designer support // InitializeComponent( ); // this.host = host; this.image = image; width = image.Width; height = image.Height; UpdateNewImage( ); // form style SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw, true ); // init scroll bars this.AutoScroll = true; // scroll bar size this.AutoScrollMinSize = new Size( width, height ); }
// Constructors public FourierDoc(ComplexImage image, IDocumentsHost host) { // // Required for Windows Form Designer support // InitializeComponent( ); // this.host = host; this.image = image; width = image.Width; height = image.Height; UpdateNewImage( ); // form style SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw, true); // init scroll bars this.AutoScroll = true; // scroll bar size this.AutoScrollMinSize = new Size(width, height); }
// Constructors private ImageHandlerForm(IDocumentsHost host) { this.host = host; ((MainForm)host).IHFList.Add(this); }
// Construct from file public ImageDoc( string fileName, IDocumentsHost host ) : this(host) { try { // load image image = (Bitmap) Bitmap.FromFile( fileName ); // format image AForge.Imaging.Image.FormatImage( ref image ); this.fileName = fileName; } catch ( Exception ) { throw new ApplicationException( "Failed loading image" ); } Init( ); }
// Constructors private ImageDoc( IDocumentsHost host ) { this.host = host; }
// Construct from image public ImageDoc( Bitmap image, IDocumentsHost host ) : this( host ) { this.image = image; if ( !AForge.Imaging.Image.IsGrayscale( this.image ) ) { this.image = AForge.Imaging.Image.Clone( image, PixelFormat.Format24bppRgb ); } Init( ); }
// Construct from file public ImageDoc( string fileName, IDocumentsHost host ) : this( host ) { FileStream stream = null; try { // read image to temporary memory stream // (.NET locks any stream until bitmap is disposed, // so that is why this work around is required) stream = File.OpenRead( fileName ); MemoryStream memoryStream = new MemoryStream( ); byte[] buffer = new byte[10000]; while ( true ) { int read = stream.Read( buffer, 0, 10000 ); if ( read == 0 ) break; memoryStream.Write( buffer, 0, read ); } image = (Bitmap) Bitmap.FromStream( memoryStream ); // format image if ( !AForge.Imaging.Image.IsGrayscale( image ) && ( image.PixelFormat != PixelFormat.Format24bppRgb ) ) { Bitmap temp = AForge.Imaging.Image.Clone( image, PixelFormat.Format24bppRgb ); image.Dispose( ); image = temp; } this.fileName = fileName; } catch ( Exception ) { throw new ApplicationException( "Failed loading image" ); } finally { if ( stream != null ) { stream.Close( ); stream.Dispose( ); } } Init( ); }
// Construct from file public ImageDoc( string fileName, IDocumentsHost host ) : this( host ) { try { image = LoadImageFromFile( fileName ); // format image if ( !AForge.Imaging.Image.IsGrayscale( image ) && ( image.PixelFormat != PixelFormat.Format24bppRgb ) ) { Bitmap temp = AForge.Imaging.Image.Clone( image, PixelFormat.Format24bppRgb ); image.Dispose( ); image = temp; } this.fileName = fileName; } catch ( Exception ) { throw new ApplicationException( "Failed loading image" ); } Init( ); }
private void ImageDoc(IDocumentsHost host) { this.host = host; }
// Constructors private ImageDoc( IDocumentsHost host ) { this.host = host; //SS: экземпляр класса для ведения логов logger = new Logger(this); }