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


C# Bitmap.RemovePropertyItem方法代码示例

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


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

示例1: PostDecodeStream

        protected override RequestedAction PostDecodeStream(ref Bitmap b, ResizeSettings settings)
        {
            if (!"true".Equals(settings["autorotate"], StringComparison.OrdinalIgnoreCase)) return RequestedAction.None;

            int propertyId = 0x0112;
            PropertyItem pi;
            try {
                pi = b.GetPropertyItem(propertyId);
            } catch (ArgumentException) {
                return RequestedAction.None;
            }
            if (pi == null) return RequestedAction.None;

            int total = 0;

            foreach (byte by in pi.Value) total += by; //Does not handle values larger than 255, but it doesn't need to, and is endian-agnostic.

            if (total == 8) b.RotateFlip(RotateFlipType.Rotate270FlipNone);
            if (total == 3) b.RotateFlip(RotateFlipType.Rotate180FlipNone);
            if (total == 6) b.RotateFlip(RotateFlipType.Rotate90FlipNone);

            if (total == 2) b.RotateFlip(RotateFlipType.RotateNoneFlipX);
            if (total == 4) b.RotateFlip(RotateFlipType.Rotate180FlipX);
            if (total == 5) b.RotateFlip(RotateFlipType.Rotate270FlipY);
            if (total == 7) b.RotateFlip(RotateFlipType.Rotate90FlipY);

            b.RemovePropertyItem(propertyId);

            return RequestedAction.None;
        }
开发者ID:stukalin,项目名称:ImageResizer,代码行数:30,代码来源:AutoRotate.cs

示例2: CorrectRotation

        private static Bitmap CorrectRotation(Bitmap bitmap)
        {
            if (Array.IndexOf (bitmap.PropertyIdList, 274) > -1)
              {
            var values = bitmap.GetPropertyItem (274).Value;
            //var dateTakenPropertyItem = bitmap.GetPropertyItem (0x9003);
            //var dateTakenString = Encoding.UTF8.GetString (dateTakenPropertyItem.Value);
            //var regex = new Regex (":");
            //dateTakenString = dateTakenString.Substring (0, dateTakenString.Length - 1);
            //dateTakenString = regex.Replace (dateTakenString, "-", 2);
            //var dateTaken = DateTime.Parse (dateTakenString);

            if (values.Length < 1)
              return bitmap;

            var orientation = (int) values [0];
            switch (orientation)
            {
              case 1:
            // No rotation required.
            break;
              case 2:
            bitmap.RotateFlip (RotateFlipType.RotateNoneFlipX);
            break;
              case 3:
            bitmap.RotateFlip (RotateFlipType.Rotate180FlipNone);
            break;
              case 4:
            bitmap.RotateFlip (RotateFlipType.Rotate180FlipX);
            break;
              case 5:
            bitmap.RotateFlip (RotateFlipType.Rotate90FlipX);
            break;
              case 6:
            bitmap.RotateFlip (RotateFlipType.Rotate90FlipNone);
            break;
              case 7:
            bitmap.RotateFlip (RotateFlipType.Rotate270FlipX);
            break;
              case 8:
            bitmap.RotateFlip (RotateFlipType.Rotate270FlipNone);
            break;
            }
            // This EXIF data is now invalid and should be removed.
            bitmap.RemovePropertyItem (274);
              }
              return bitmap;
        }
开发者ID:rominator1983,项目名称:PictureSorter,代码行数:48,代码来源:PictureCache.cs

示例3: skipExifData

        private EndianStream skipExifData(EndianStream image)
        {
            Bitmap bitmap = new Bitmap(image.BaseStream);
            Stream output = new MemoryStream();
            // load into bitmap, remove all exlif data
            foreach (PropertyItem item in bitmap.PropertyItems)
            {
                if (item.Type == 2)
                    bitmap.RemovePropertyItem(item.Id);
            }

            bitmap.Save(output, ImageFormat.Jpeg);
            return new EndianStream(output, image.Endianness);
        }
开发者ID:iBotPeaches,项目名称:Assembly,代码行数:14,代码来源:HaloImage.xaml.cs


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