宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取

注意:一系列文章涉及ffdshow位图覆盖过滤器的源代码分析,在此列出:

ffdshow源代码分析2 :位图覆盖过滤器(对话框部分诊断) () ) ) ) ) ) ) ) ) ) )。

ffdshow源代码分析3 :位图覆盖过滤器(设置) () ) ) ) ) ) ) ) ) ) )。

ffdshow源代码分析4 :位图覆盖滤波器(滤波器部分Filter ) )。

ffdshow源代码分析5 :位图覆盖滤波器(汇总) () ) ) ) ) ) ) ) ) ) ) ) )

上一篇文章介绍了ffdshow的“位图覆盖过滤器”对话框(“诊断”部分);ffdshow源代码分析2 )“位图覆盖过滤器”对话框部分(诊断)

这里还介绍了“设置”(Settings ),还有另一个过滤器部分(Filter )。 这三个部分可以构成一个ffdshow的滤镜功能。

设置部分(Settings)

ffdshow中的“过滤器设置”(Settings )主要用于存储执行过滤器所需的各种变量。 一般来说,通过读取注册表变量并将其分配给该类中的变量,可以完成操作相应过滤器的功能。

用于设置位图叠加(位图)滤镜的类包括位于settings-filters-video目录下的TbitmapSettings.cpp文件和TbitmapSettings.h缓冲区

先来看看TbitmapSettings.h

此类的名称为TbitmapSettings,如类的定义所示。

flnm[]保存打开的位图的路径

posx,posy包含位图在屏幕上显示的位置

mode包含显示方法

与该过滤器(过滤器)相关的所有数据都存储在该类中。

此类包含TfilterIDFF类型的结构IDffs,用于存储过滤器的部分属性信息,如名称、ID和属性对话框ID

另外,还有两个重要的函数。 createFilters ()用于创建过滤器)。 用于创建createPages ()滤镜的“设置”对话框() Dialog )。

# ifndef _ tbitmap settings _ h _ # define _ tbitmap settings _ h _ /每个过滤器的默认值# include ‘ tfiltersettings.h ‘ # iii protected : virtual constint * get resets (unsignedintpageid ); public : tbitmap settings (tintstrcoll * icoll=null,TfilterIDFFs *filters=NULL ); //Bitmap文件路径char_t flnm[MAX_PATH]; //x、y坐标和坐标模式int posx、posy、pos模式; int align; //重叠方式enum { MODE_BLEND=0,MODE_DARKEN=1,MODE_LIGHTEN=2,MODE_ADD=3,MODE_SOFTLIGHT=4,mode 静态常数char _ t * modes [ ]; int strength; //filtervirtualvoidcreatefilters (size _ tfiltersorder,Tfilters *filters,TfilterQueue queue ) const; //属性页面virtualvoidcreatepages (tffdshowpagedec * parent ) const; virtualboolgettip (unsignedintpageid,char_t *buf,size_t buflen ); (; #endif

33558 www.Sina.com/tbitmap settings.CPP

此类包含TbitmapSettings类中函数方法的具体实现。 让我们先看看构造函数TbitmapSettings ()。 从构造函数中可以看到,类中的变量和注册表变量绑定为一对一的关系。 其他函数我不详细叙述,但是比较简单,容易理解。

/* *版权所有(c ) 2004-2006 Milan Cutka *

* This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */#include “stdafx.h”#include “TbitmapSettings.h”#include “TimgFilterBitmap.h”#include “Cbitmap.h”#include “TffdshowPageDec.h”#include “TsubtitlesSettings.h”//几种叠加方式const char_t* TbitmapSettings::modes[] = { _l(“blend”), _l(“darken”), _l(“lighten”), _l(“add”), _l(“softlight”), _l(“exclusion”), NULL};//Filter属性const TfilterIDFF TbitmapSettings::idffs = { /*name*/ _l(“Bitmap overlay”), /*id*/ IDFF_filterBitmap, /*is*/ IDFF_isBitmap, /*order*/ IDFF_orderBitmap, /*show*/ IDFF_showBitmap, /*full*/ IDFF_fullBitmap, /*half*/ 0, /*dlgId*/ IDD_BITMAP,};//构造函数TbitmapSettings::TbitmapSettings(TintStrColl *Icoll, TfilterIDFFs *filters): TfilterSettingsVideo(sizeof(*this), Icoll, filters, &idffs){ half = 0; memset(flnm, 0, sizeof(flnm));//绑定变量 static const TintOptionT<TbitmapSettings> iopts[] = { IDFF_isBitmap , &TbitmapSettings::is , 0, 0, _l(“”), 1, _l(“isBitmap”), 0, IDFF_showBitmap , &TbitmapSettings::show , 0, 0, _l(“”), 1, _l(“showBitmap”), 1, IDFF_orderBitmap , &TbitmapSettings::order , 1, 1, _l(“”), 1, _l(“orderBitmap”), 0, IDFF_fullBitmap , &TbitmapSettings::full , 0, 0, _l(“”), 1, _l(“fullBitmap”), 0, IDFF_bitmapPosx , &TbitmapSettings::posx , -4096, 4096, _l(“”), 1, _l(“bitmapPosX”), 50, IDFF_bitmapPosy , &TbitmapSettings::posy , -4096, 4096, _l(“”), 1, _l(“bitmapPosY”), 50, IDFF_bitmapPosmode , &TbitmapSettings::posmode , 0, 1, _l(“”), 1, _l(“bitmapPosMode”), 0, IDFF_bitmapAlign , &TbitmapSettings::align , 0, 3, _l(“”), 1, _l(“bitmapAlign”), ALIGN_CENTER, IDFF_bitmapMode , &TbitmapSettings::mode , 0, 5, _l(“”), 1, _l(“bitmapMode”), 0, IDFF_bitmapStrength , &TbitmapSettings::strength , 0, 256, _l(“”), 1, _l(“bitmapStrength”), 128, 0 }; addOptions(iopts); static const TstrOption sopts[] = { IDFF_bitmapFlnm , (TstrVal)&TbitmapSettings::flnm , MAX_PATH, 0, _l(“”), 1, _l(“bitmapFlnm”), _l(“”), 0 }; addOptions(sopts); static const TcreateParamList1 listMode(modes); setParamList(IDFF_bitmapMode, &listMode); static const TcreateParamList1 listAlign(TsubtitlesSettings::alignments); setParamList(IDFF_bitmapAlign, &listAlign);}//创建Filtervoid TbitmapSettings::createFilters(size_t filtersorder, Tfilters *filters, TfilterQueue &queue) const{ idffOnChange(idffs, filters, queue.temporary); if (is && show) { queueFilter<TimgFilterBitmap>(filtersorder, filters, queue); }}//创建属性页面void TbitmapSettings::createPages(TffdshowPageDec *parent) const{ parent->addFilterPage<TbitmapPage>(&idffs);}const int* TbitmapSettings::getResets(unsigned int pageId){ static const int idResets[] = { IDFF_bitmapPosx, IDFF_bitmapPosy, IDFF_bitmapPosmode, IDFF_bitmapAlign, IDFF_bitmapMode, IDFF_bitmapStrength, 0 }; return idResets;}bool TbitmapSettings::getTip(unsigned int pageId, char_t *tipS, size_t len){ if (flnm[0]) { tsnprintf_s(tipS, len, _TRUNCATE, _l(“%s %s”), modes[mode], flnm); tipS[len – 1] = ‘\0’; } else { tipS[0] = ‘\0’; } return true;}