本文介绍了C#:如何更改图像方向属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

foreach (var prop in img.PropertyItems)
{
      if (prop.Id == 0x0112) //value of EXIF
      {
         var orientation = img.GetPropertyItem(prop.Id).Value[0];
         switch (orientation)
         {
            case 1:
            // No rotation required.
            break;
            case 2:
            img.RotateFlip(RotateFlipType.RotateNoneFlipX);
            break;
            case 3:
            img.RotateFlip(RotateFlipType.Rotate180FlipNone);





我使用上面的代码来检测图像是否从原始状态改变。假设我将方向值设置为3并且我想将其设置为1的正常,那么我如何将该方向属性值3替换为1?



I have used above code to detect whether image orietation is changed from original. Suppose I have get orientation value as "3" and I want to set it to normal that is "1", so how I could replace that orientation property value 3 by 1?

推荐答案

foreach (var prop in img.PropertyItems)
{
      if (prop.Id == 0x0112) //value of EXIF
      {
         var orientation = prop.Value;
         if (orientation == 3)
         {
             prop.Value[0] = 1;
             img.SetPropertyItem(prop);
         }
     }
}


这篇关于C#:如何更改图像方向属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 13:23