当前位置: 首页>>代码示例>>C#>>正文


C# Bitmap.GetHashCode方法代码示例

本文整理汇总了C#中System.Drawing.Bitmap.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Bitmap.GetHashCode方法的具体用法?C# Bitmap.GetHashCode怎么用?C# Bitmap.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Bitmap的用法示例。


在下文中一共展示了Bitmap.GetHashCode方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddFrames

        /// <summary>
        /// Saves the Bitmap to the disk and adds the filename in the list of frames.
        /// </summary>
        /// <param name="filename">The final filename of the Bitmap.</param>
        /// <param name="bitmap">The Bitmap to save in the disk.</param>
        private void AddFrames(string filename, Bitmap bitmap)
        {
            var mutexLock = new Mutex(false, bitmap.GetHashCode().ToString());
            mutexLock.WaitOne();

            bitmap.Save(filename);
            bitmap.Dispose();

            GC.Collect(1);
            mutexLock.ReleaseMutex();
        }
开发者ID:koen24,项目名称:screentogif,代码行数:16,代码来源:Recorder.xaml.cs

示例2: GatherStatistics

        // Gather image statistics
        public void GatherStatistics(Bitmap image)
        {
            // avoid calculation in the case of the same image
            if (image != null)
            {
                if (currentImageHash == image.GetHashCode())
                    return;
                currentImageHash = image.GetHashCode();
            }
            else
            {
                propertyGrid.SelectedObject = null;
                return;
            }

            System.Diagnostics.Debug.WriteLine("--- Gathering stastics");

            // check pixel format
            if (image.PixelFormat == PixelFormat.Format24bppRgb)
            {
                // busy
                Capture = true;
                Cursor = Cursors.WaitCursor;

                ColorImageStatisticsDescription statDesc = new ColorImageStatisticsDescription(image);
                // show statistics
                propertyGrid.SelectedObject = statDesc;
                propertyGrid.ExpandAllGridItems();

                // free
                Cursor = Cursors.Arrow;
                Capture = false;
            }
            else
            {
                propertyGrid.SelectedObject = null;
            }
        }
开发者ID:vebin,项目名称:PhotoBrushProject,代码行数:39,代码来源:DetailsForm.cs

示例3: ScreenShot

 public static void ScreenShot()
 {
     Rectangle bounds = Screen.GetBounds(Point.Empty);
     using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
     {
         using (Graphics g = Graphics.FromImage(bitmap))
         {
             g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
         }
         DateTime thisDay = DateTime.Today;
         string data = thisDay.ToString("d");
         string ingName = "..//..//Screenshots//screenshots" + bitmap.GetHashCode() + ".jpg";
         bitmap.Save(ingName, ImageFormat.Jpeg);
         Thread.Sleep(2000);
     }
 }
开发者ID:AlenaTarasiuk,项目名称:TestForTeamCity,代码行数:16,代码来源:ScreenShots.cs

示例4: TestThin

        public void TestThin(Bitmap bmp)
        {
            var bmpBefore = Binarization(ImageHelper.LoadImage<double>(bmp), bmp.Height, bmp.Width);
            /* open binarized source picture
            var newPic1 = ImageHelper.SaveArrayToBitmap(bmpBefore);
            var name1 = Path.GetTempPath() + bmp.GetHashCode().ToString() + "BEFORE.bmp";
            newPic1.Save(name1, ImageHelper.GetImageFormatFromExtension(name1));
            Process.Start(name1);
            */
            var bmpAfter = Thinner.Thin(bmpBefore, bmp.Width, bmp.Height);

            var newPic = ImageHelper.SaveArrayToBitmap(
                OverlapArrays(bmpAfter, bmpBefore, bmp.Height, bmp.Width)
            );
            var name = Path.GetTempPath() + bmp.GetHashCode().ToString() + "AFTER.bmp";
            newPic.Save(name, ImageHelper.GetImageFormatFromExtension(name));
            Process.Start(name);
        }
