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


C# Tiff.FieldWithTag方法代码示例

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


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

示例1: SetField


//.........这里部分代码省略.........
                        if ((fip.PassCount ||
                            fip.WriteCount == TiffFieldInfo.Variable ||
                            fip.WriteCount == TiffFieldInfo.Variable2 ||
                            fip.WriteCount == TiffFieldInfo.Spp ||
                            td.td_customValues[tvIndex].count > 1) &&
                            fip.Tag != TiffTag.PAGENUMBER &&
                            fip.Tag != TiffTag.HALFTONEHINTS &&
                            fip.Tag != TiffTag.YCBCRSUBSAMPLING &&
                            fip.Tag != TiffTag.DOTRANGE)
                        {
                            byte[] apBytes = value[paramIndex++].GetBytes();
                            Buffer.BlockCopy(apBytes, 0, td.td_customValues[tvIndex].value, 0, Math.Min(apBytes.Length, td.td_customValues[tvIndex].value.Length));
                        }
                        else
                        {
                            // XXX: The following loop required to handle
                            // PAGENUMBER, HALFTONEHINTS,
                            // YCBCRSUBSAMPLING and DOTRANGE tags.
                            // These tags are actually arrays and should be
                            // passed as arrays to SetField() function, but
                            // actually passed as a list of separate values.
                            // This behavior must be changed in the future!

                            // Upd: This loop also processes some EXIF tags with
                            // UNDEFINED type (like EXIF_FILESOURCE or EXIF_SCENETYPE)
                            // In this case input value is string-based, so
                            // in TiffType.UNDEFINED case we use FieldValue.GetBytes()[0]
                            // construction instead of direct call of FieldValue.ToByte() method.
                            byte[] val = td.td_customValues[tvIndex].value;
                            int valPos = 0;
                            for (int i = 0; i < td.td_customValues[tvIndex].count; i++, valPos += tv_size)
                            {
                                switch (fip.Type)
                                {
                                    case TiffType.BYTE:
                                    case TiffType.UNDEFINED:
                                        val[valPos] = value[paramIndex + i].GetBytes()[0];
                                        break;
                                    case TiffType.SBYTE:
                                        val[valPos] = value[paramIndex + i].ToByte();
                                        break;
                                    case TiffType.SHORT:
                                        Buffer.BlockCopy(BitConverter.GetBytes(value[paramIndex + i].ToShort()), 0, val, valPos, tv_size);
                                        break;
                                    case TiffType.SSHORT:
                                        Buffer.BlockCopy(BitConverter.GetBytes(value[paramIndex + i].ToShort()), 0, val, valPos, tv_size);
                                        break;
                                    case TiffType.LONG:
                                    case TiffType.IFD:
                                        Buffer.BlockCopy(BitConverter.GetBytes(value[paramIndex + i].ToInt()), 0, val, valPos, tv_size);
                                        break;
                                    case TiffType.SLONG:
                                        Buffer.BlockCopy(BitConverter.GetBytes(value[paramIndex + i].ToInt()), 0, val, valPos, tv_size);
                                        break;
                                    case TiffType.RATIONAL:
                                    case TiffType.SRATIONAL:
                                    case TiffType.FLOAT:
                                        Buffer.BlockCopy(BitConverter.GetBytes(value[paramIndex + i].ToFloat()), 0, val, valPos, tv_size);
                                        break;
                                    case TiffType.DOUBLE:
                                        Buffer.BlockCopy(BitConverter.GetBytes(value[paramIndex + i].ToDouble()), 0, val, valPos, tv_size);
                                        break;
                                    default:
                                        Array.Clear(val, valPos, tv_size);
                                        status = false;
                                        break;
                                }
                            }
                        }
                    }
                    break;
            }

            if (!end && !badvalue && !badvalue32)
            {
                if (status)
                {
                    tif.setFieldBit(tif.FieldWithTag(tag).Bit);
                    tif.m_flags |= TiffFlags.DIRTYDIRECT;
                }
            }

            if (badvalue)
            {
                Tiff.ErrorExt(tif, tif.m_clientdata, module,
                    "{0}: Bad value {1} for \"{2}\" tag",
                    tif.m_name, v, tif.FieldWithTag(tag).Name);
                return false;
            }

            if (badvalue32)
            {
                Tiff.ErrorExt(tif, tif.m_clientdata, module,
                    "{0}: Bad value {1} for \"{2}\" tag",
                    tif.m_name, v32, tif.FieldWithTag(tag).Name);
                return false;
            }

            return status;
        }
开发者ID:dronab,项目名称:libtiff.net,代码行数:101,代码来源:TiffTagMethods.cs


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