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


C# Image.GetPropertyItem方法代码示例

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


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

示例1: ImageAnimation

        //-------------------------------------------------------------------------------
        //
        public ImageAnimation(Image img)
        {
            _image = img;
            FrameDimension = new FrameDimension(img.FrameDimensionsList[0]);
            MaxFrameCount = img.GetFrameCount(FrameDimension);
            PropertyItem pItemFrameDelay = img.GetPropertyItem(FRAME_DELAY);
            PropertyItem pItemFrameNum = img.GetPropertyItem(FRAME_NUM);
            FrameDelays = new int[MaxFrameCount];

            for (int i = 0; i < MaxFrameCount; i++) {
                FrameDelays[i] = BitConverter.ToInt32(pItemFrameDelay.Value, 4 * i);
            }
            MaxLoopCount = BitConverter.ToInt16(pItemFrameNum.Value, 0);

            LoopInfinity = (MaxLoopCount == 0);

            _timer = new Timer(Timer_Elapsed, null, Timeout.Infinite, Timeout.Infinite);
            try {
                _image.SelectActiveFrame(FrameDimension, 0);
            }
            catch (InvalidOperationException/* ex*/) {
                //Log.DebugLog(ex);
                //Debug.Assert(false, "Image.SelectActiveFrame失敗");
            }
        }
开发者ID:tomfuru,项目名称:StarlitTwit,代码行数:27,代码来源:ImageAnimation.cs

示例2: GifDecoder

        /// <summary>
        /// Initializes a new instance of the <see cref="GifDecoder"/> class.
        /// </summary>
        /// <param name="image">
        /// The <see cref="Image"/> to decode.
        /// </param>
        public GifDecoder(Image image)
        {
            this.Height = image.Height;
            this.Width = image.Width;

            if (FormatUtilities.IsAnimated(image))
            {
                this.IsAnimated = true;

                if (this.IsAnimated)
                {
                    int frameCount = image.GetFrameCount(FrameDimension.Time);
                    int last = frameCount - 1;
                    double length = 0;

                    List<GifFrame> gifFrames = new List<GifFrame>();

                    // Get the times stored in the gif.
                    byte[] times = image.GetPropertyItem((int)ExifPropertyTag.FrameDelay).Value;

                    for (int i = 0; i < frameCount; i++)
                    {
                        // Convert each 4-byte chunk into an integer.
                        // GDI returns a single array with all delays, while Mono returns a different array for each frame.
                        TimeSpan delay = TimeSpan.FromMilliseconds(BitConverter.ToInt32(times, (4 * i) % times.Length) * 10);

                        // Find the frame
                        image.SelectActiveFrame(FrameDimension.Time, i);
                        Bitmap frame = new Bitmap(image);
                        frame.SetResolution(image.HorizontalResolution, image.VerticalResolution);
                        
                        // TODO: Get positions.
                        gifFrames.Add(new GifFrame { Delay = delay, Image = frame });

                        // Reset the position.
                        if (i == last)
                        {
                            image.SelectActiveFrame(FrameDimension.Time, 0);
                        }

                        length += delay.TotalMilliseconds;
                    }

                    this.GifFrames = gifFrames;
                    this.AnimationLength = length;

                    // Loop info is stored at byte 20737.
                    this.LoopCount = BitConverter.ToInt16(image.GetPropertyItem((int)ExifPropertyTag.LoopCount).Value, 0);
                    this.IsLooped = this.LoopCount != 1;
                }
            }
        }
开发者ID:AlexSkarbo,项目名称:ImageProcessor,代码行数:58,代码来源:GifDecoder.cs

示例3: GetLatitude

 public static float? GetLatitude(Image targetImg)
 {
     try
     {
         //Property Item 0x0001 - PropertyTagGpsLatitudeRef
         PropertyItem propItemRef = targetImg.GetPropertyItem(1);
         //Property Item 0x0002 - PropertyTagGpsLatitude
         PropertyItem propItemLat = targetImg.GetPropertyItem(2);
         return ExifGpsToFloat(propItemRef, propItemLat);
     }
     catch (ArgumentException)
     {
         return null;
     }
 }
开发者ID:ratRenRao,项目名称:PhotoOrganizer,代码行数:15,代码来源:PictureData.cs

示例4: GetLongitude

 public static float? GetLongitude(Image targetImg)
 {
     try
     {
         ///Property Item 0x0003 - PropertyTagGpsLongitudeRef
         PropertyItem propItemRef = targetImg.GetPropertyItem(3);
         //Property Item 0x0004 - PropertyTagGpsLongitude
         PropertyItem propItemLong = targetImg.GetPropertyItem(4);
         return ExifGpsToFloat(propItemRef, propItemLong);
     }
     catch (ArgumentException)
     {
         return null;
     }
 }
开发者ID:ratRenRao,项目名称:PhotoOrganizer,代码行数:15,代码来源:PictureData.cs