开发者ID:SeriousCoder,项目名称:CUDA-Fingerprinting,代码行数:18,代码来源:ThinnerTest.cs

示例5: Texture

 /// <summary>
 /// Create a texture from a supplie bitmap.
 /// </summary>
 /// <param name="BitmapImage">The already decoded bitmap image.</param>
 /// <param name="FlipY">True if the bitmap should be flipped.</param>
 public Texture(Bitmap BitmapImage, bool FlipY = true)
 {
     this.Filename = BitmapImage.GetHashCode().ToString();
     LoadBitmap(BitmapImage, FlipY);
     Gl.BindTexture(TextureTarget, 0);
 }
开发者ID:TrentSterling,项目名称:opengl4csharp,代码行数:11,代码来源:Texture.cs

示例6: MyLoLoadFolder

        /// <summary>
        /// Load files in one Folder, then recurse on all contained folders
        /// </summary>
        /// <param name="root">Current Top Level Folder Name</param>
        private void MyLoLoadFolder(DirectoryInfo root)
        {
            System.IO.FileInfo[] files = null;
            System.IO.DirectoryInfo[] subDirs = null;
            // First, process all the files directly under this folder
            try
            {
                files = root.GetFiles("*.*");
            }
            // This is thrown if even one of the files requires permissions greater
            // than the application provides.
            catch (UnauthorizedAccessException e)
            {
                // This code just writes out the message and continues to recurse.
                // You may decide to do something different here. For example, you
                // can try to elevate your privileges and access the file again.
                log.Add(e.Message);
            }

            catch (System.IO.DirectoryNotFoundException e)
            {
                Console.WriteLine(e.Message);
            }

            if (files != null)
            {
                foreach (System.IO.FileInfo fi in files)
                {
                    // a try-catch block is required here to handle the case
                    // where the file has been deleted since the call to MyLoLoadFolder().
                    try
                    {
                        if (fi.Extension == ".jpg" || fi.Extension == ".JPG")
                        {
                            Photo photo = new Photo();
                            Image.GetThumbnailImageAbort myCallback =
                            new Image.GetThumbnailImageAbort(ThumbnailCallback);
                            Bitmap image = new Bitmap(fi.FullName);
                            Image thumb = image.GetThumbnailImage(100, 100, myCallback, IntPtr.Zero);

                            ImageConverter converter = new ImageConverter();
                            photo.Thumbnail = (byte[])converter.ConvertTo(thumb, typeof(byte[]));

                            // This is for testing only - should switch to more reliable Hash such as SHA-256 or MD5
                            //long CRC = CalculateCRCForFile(fi.FullName);
                            photo.CRC = image.GetHashCode();
                            image.Dispose();

                            JpgPhoto photoJpg = new JpgPhoto(fi.FullName);

                            photo.Uri = fi.FullName;
                            photo.Aperture = photoJpg.Metadata.Aperture;
                            photo.Camera = photoJpg.Metadata.CameraModel;
                            photo.DateTaken = photoJpg.Metadata.DateTaken;
                            photo.PhotoIndexKind = _timeIndexKind;
                            DateTime dat = photoJpg.Metadata.DateTaken.Date;
                            TimeSpan tim = photoJpg.Metadata.DateTaken.TimeOfDay;
                            if (photoJpg.Metadata.GpsPosition.Latitude.IsValidCoordinate)
                            {
                                photo.GpsLat = photoJpg.Metadata.GpsPosition.Latitude.Numeric;
                            }
                            if (photoJpg.Metadata.GpsPosition.Longitude.IsValidCoordinate)
                            {
                                photo.GpsLong = photoJpg.Metadata.GpsPosition.Longitude.Numeric;
                            }
                            photo.Uuid = Guid.NewGuid();

                            //foreach (Tag tag in photo.Metadata.Tags)
                            //{
                            //    Console.WriteLine(tag.FullName);
                            //}
                            long photoId = _myLoStore.AddPhoto(_userId, photo);

                            _count++;

                            // TODO add code to write back GUID and Hash into photo metadata
                        }
                    }
                    catch (MyLoCRCException crcEx)
                    {
                        throw new MyLoException("CRC Calculation Error: Inner exception: " + crcEx);
                    }
                    catch (MyLoDataStoreException dsEx)
                    {
                        throw new MyLoException("DataStore Error: Inner exception: " + dsEx);
                    }
                    catch (Exception ex)
                    {
                        throw new MyLoException("File not Found: " + fi.FullName + " Inner exception: " + ex);
                    }
                    Debug.WriteLine(fi.FullName);
                }

                // Now find all the subdirectories under this directory.
                subDirs = root.GetDirectories();

//.........这里部分代码省略.........
开发者ID:keithshort1,项目名称:MyLoProto,代码行数:101,代码来源:PhotoLoader.cs

示例7: Recognize

        public static string Recognize(Bitmap bitmap, int series)
        {
            Dictionary <string, int> versions = new Dictionary <string, int>();

            using (ImageClass image = new ImageClass(bitmap))
            {
                for (int i = 0; i < series; i++)
                {
                    string result = "";
                    try
                    {
                        using (Bitmap b = new Bitmap(image.BitImage))
                        {
                            result = Recognize(b);
                        }
                    }
                    catch (RecognitionEngineException exception)
                    {
                        //если ошибка из-за отсутствия текста
                        if (exception.ErrorCode == 6553609)
                        {
                            if (!versions.ContainsKey(result))
                            {
                                versions.Add(result, 1);
                            }
                            break;
                        }
                        //если ошибка из-за отсутствия текста[2]
                        if (exception.ErrorCode == 6684676)
                        {
                            if (!versions.ContainsKey(result))
                            {
                                versions.Add(result, 1);
                            }
                            break;
                        }
                        bitmap.Save(Path.Combine(Application.StartupPath, bitmap.GetHashCode().ToString() + ".png"), ImageFormat.Png);
                        throw;
                    }
                    if (versions.ContainsKey(result))
                    {
                        versions[result]++;
                    }
                    else
                    {
                        versions.Add(result, 1);
                    }
                    image.Resize(0.9);
                }
            }

            int max = 0;
            string sMax = "";
            foreach (KeyValuePair <string, int> pair in versions)
            {
                if (string.IsNullOrEmpty(pair.Key))
                    continue;
                if (pair.Value > max)
                {
                    sMax = pair.Key;
                    max = pair.Value;
                }
            }
            return sMax;
        }
开发者ID:IgorGorbunov,项目名称:SmartLabParser,代码行数:65,代码来源:Recognizer.cs

示例8: SetHistograms

        internal void SetHistograms(Bitmap hostImage, Bitmap secretImage, Bitmap outputImage)
        {
            if (hostImage != null)
            {
                if (hostImageHash == hostImage.GetHashCode())
                {
                    return;
                }
                hostImageHash = hostImage.GetHashCode();
                CreateSeries(ref hostImageSeries, hostImage, "HostImageChartArea");
                hostImageComboBox.Enabled = true;
                hostImageComboBox.SelectedIndex = 0;
            }
            else
            {
                hostImageChart.Series.Clear();
            }

            if (secretImage != null)
            {
                if (secretImageHash == secretImage.GetHashCode())
                {
                    return;
                }
                secretImageHash = secretImage.GetHashCode();
                CreateSeries(ref secretImageSeries, secretImage, "SecretImageChartArea");
                secretImageComboBox.Enabled = true;
                secretImageComboBox.SelectedIndex = 0;
            }
            else
            {
                secretImageChart.Series.Clear();
            }

            if (outputImage != null)
            {
                if (outputImageHash == outputImage.GetHashCode())
                {
                    return;
                }
                outputImageHash = outputImage.GetHashCode();
                CreateSeries(ref outputImageSeries, outputImage, "OutputImageChartArea");
                outputImageComboBox.Enabled = true;
                outputImageComboBox.SelectedIndex = 0;
            }
            else
            {
                outputImageChart.Series.Clear();
            }

            if (hostImage != null && secretImage != null && outputImage != null)
                allImageComboBox.Enabled = true;

            return;
        }
开发者ID:sskl,项目名称:watermarking,代码行数:55,代码来源:HistogramForm.cs

示例9: GatherStatistics

        // Gather image statistics
        public void GatherStatistics( Bitmap image )
        {
            // avoid calculation in the case of the same image
            if ( image != null )
            {
                if ( currentImageHash == image.GetHashCode( ) )
                    return;
                currentImageHash = image.GetHashCode( );
            }

            if ( image != null )
                System.Diagnostics.Debug.WriteLine( "=== Gathering histogram" );

            // busy
            Capture = true;
            Cursor = Cursors.WaitCursor;

            // get statistics
            stat = ( image == null ) ? null : new ImageStatistics( image );

            // free
            Cursor = Cursors.Arrow;
            Capture = false;

            // clean combo
            channelCombo.Items.Clear( );
            channelCombo.Enabled = false;

            if ( stat != null )
            {
                if ( !stat.IsGrayscale )
                {
                    // RGB picture
                    channelCombo.Items.AddRange( new object[] { "Red", "Green", "Blue" } );
                    channelCombo.Enabled = true;
                }
                else
                {
                    // grayscale picture
                    channelCombo.Items.Add( "Gray" );
                }
                channelCombo.SelectedIndex = 0;
            }
            else
            {
                histogram.Values = null;
                meanLabel.Text = String.Empty;
                stdDevLabel.Text = String.Empty;
                medianLabel.Text = String.Empty;
                minLabel.Text = String.Empty;
                maxLabel.Text = String.Empty;
                levelLabel.Text = String.Empty;
                countLabel.Text = String.Empty;
                percentileLabel.Text = String.Empty;
            }
        }
开发者ID:kapt-sino,项目名称:fingergraph,代码行数:57,代码来源:HistogramWindow.cs

示例10: GetHashCodeTest

		public void GetHashCodeTest () {
			Assert.IsFalse (t.Bitmap.GetHashCode () == 0);
			Bitmap im1 = new Bitmap (10, 20);
			Assert.IsFalse (t.Bitmap.GetHashCode () == im1.GetHashCode ());
		}
开发者ID:nlhepler,项目名称:mono,代码行数:5,代码来源:Image.cs

示例11: SetProperties

        internal void SetProperties(Bitmap hostImage, Bitmap secretImage, Bitmap outputImage)
        {
            if (hostImage != null)
            {
                if (hostImageHash == hostImage.GetHashCode())
                {
                    return;
                }
                hostImageHash = hostImage.GetHashCode();
                hostImgPropertyGrid.SelectedObject = new ImageProperties(hostImage);
                hostImgPropertyGrid.ExpandAllGridItems();
            }
            else
            {
                hostImgPropertyGrid.SelectedObject = null;
            }

            if (secretImage != null)
            {
                if (secretImageHash == secretImage.GetHashCode())
                {
                    return;
                }
                secretImageHash = secretImage.GetHashCode();
                secretImgPropertyGrid.SelectedObject = new ImageProperties(secretImage);
                secretImgPropertyGrid.ExpandAllGridItems();
            }
            else
            {
                secretImgPropertyGrid.SelectedObject = null;
            }

            if (outputImage != null)
            {
                if (outputImageHash == outputImage.GetHashCode())
                {
                    return;
                }
                outputImageHash = outputImage.GetHashCode();
                outputImgPropertyGrid.SelectedObject = new ImageProperties(outputImage);
                outputImgPropertyGrid.ExpandAllGridItems();
            }
            else
            {
                outputImgPropertyGrid.SelectedObject = null;
            }

            return;
        }
开发者ID:sskl,项目名称:watermarking,代码行数:49,代码来源:PropertiesForm.cs

示例12: MakeOpaque

        private static Bitmap MakeOpaque(Bitmap original, string path, double opacity)
        {
            if (CachedOpaque.ContainsKey(original.GetHashCode())) return CachedOpaque[original.GetHashCode()];

            Bitmap bmp = (Bitmap)original.Clone();

            // Specify a pixel format.
            PixelFormat pxf = PixelFormat.Format32bppArgb;

            // Lock the bitmap's bits.
            Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
            BitmapData bmpData = bmp.LockBits(rect, ImageLockMode.ReadWrite, pxf);

            // Get the address of the first line.
            IntPtr ptr = bmpData.Scan0;

            // Declare an array to hold the bytes of the bitmap.
            // This code is specific to a bitmap with 32 bits per pixels
            // (32 bits = 4 bytes, 3 for RGB and 1 byte for alpha).
            int numBytes = bmp.Width * bmp.Height * 4;
            byte[] argbValues = new byte[numBytes];

            // Copy the ARGB values into the array.
            System.Runtime.InteropServices.Marshal.Copy(ptr, argbValues, 0, numBytes);

            // Manipulate the bitmap, such as changing the
            // RGB values for all pixels in the the bitmap.
            for (int counter = 0; counter < argbValues.Length; counter += 4)
            {
                // argbValues is in format BGRA (Blue, Green, Red, Alpha)

                // If 100% transparent, skip pixel
                if (argbValues[counter + 4 - 1] == 0)
                    continue;

                int pos = 0;
                pos++; // B value
                pos++; // G value
                pos++; // R value

                argbValues[counter + pos] = (byte)(argbValues[counter + pos] * opacity);
            }

            // Copy the ARGB values back to the bitmap
            System.Runtime.InteropServices.Marshal.Copy(argbValues, 0, ptr, numBytes);

            // Unlock the bits.
            bmp.UnlockBits(bmpData);

            // Cache
            CachedOpaque[original.GetHashCode()] = bmp;
            return bmp;
        }
开发者ID:MisterDr,项目名称:fonline-mapgen,代码行数:53,代码来源:DrawMap.cs

示例13: GreenFilter

        /// <summary>
        /// Return green filter for specific image
        /// </summary>
        /// <param name="Image"></param>
        /// <returns></returns>
        public static Bitmap GreenFilter(Bitmap Image)
        {
            if (CachedOverlay.ContainsKey(Image.GetHashCode())) return CachedOverlay[Image.GetHashCode()];

            ColorMatrixBitmap TempMatrix = new ColorMatrixBitmap();
            TempMatrix.Matrix = new float[][]{
                       new float[] {0, 0, 0, 0, 0},
                       new float[] {0, 1, 0, 0, 0},
                       new float[] {0, 0, 0, 0, 0},
                       new float[] {0, 0, 0, 1, 0},
                       new float[] {0, 0, 0, 0, 1}
                   };
             var bmp = TempMatrix.Apply(Image);
             CachedOverlay[Image.GetHashCode()] = bmp;
             return bmp;
        }
开发者ID:MisterDr,项目名称:fonline-mapgen,代码行数:21,代码来源:DrawMap.cs

示例14: SetPSNR

        internal void SetPSNR(Bitmap hostImage, Bitmap outputImage)
        {
            if (outputImage != null)
            {
                if (outputImageHash == outputImage.GetHashCode())
                {
                    return;
                }
                outputImageHash = outputImage.GetHashCode();
                outputImgPropertyGrid.SelectedObject = new PSNR(hostImage, outputImage);
                outputImgPropertyGrid.ExpandAllGridItems();
            }
            else
            {
                outputImgPropertyGrid.SelectedObject = null;
            }

            return;
        }
开发者ID:sskl,项目名称:watermarking,代码行数:19,代码来源:AnalysisForm.cs


注:本文中的System.Drawing.Bitmap.GetHashCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。