diff --git a/SharpAvi/Codecs/FlipUncompressedVideoEncoder.cs b/SharpAvi/Codecs/FlipUncompressedVideoEncoder.cs new file mode 100644 index 0000000..8064acd --- /dev/null +++ b/SharpAvi/Codecs/FlipUncompressedVideoEncoder.cs @@ -0,0 +1,64 @@ +using System.Diagnostics.Contracts; + +namespace SharpAvi.Codecs +{ + /// + /// Flip bitmap vertically without compression (from top-down to bottom-up). + /// + public class UniversalUncompressedVideoEncoder : IVideoEncoder + { + private readonly int _width; + private readonly int _height; + private readonly BitsPerPixel _bitsPerPixel; + private readonly int _bytesPerPixel; + + + public UniversalUncompressedVideoEncoder(int width, int height, BitsPerPixel bitsPerPixel) + { + Contract.Requires(width > 0); + Contract.Requires(height > 0); + + _width = width; + _height = height; + _bitsPerPixel = bitsPerPixel; + _bytesPerPixel = (int)bitsPerPixel / 8; + } + + #region IVideoEncoder Members + + /// Video codec. + public FourCC Codec + { + get { return KnownFourCCs.Codecs.Uncompressed; } + } + + /// + /// Number of bits per pixel in encoded image. + /// + public BitsPerPixel BitsPerPixel + { + get { return _bitsPerPixel; } + } + + /// + /// Maximum size of encoded frame. + /// + public int MaxEncodedSize + { + get { return _width * _height * _bytesPerPixel; } + } + + /// + /// Encodes a frame. + /// + /// + public int EncodeFrame(byte[] source, int srcOffset, byte[] destination, int destOffset, out bool isKeyFrame) + { + BitmapUtils.FlipVertical(source, srcOffset, destination, destOffset, _height, _width * _bytesPerPixel); + isKeyFrame = true; + return MaxEncodedSize; + } + + #endregion + } +} \ No newline at end of file diff --git a/SharpAvi/SharpAvi.csproj b/SharpAvi/SharpAvi.csproj index 3e4a3d7..70fd74f 100644 --- a/SharpAvi/SharpAvi.csproj +++ b/SharpAvi/SharpAvi.csproj @@ -140,6 +140,7 @@ +