问题描述
|
我遇到一个问题,即C#中的Bitmap类无法正确加载CCITT T.6 Tiff文件,它将翻转它,因此高度为宽度,宽度为高度。
有没有人做过这些并且知道正确的处理方法?
编辑:
这是代码:
Bitmap B = new Bitmap(@\"C:\\test2.tif\");
Debug.WriteLine(B.Width); //returns 1728
Debug.WriteLine(B.Height); //returns 1127
当我在.net图片框中显示它时(SizeMode设置为Normal),它也显示不正确(拉伸)。但是,如果我使用Windows Photo Viewer打开它,则显示正确。
这些是tiff文件中可用的标签:
SubFileType (1 Long): Page
ImageWidth (1 Long): 1728
ImageLength (1 Long): 1127
BitsPerSample (1 Short): 1
Compression (1 Short): Group 4 Fax (aka CCITT FAX4)
Photometric (1 Short): MinIsWhite
FillOrder (1 Short): Lsb2Msb
StripOffsets (1 Long): 8
SamplesPerPixel (1 Short): 1
RowsPerStrip (1 Long): 1127
StripByteCounts (1 Long): 14764
XResolution (1 Rational): 204
YResolution (1 Rational): 98
Group3Options (1 Long): 5
ResolutionUnit (1 Short): Inch
PageNumber (2 Short): 0,0
Software (32 ASCII): Windows NT Fax Server
CleanFaxData (1 Short): 0
ConsecutiveBadFaxLines (1 Short): 0
37680 (5632 Undefined):
40003 (26 ASCII): U.S. Robotics 56K FAX EXT
40005 (1 ASCII):
40046 (1 Long): 1
40047 (1 Long): 4
40048 (1 Long): 256
40049 (1 Long): 18
40051 (1 SRational):
40052 (1 SRational):
40053 (1 Long): 2
解决方法
TIFF可以具有定义图像行中数据方向的标签。这个标签在LibTiff中称为
TIFFTAG_ORIENTATION
。
一些值是:
1 =第0行代表图像的视觉上端,第0列代表视觉的左手边。
5 =第0行代表图像的视觉左侧,第0列代表视觉顶部。
根据这篇文章:
TIFF标签方向
许多读者会忽略此标签。
我怀疑Microsoft .NET 3类是这些阅读器之一,并且您的图像中包含该标签。