AviMemDc: a C++ class

创建AVI文件的C++类详解
本文详细介绍了AviMemDC类,一个用于创建AVI文件的C++类,包括其用法、功能和许可协议。通过使用此类,开发者可以轻松地将图像数据打包成AVI文件,同时提供了源代码的自由使用、修改和重新分发权限。

AviMemDc: a C++ class
        
This class is used in the Avi Examples.
The header file
AviMemDC.h

/*
   AviMemDC.h

   A C++ class for creating avi files

   Copyright (c) 2004, 2005 René Nyffenegger

   This source code is provided 'as-is', without any express or implied
   warranty. In no event will the author be held liable for any damages
   arising from the use of this software.

   Permission is granted to anyone to use this software for any purpose,
   including commercial applications, and to alter it and redistribute it
   freely, subject to the following restrictions:

   1. The origin of this source code must not be misrepresented; you must not
      claim that you wrote the original source code. If you use this source code
      in a product, an acknowledgment in the product documentation would be
      appreciated but is not required.

   2. Altered source versions must be plainly marked as such, and must not be
      misrepresented as being the original source code.

   3. This notice may not be removed or altered from any source distribution.

   René Nyffenegger rene.nyffenegger@adp-gmbh.ch

*/

#include "MemoryDC.h"
#include "DibSection.h"
#include "Color.h"
#include "Font.h"
#include "avi.h"

class AviMemDC : public MemoryDC {

  public:
    AviMemDC(int width, int height, std::string const& avi_file, int frames_per_second);

    void AddFrame();

    DibSection& GetDibSection();

  private:
    DibSection dib_section_;
    Avi        avi_;

    bool       compression_chosen_;
};

The implementation file
AviMemDC.cpp

/*
   AviMemDC.cpp

   A C++ class for creating avi files

   Copyright (c) 2004, 2005 René Nyffenegger

   This source code is provided 'as-is', without any express or implied
   warranty. In no event will the author be held liable for any damages
   arising from the use of this software.

   Permission is granted to anyone to use this software for any purpose,
   including commercial applications, and to alter it and redistribute it
   freely, subject to the following restrictions:

   1. The origin of this source code must not be misrepresented; you must not
      claim that you wrote the original source code. If you use this source code
      in a product, an acknowledgment in the product documentation would be
      appreciated but is not required.

   2. Altered source versions must be plainly marked as such, and must not be
      misrepresented as being the original source code.

   3. This notice may not be removed or altered from any source distribution.

   René Nyffenegger rene.nyffenegger@adp-gmbh.ch

*/

#include "AviMemDC.h"

AviMemDC::AviMemDC(int width, int height, std::string const& avi_file, int frames_per_second) :
  MemoryDC(),
  dib_section_(width, height),
  avi_(avi_file, 1000/frames_per_second, 0),
  compression_chosen_(false)
{
  Select(dib_section_);
}

void AviMemDC::AddFrame() {
  if (!compression_chosen_) {
    avi_.compression(dib_section_, 0, true, 0);
    compression_chosen_ = true;
  }
  avi_.add_frame(dib_section_);
}

DibSection& AviMemDC::GetDibSection() {
  return dib_section_;
}

 

转载于:https://www.cnblogs.com/honeynm/p/4695857.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值