using System;
using System.Collections;
using System.IO;
using com.drew.metadata;
///
/// This class was first written by Drew Noakes in Java.
///
/// This is public domain software - that is, you can do whatever you want
/// with it, and include it software that is licensed under the GNU or the
/// BSD license, or whatever other licence you choose, including proprietary
/// closed source licenses. I do ask that you leave this header in tact.
///
/// If you make modifications to this code that you think would benefit the
/// wider community, please send me a copy and I'll post it on my site.
///
/// If you make use of this code, Drew Noakes will appreciate hearing
/// about it: drew@drewnoakes.com
///
/// Latest Java version of this software kept at
/// http://drewnoakes.com/
///
/// The C# class was made by Ferret Renaud:
/// renaud91@free.fr
/// If you find a bug in the C# code, feel free to mail me.
///
namespace com.drew.metadata.jpeg
{
///
/// The Jpeg component class
///
[Serializable]
public class JpegComponent
{
private int _componentId;
private int _samplingFactorByte;
private int _quantizationTableNumber;
///
/// The constructor of the object
///
/// the component id
/// the sampling factor byte
/// the quantization table number
public JpegComponent(
int componentId,
int samplingFactorByte,
int quantizationTableNumber) : base()
{
_componentId = componentId;
_samplingFactorByte = samplingFactorByte;
_quantizationTableNumber = quantizationTableNumber;
}
///
/// Gets the component id
///
/// the component id
public int GetComponentId()
{
return _componentId;
}
///
/// The component name
///
/// The component name
public string GetComponentName()
{
switch (_componentId)
{
case 1 :
return "Y";
case 2 :
return "Cb";
case 3 :
return "Cr";
case 4 :
return "I";
case 5 :
return "Q";
}
throw new MetadataException("Unsupported component id: " + _componentId);
}
///
/// Gets the Quantization Table Number
///
/// the Quantization Table Number
public int GetQuantizationTableNumber()
{
return _quantizationTableNumber;
}
///
/// Gets the Horizontal Sampling Factor
///
/// the Horizontal Sampling Factor
public int GetHorizontalSamplingFactor()
{
return _samplingFactorByte & 0x0F;
}
///
/// Gets the Vertical Sampling Factor
///
/// the Vertical Sampling Factor
public int GetVerticalSamplingFactor()
{
return (_samplingFactorByte >> 4) & 0x0F;
}
}
}