Ejemplo n.º 1
0
 public virtual void Extract(sbyte[] segmentBytes, Com.Drew.Metadata.Metadata metadata, JpegSegmentType segmentType)
 {
     JpegDirectory directory = new JpegDirectory();
     metadata.AddDirectory(directory);
     // The value of TAG_COMPRESSION_TYPE is determined by the segment type found
     directory.SetInt(JpegDirectory.TagCompressionType, segmentType.byteValue - JpegSegmentType.Sof0.byteValue);
     SequentialReader reader = new SequentialByteArrayReader(segmentBytes);
     try
     {
         directory.SetInt(JpegDirectory.TagDataPrecision, reader.GetUInt8());
         directory.SetInt(JpegDirectory.TagImageHeight, reader.GetUInt16());
         directory.SetInt(JpegDirectory.TagImageWidth, reader.GetUInt16());
         short componentCount = reader.GetUInt8();
         directory.SetInt(JpegDirectory.TagNumberOfComponents, componentCount);
         // for each component, there are three bytes of data:
         // 1 - Component ID: 1 = Y, 2 = Cb, 3 = Cr, 4 = I, 5 = Q
         // 2 - Sampling factors: bit 0-3 vertical, 4-7 horizontal
         // 3 - Quantization table number
         for (int i = 0; i < (int)componentCount; i++)
         {
             int componentId = reader.GetUInt8();
             int samplingFactorByte = reader.GetUInt8();
             int quantizationTableNumber = reader.GetUInt8();
             JpegComponent component = new JpegComponent(componentId, samplingFactorByte, quantizationTableNumber);
             directory.SetObject(JpegDirectory.TagComponentData1 + i, component);
         }
     }
     catch (IOException ex)
     {
         directory.AddError(ex.Message);
     }
 }
Ejemplo n.º 2
0
        public virtual void Extract(sbyte[] segmentBytes, Com.Drew.Metadata.Metadata metadata, JpegSegmentType segmentType)
        {
            JpegDirectory directory = new JpegDirectory();

            metadata.AddDirectory(directory);
            // The value of TAG_COMPRESSION_TYPE is determined by the segment type found
            directory.SetInt(JpegDirectory.TagCompressionType, segmentType.byteValue - JpegSegmentType.Sof0.byteValue);
            SequentialReader reader = new SequentialByteArrayReader(segmentBytes);

            try
            {
                directory.SetInt(JpegDirectory.TagDataPrecision, reader.GetUInt8());
                directory.SetInt(JpegDirectory.TagImageHeight, reader.GetUInt16());
                directory.SetInt(JpegDirectory.TagImageWidth, reader.GetUInt16());
                short componentCount = reader.GetUInt8();
                directory.SetInt(JpegDirectory.TagNumberOfComponents, componentCount);
                // for each component, there are three bytes of data:
                // 1 - Component ID: 1 = Y, 2 = Cb, 3 = Cr, 4 = I, 5 = Q
                // 2 - Sampling factors: bit 0-3 vertical, 4-7 horizontal
                // 3 - Quantization table number
                for (int i = 0; i < (int)componentCount; i++)
                {
                    int           componentId             = reader.GetUInt8();
                    int           samplingFactorByte      = reader.GetUInt8();
                    int           quantizationTableNumber = reader.GetUInt8();
                    JpegComponent component = new JpegComponent(componentId, samplingFactorByte, quantizationTableNumber);
                    directory.SetObject(JpegDirectory.TagComponentData1 + i, component);
                }
            }
            catch (IOException ex)
            {
                directory.AddError(ex.Message);
            }
        }
Ejemplo n.º 3
0
        public static JpegDirectory ProcessBytes(string filePath)
        {
            Com.Drew.Metadata.Metadata metadata = new Com.Drew.Metadata.Metadata();
            new JpegReader().Extract(FileUtil.ReadBytes(filePath), metadata, JpegSegmentType.Sof0);
            JpegDirectory directory = metadata.GetDirectory <JpegDirectory>();

            NUnit.Framework.Assert.IsNotNull(directory);
            return(directory);
        }
Ejemplo n.º 4
0
 public virtual void SetUp()
 {
     _directory = ProcessBytes("Tests/Data/simple.jpg.sof0");
 }
 public virtual void SetUp()
 {
     _directory  = new JpegDirectory();
     _descriptor = new JpegDescriptor(_directory);
 }
		public virtual void SetUp()
		{
			_directory = new JpegDirectory();
			_descriptor = new JpegDescriptor(_directory);
		}
 public virtual void SetUp()
 {
     _directory = new JpegDirectory();
 }
 public virtual void SetUp()
 {
     _directory = ProcessBytes("Tests/Data/simple.jpg.sof0");
 }
 public virtual void SetUp()
 {
     _directory = new JpegDirectory();
 }