當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。