使用C 使用CAD插件在打开时缓慢
创始人
2024-05-03 22:10:52
0

 一、什么是EXIF

Exif是英文Exchangeable Image File(可交换图像文件)的缩写,最初由日本电子工业发展协会(JEIDA --Japan Electronic Industry Development Association) 制订,目前的最新版本是发表于2002年04月的2.21 版。国际标准化组织(ISO)正在制订的相机文件设计标准(DCF -- Design role for Camera File system)可能以Exif2.1为基础。

所有的JPEG文件以字符串“0xFFD8”开头,并以字符串“0xFFD9”结束。文件头中有一系列“0xFF??”格式的字符串,称为“标识”,用来标记JPEG文件的信息段。“0xFFD8”表示图像信息开始,“0xFFD9”表示图像信息结束,这两个标识后面没有信息,而其它标识紧跟一些信息字符。

0xFFE0 -- 0xFFEF之间的标识符称为“应用标记”,没有被常规JPEG文件利用,Exif正是利用这些信息串记录拍摄信息如快门速度、光圈值等,甚至可以包括全球定位信息。其中拍摄方向的ID为“0x0112”,有1至8共8种值。而C#旋转图片可以通过EXIF来实现。

EXIF图1

二、EXIF Orientation

  1. Orientation   
  2. The image orientation viewed in terms of rows and columns.   
  3. Tag = 274 (112.H)   
  4. Type = SHORT   
  5. Count = 1   
  6. Default = 1   
  7. 1 = The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.   
  8. 2 = The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.   
  9. 3 = The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.   
  10. 4 = The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.   
  11. 5 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual top.   
  12. 6 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual top.   
  13. 7 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.   
  14. 8 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.   
  15. Other = reserved 

三、使用C#旋转图片

  1. public static void rotating(Bitmap img,ref int width, ref int height, int orien)  
  2. {  
  3.     int ow = width;  
  4.     switch (orien)  
  5.     {  
  6.         case 2:  
  7.             img.RotateFlip(RotateFlipType.RotateNoneFlipX);//horizontal flip  
  8.             break;  
  9.         case 3:  
  10.             img.RotateFlip(RotateFlipType.Rotate180FlipNone);//right-top  
  11.             break;  
  12.         case 4:  
  13.             img.RotateFlip(RotateFlipType.RotateNoneFlipY);//vertical flip  
  14.             break;  
  15.         case 5:  
  16.             img.RotateFlip(RotateFlipType.Rotate90FlipX);  
  17.             break;  
  18.         case 6:  
  19.             img.RotateFlip(RotateFlipType.Rotate90FlipNone);//right-top  
  20.             width = height;  
  21.             height = ow;  
  22.             break;  
  23.         case 7:  
  24.             img.RotateFlip(RotateFlipType.Rotate270FlipX);  
  25.             break;  
  26.         case 8:  
  27.             img.RotateFlip(RotateFlipType.Rotate270FlipNone);//left-bottom  
  28.             width = height;  
  29.             height = ow;  
  30.             break;  
  31.         default:  
  32.             break;  
  33.     }  

至此,使用C#旋转图片的目的就达到了。

【编辑推荐】

  1. C#代码与#函数相互调用问题集锦
  2. 如何使用泛型达到代码重用的目的
  3. 线性链表测试方法简介
  4. 创建一个简单的线性链表
  5. C#事件模型的一个实例

相关内容

热门资讯

如何允许远程连接到MySQL数... [[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...
如何利用交换机和端口设置来管理... 在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...
施耐德电气数据中心整体解决方案... 近日,全球能效管理专家施耐德电气正式启动大型体验活动“能效中国行——2012卡车巡展”,作为该活动的...
Windows恶意软件20年“... 在Windows的早期年代,病毒游走于系统之间,偶尔删除文件(但被删除的文件几乎都是可恢复的),并弹...
20个非常棒的扁平设计免费资源 Apple设备的平面图标PSD免费平板UI 平板UI套件24平图标Freen平板UI套件PSD径向平...
德国电信门户网站可实时显示全球... 德国电信周三推出一个门户网站,直观地实时提供其安装在全球各地的传感器网络检测到的网络攻击状况。该网站...
着眼MAC地址,解救无法享受D... 在安装了DHCP服务器的局域网环境中,每一台工作站在上网之前,都要先从DHCP服务器那里享受到地址动...
为啥国人偏爱 Mybatis,... 关于 SQL 和 ORM 的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行...