示例5: Animate

		public static void Animate (Image image, EventHandler onFrameChangedHandler)
		{
			// must be non-null and contain animation time frames
			if (!CanAnimate (image))
				return;

			// is animation already in progress ?
			if (ht.ContainsKey (image))
				return;

			PropertyItem item = image.GetPropertyItem (0x5100); // FrameDelay in libgdiplus
			byte[] value = item.Value;
			int[] delay = new int [(value.Length >> 2)];
			for (int i=0, n=0; i < value.Length; i += 4, n++) {
				int d = BitConverter.ToInt32 (value, i) * 10;
				// follow worse case (Opera) see http://news.deviantart.com/article/27613/
				delay [n] = d < 100 ? 100 : d;
			}

			AnimateEventArgs aea = new AnimateEventArgs (image);
			WorkerThread wt = new WorkerThread (onFrameChangedHandler, aea, delay);
			Thread thread = new Thread (new ThreadStart (wt.LoopHandler));
			thread.IsBackground = true;
			aea.RunThread = thread;
			ht.Add (image, aea);
			thread.Start ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:27,代码来源:ImageAnimator.cs

示例6: ImageInfo

            /// <devdoc> 
            /// </devdoc>  
            public ImageInfo(Image image) {
                this.image = image;
                animated = ImageAnimator.CanAnimate(image);

                if (animated) {
                    frameCount = image.GetFrameCount(FrameDimension.Time);

                    PropertyItem frameDelayItem = image.GetPropertyItem(PropertyTagFrameDelay);

                    // If the image does not have a frame delay, we just return 0.                                     
                    //
                    if (frameDelayItem != null) {
                        // Convert the frame delay from byte[] to int
                        //
                        byte[] values = frameDelayItem.Value;
                        Debug.Assert(values.Length == 4 * FrameCount, "PropertyItem has invalid value byte array");
                        frameDelay = new int[FrameCount];
                        for (int i=0; i < FrameCount; ++i) {
                            frameDelay[i] = values[i * 4] + 256 * values[i * 4 + 1] + 256 * 256 * values[i * 4 + 2] + 256 * 256 * 256 * values[i * 4 + 3];
                        }
                    }
                }
                else {
                    frameCount = 1;
                }
                if (frameDelay == null) {
                    frameDelay = new int[FrameCount];
                }
            }                                               
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:31,代码来源:ImageInfo.cs

示例7: GetDateTakenPropertyItem

 private static PropertyItem GetDateTakenPropertyItem(Image image)
 {
     PropertyItem dateTakenItem = null;
     try
     {
         dateTakenItem = image.GetPropertyItem(DATE_TAKEN);
     }
     catch (ArgumentException) { }
     return dateTakenItem;
 }
开发者ID:garyjohnson,项目名称:Photo-Sorter,代码行数:10,代码来源:PhotoDateTakenParser.cs

示例8: ImageAnimation

        //-------------------------------------------------------------------------------
        //
        public ImageAnimation(Image img)
        {
            _image = img;
            FrameDimension = new FrameDimension(img.FrameDimensionsList[0]);
            MaxFrameCount = img.GetFrameCount(FrameDimension);
            PropertyItem pItemFrameDelay = img.GetPropertyItem(FRAME_DELAY);
            PropertyItem pItemFrameNum = img.GetPropertyItem(FRAME_NUM);
            FrameDelays = new int[MaxFrameCount];

            for (int i = 0; i < MaxFrameCount; i++) {
                FrameDelays[i] = BitConverter.ToInt32(pItemFrameDelay.Value, 4 * i);
            }
            MaxLoopCount = BitConverter.ToInt16(pItemFrameNum.Value, 0);

            LoopInfinity = (MaxLoopCount == 0);

            _timer = new Timer(Timer_Elapsed, null, Timeout.Infinite, Timeout.Infinite);
            _image.SelectActiveFrame(FrameDimension, 0);
        }
开发者ID:tomfuru,项目名称:StarlitTwit,代码行数:21,代码来源:ImageAnimation.cs

示例9: GifHandler

		public GifHandler( Image Image ) {
			mImage = Image.Clone() as Image;
			mFrameDimension = new FrameDimension( mImage.FrameDimensionsList[ 0 ] );
			mFrameCount = mImage.GetFrameCount( mFrameDimension );

			mFrameTimes = new int[ mFrameCount ];
			byte[] times = mImage.GetPropertyItem( 0x5100 ).Value;
			for( int i = 0; i < mFrameCount; i++ )
				mFrameTimes[ i ] = BitConverter.ToInt32( times, 4 * i ) * 10;
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:10,代码来源:GifHandler.cs

示例10: SetPropertyItemString

 private static void SetPropertyItemString(Image srcImg, ImageMetadataPropertyId id, string value)
 {
     var buffer = Encoding.Unicode.GetBytes(value);
     var propItem = srcImg.GetPropertyItem(srcImg.PropertyItems[0].Id);
     propItem.Id = (int)id;
     propItem.Type = 1;
     propItem.Len = buffer.Length;
     propItem.Value = buffer;
     srcImg.SetPropertyItem(propItem);
 }
开发者ID:BlythMeister,项目名称:BingImageDowload,代码行数:10,代码来源:ImagePropertyHandling.cs

示例11: Orientate

        /// <summary>
        /// Make sure the image is orientated correctly
        /// </summary>
        /// <param name="image"></param>
        public static void Orientate(Image image)
        {
            /*if (!conf.ProcessEXIFOrientation)
            {
                return;
            }*/
            try
            {
                // Get the index of the orientation property.
                int orientationIndex = Array.IndexOf(image.PropertyIdList, EXIF_ORIENTATION_ID);
                // If there is no such property, return Unknown.
                if (orientationIndex < 0)
                {
                    return;
                }
                PropertyItem item = image.GetPropertyItem(EXIF_ORIENTATION_ID);

                ExifOrientations orientation = (ExifOrientations)item.Value[0];
                // Orient the image.
                switch (orientation)
                {
                    case ExifOrientations.Unknown:
                    case ExifOrientations.TopLeft:
                        break;
                    case ExifOrientations.TopRight:
                        image.RotateFlip(RotateFlipType.RotateNoneFlipX);
                        break;
                    case ExifOrientations.BottomRight:
                        image.RotateFlip(RotateFlipType.Rotate180FlipNone);
                        break;
                    case ExifOrientations.BottomLeft:
                        image.RotateFlip(RotateFlipType.RotateNoneFlipY);
                        break;
                    case ExifOrientations.LeftTop:
                        image.RotateFlip(RotateFlipType.Rotate90FlipX);
                        break;
                    case ExifOrientations.RightTop:
                        image.RotateFlip(RotateFlipType.Rotate90FlipNone);
                        break;
                    case ExifOrientations.RightBottom:
                        image.RotateFlip(RotateFlipType.Rotate90FlipY);
                        break;
                    case ExifOrientations.LeftBottom:
                        image.RotateFlip(RotateFlipType.Rotate270FlipNone);
                        break;
                }
                // Set the orientation to be normal, as we rotated the image.
                item.Value[0] = (byte)ExifOrientations.TopLeft;
                image.SetPropertyItem(item);
            }
            catch (Exception orientEx)
            {
                LOG.Warn("Problem orientating the image: ", orientEx);
            }
        }
开发者ID:Maximus325,项目名称:ShareX,代码行数:59,代码来源:ImageHelper.cs

示例12: GifImage

        public GifImage(string path)
        {
            _lastRequest = DateTime.Now;
            _gifImage = Image.FromFile(path); //initialize
            _dimension = new FrameDimension(_gifImage.FrameDimensionsList[0]); //gets the GUID
            FrameCount = _gifImage.GetFrameCount(_dimension); //total frames in the animation

            Source = path;

            var item = _gifImage.GetPropertyItem(0x5100); // FrameDelay in libgdiplus
            _delay = (item.Value[0] + item.Value[1]*256)*10; // Time is in 1/100th of a second
        }
开发者ID:SpoinkyNL,项目名称:Artemis,代码行数:12,代码来源:GifImage.cs

示例13: ImageOrientation

        /// <summary>
        /// Return the image's orientation.
        /// </summary>
        /// <param name="img"></param>
        /// <returns></returns>
        public static ExifOrientations ImageOrientation(Image img)
        {
            // Get the index of the orientation property.
            int orientation_index = Array.IndexOf(img.PropertyIdList, OrientationID);

            // If there is no such property, return Unknown.
            if ((orientation_index < 0))
                return ExifOrientations.Unknown;

            // Return the orientation value.
            return (ExifOrientations)img.GetPropertyItem(OrientationID).Value[0];
        }
开发者ID:huanlin,项目名称:YetAnotherLibrary,代码行数:17,代码来源:ExifHelper.cs

示例14: MakeSureAllPropertyItemsArePresent

 protected void MakeSureAllPropertyItemsArePresent(Image source, Image target)
 {
     foreach (var propertyItem in source.PropertyItems)
     {
         try
         {
             target.GetPropertyItem(propertyItem.Id);
         }
         catch (ArgumentException)
         {
             Assert.Fail("The property item with ID {0} was not present.", propertyItem.Id);
         }
     }
 }
开发者ID:GorelH,项目名称:FluentImageResizing,代码行数:14,代码来源:TestFixtureWorkingWithImages.cs

示例15: GifDecoder

        /// <summary>
        /// Initializes a new instance of the <see cref="GifDecoder"/> class.
        /// </summary>
        /// <param name="image">
        /// The <see cref="Image"/> to decode.
        /// </param>
        /// <param name="animationProcessMode">
        /// The <see cref="AnimationProcessMode" /> to use.
        /// </param>
        public GifDecoder(Image image, AnimationProcessMode animationProcessMode)
        {
            this.Height = image.Height;
            this.Width = image.Width;

            if (FormatUtilities.IsAnimated(image) && animationProcessMode == AnimationProcessMode.All)
            {
                this.IsAnimated = true;
                this.FrameCount = image.GetFrameCount(FrameDimension.Time);

                // Loop info is stored at byte 20737.
                this.LoopCount = BitConverter.ToInt16(image.GetPropertyItem((int)ExifPropertyTag.LoopCount).Value, 0);
            }
            else
            {
                this.FrameCount = 1;
            }
        }
开发者ID:CastleSoft,项目名称:ImageProcessor,代码行数:27,代码来源:GifDecoder.cs


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