Пример #1
0
        public virtual void Extract([NotNull] SequentialReader reader, [NotNull] Com.Drew.Metadata.Metadata metadata)
        {
            reader.SetMotorolaByteOrder(false);
            PcxDirectory directory = new PcxDirectory();

            metadata.AddDirectory(directory);
            try
            {
                sbyte identifier = reader.GetInt8();
                if (identifier != unchecked ((int)(0x0A)))
                {
                    throw new ImageProcessingException("Invalid PCX identifier byte");
                }
                directory.SetInt(PcxDirectory.TagVersion, reader.GetInt8());
                sbyte encoding = reader.GetInt8();
                if (encoding != unchecked ((int)(0x01)))
                {
                    throw new ImageProcessingException("Invalid PCX encoding byte");
                }
                directory.SetInt(PcxDirectory.TagBitsPerPixel, reader.GetUInt8());
                directory.SetInt(PcxDirectory.TagXmin, reader.GetUInt16());
                directory.SetInt(PcxDirectory.TagYmin, reader.GetUInt16());
                directory.SetInt(PcxDirectory.TagXmax, reader.GetUInt16());
                directory.SetInt(PcxDirectory.TagYmax, reader.GetUInt16());
                directory.SetInt(PcxDirectory.TagHorizontalDpi, reader.GetUInt16());
                directory.SetInt(PcxDirectory.TagVerticalDpi, reader.GetUInt16());
                directory.SetByteArray(PcxDirectory.TagPalette, reader.GetBytes(48));
                reader.Skip(1);
                directory.SetInt(PcxDirectory.TagColorPlanes, reader.GetUInt8());
                directory.SetInt(PcxDirectory.TagBytesPerLine, reader.GetUInt16());
                int paletteType = reader.GetUInt16();
                if (paletteType != 0)
                {
                    directory.SetInt(PcxDirectory.TagPaletteType, paletteType);
                }
                int hScrSize = reader.GetUInt16();
                if (hScrSize != 0)
                {
                    directory.SetInt(PcxDirectory.TagHscrSize, hScrSize);
                }
                int vScrSize = reader.GetUInt16();
                if (vScrSize != 0)
                {
                    directory.SetInt(PcxDirectory.TagVscrSize, vScrSize);
                }
            }
            catch (Exception ex)
            {
                directory.AddError("Exception reading PCX file metadata: " + ex.Message);
            }
        }
Пример #2
0
 public virtual void Extract([NotNull] SequentialReader reader, [NotNull] Com.Drew.Metadata.Metadata metadata)
 {
     reader.SetMotorolaByteOrder(false);
     PcxDirectory directory = new PcxDirectory();
     metadata.AddDirectory(directory);
     try
     {
         sbyte identifier = reader.GetInt8();
         if (identifier != unchecked((int)(0x0A)))
         {
             throw new ImageProcessingException("Invalid PCX identifier byte");
         }
         directory.SetInt(PcxDirectory.TagVersion, reader.GetInt8());
         sbyte encoding = reader.GetInt8();
         if (encoding != unchecked((int)(0x01)))
         {
             throw new ImageProcessingException("Invalid PCX encoding byte");
         }
         directory.SetInt(PcxDirectory.TagBitsPerPixel, reader.GetUInt8());
         directory.SetInt(PcxDirectory.TagXmin, reader.GetUInt16());
         directory.SetInt(PcxDirectory.TagYmin, reader.GetUInt16());
         directory.SetInt(PcxDirectory.TagXmax, reader.GetUInt16());
         directory.SetInt(PcxDirectory.TagYmax, reader.GetUInt16());
         directory.SetInt(PcxDirectory.TagHorizontalDpi, reader.GetUInt16());
         directory.SetInt(PcxDirectory.TagVerticalDpi, reader.GetUInt16());
         directory.SetByteArray(PcxDirectory.TagPalette, reader.GetBytes(48));
         reader.Skip(1);
         directory.SetInt(PcxDirectory.TagColorPlanes, reader.GetUInt8());
         directory.SetInt(PcxDirectory.TagBytesPerLine, reader.GetUInt16());
         int paletteType = reader.GetUInt16();
         if (paletteType != 0)
         {
             directory.SetInt(PcxDirectory.TagPaletteType, paletteType);
         }
         int hScrSize = reader.GetUInt16();
         if (hScrSize != 0)
         {
             directory.SetInt(PcxDirectory.TagHscrSize, hScrSize);
         }
         int vScrSize = reader.GetUInt16();
         if (vScrSize != 0)
         {
             directory.SetInt(PcxDirectory.TagVscrSize, vScrSize);
         }
     }
     catch (Exception ex)
     {
         directory.AddError("Exception reading PCX file metadata: " + ex.Message);
     }
 }