`
xzknet
  • 浏览: 311024 次
  • 性别: Icon_minigender_1
  • 来自: 河南
文章分类
社区版块
存档分类
最新评论

用delphi编写图片播放组件

阅读更多
...{ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::  Author:pengyi    Email:pengyi.yi@
126.com    ::
:: ::
:: Unit : UnitImagePlay ::
:: ::
:: Developer Team : Mdcl DevTeam ::
:: $Id: UnitImagePlay.pas,v 
1.13 2006/07/13 08:22:24 Exp $ ::
:: ::
:: Created Date : 
2005-12-8 ::
:: Last Modified: $Date: 
2006/07/13 08:22:24 $ ::
:: Last Modifier: $Author:pengyi $ ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: }


unit UnitImagePlay;

interface
uses Messages, Windows, SysUtils, Classes, CutlineU,
  Controls, Forms, ExtCtrls, Graphics, StdCtrls, Dialogs;
type
  TXPImage 
= class;

  TShowPicture 
= class(TThread)
  
private
    Fidx: integer; 
...{当时显示的数}
//I:integer;
    FItem: TXPImage;
  
protected
    procedure Execute; 
override;
  
public
    procedure SetPicture;
    constructor Create(Aowner: TXPImage);
  end;

  TXPImage 
= class(TComponent)
  
private
    FActive: Boolean; 
//当前是否激活
    FInterval: Integer;
//FTimer :TTimer;
    FImgbmp: TBitmap;
//FImage: TImage;
    FImage: TCutline;
    FImageList: TImageList;
    FshowPic: TShowPicture;
    procedure SetActive(Value: Boolean); 
virtual;
    procedure SetInterval(Value: Integer);
    procedure SetImageList(Value: TImageList);
    procedure SetImage(Value: TCutline);
  
public
    constructor Create(AOwner: TComponent); 
override;
    destructor Destroy; 
override;
    procedure Start;
// Procedure Pause;
//Procedure Continue;
    procedure Stop;
    property Active: Boolean read FActive write SetActive;
    property Interval: Integer read FInterval write SetInterval;
    property Imgbmp: TBitmap read FImgbmp write FImgbmp;
    property ImageList: TImageList read FImageList write SetImageList;
//Property Image:TImage Read FImage Write SetImage;
    property Image: TCutline read FImage write SetImage;
//Property showPic:TShowPicture Read FshowPic;
  end;

implementation

uses
  CommonU, DbugIntf;

...{ TXPImage }

constructor TXPImage.Create(AOwner: TComponent);
begin
  inherited;
  FInterval :
= 800;
  FImgbmp :
= TBitmap.Create;
//FImage := TCutline.Create(AOwner);
//FImageList := TImageList.Create(AOwner);
//FTimer := TTimer.Create(AOwner);
//FImage := TImage.Create(AOwner);
end;

destructor TXPImage.Destroy;
begin
  
if Assigned(FImgbmp) then
    FImgbmp.Free;
//FTimer.Free;
//FImage.Free;
//FImageList.Free;
  inherited;
end;

procedure TXPImage.SetActive(Value: Boolean);
begin
  FActive :
= Value;
  
if (FshowPic <> nil) and Value then
    FshowPic :
= TShowPicture.Create(Self)
  
else
    FshowPic.Terminate;
end;

procedure TXPImage.SetImageList(Value: TImageList);
begin
  FImageList :
= Value;
end;

procedure TXPImage.SetInterval(Value: Integer);
begin
  FInterval :
= value;
end;

procedure TXPImage.SetImage(Value: TCutline);
begin
  FImage :
= Value;
end;

procedure TXPImage.Start;
begin
  FActive :
= true;
//创建线程
  FshowPic := TShowPicture.Create(Self);
//FshowPic.Resume;
end;

procedure TXPImage.Stop;
begin
//FActive:= false;
  if FshowPic <> nil then
  begin
    FshowPic.Terminate;
    FshowPic :
= nil;
  end;
end;

...{procedure TXPImage.Continue;
begin
IF FshowPic
<> nil then
begin
FActive:
= true;
FshowPic.Resume;
end;
end;

procedure TXPImage.Pause;
begin
IF FshowPic
<> nil then
FActive:
= false;
end;}


...{ TShowPicture }

constructor TShowPicture.Create(Aowner: TXPImage);
begin
  inherited Create(
false);
  FItem :
= Aowner;
  Fidx :
= 0;
  FreeOnTerminate :
= true;
end;

procedure TShowPicture.Execute;
//var
// nTickCount: Cardinal;
begin
  inherited;
  
while not Terminated do
  begin
    
if FItem.Active then
    begin
//Application.ProcessMessages;
      synchronize(SetPicture); ...{注意此处}
      Fidx :
= Fidx + 1;
      
if Fidx >= FItem.FImageList.Count then
        Fidx :
= 0;
      
if terminated then
        exit;
//Item.;
      Sleep(FItem.FInterval);

// nTickCount := GetTickCount;
// while FItem.Active and (GetTickCount - nTickCount < FItem.FInterval) do
// Application.ProcessMessages;
    end
    
else
    begin
      Suspend;
    end;
  end;
end;

procedure TShowPicture.SetPicture;
var
  sMsg: 
string;
begin

//SendMethodEnter(Format('“%s” 播放动画中的设置图片', [FItem.Image.Caption]));
  if FItem.Imgbmp <> nil then
  begin
    
try
//SendDebug('开始从 Imagelist 中获取图片');
      FItem.FImageList.GetBitmap(Fidx, FItem.Imgbmp);
//SendDebug('完成从 Imagelist 中获取图片');
//FItem.FImageList.GetBitmap(Fidx,FItem.FImage.Picture.Bitmap);
//SendDebug('开始从把图片给 Cutline 图片');
      FItem.Image.SetImage(FItem.Imgbmp);
//SendDebug('完成从把图片给 Cutline 图片');
//SendDebug('开始刷新 Cutline');
//FItem.FImage.Refresh;
//SendDebug('完成刷新 Cutline');
      application.ProcessMessages;
    except
      on E: Exception 
do
      begin
        sMsg :
= Format('错误位置:[%s] 类:[%s] 名称:[%s] 错误类:[%s] 错误信息:[%s]',
          [
'播放动画', ClassName, FItem.Image.Caption, E.ClassName, E.Message]);
        SendDebugEx(sMsg, mtError);
        WriteLog(sMsg);
      end;
    end;
  end;
//SendMethodExit(Format('“%s” 播放动画中的设置图片', [FItem.Image.Caption]));
//SendSeparator;

end;

end.
 
分享到:
评论

相关推荐

    Delphi 图片滚动播放

    综上所述,实现Delphi中的图片滚动播放主要涉及TImage组件的使用、图片的加载和定时器事件的处理。通过灵活运用这些组件和技巧,你可以创建出一个功能完善的图片播放器。在实际开发中,还可以根据需求进一步扩展功能...

    Delphi编写的 COM+组件范例

    本篇文章将深入探讨使用Delphi编写COM+组件的相关知识点,并结合提供的文件名来阐述其主要应用领域。 首先,"Delphi编写的 COM+组件实现客户端、服务器回调"这部分内容涉及到的是分布式系统中的通信机制。在COM+中...

    Delphi编写组件扩展ASP的功能delphi源码

    标题“Delphi编写组件扩展ASP的功能delphi源码”揭示了这次我们要探讨的核心技术:如何通过Delphi创建自定义组件,并将这些组件集成到ASP应用中,增强其处理逻辑或增加新的特性。这通常涉及到对COM(Component ...

    Delphi7组件编写者指南

    8. **文档和调试**:编写组件时,文档和调试同样重要。学习如何使用Delphi的内置帮助系统创建组件文档,以及如何利用IDE中的调试工具进行组件测试。 9. **高级话题**:涵盖多线程组件、ActiveX控件、组件间通信等...

    Delphi组件编写指南

    Delphi 组件编写指南是 Delphi 编程语言中编写控件的详细指南,对于编写 Delphi 组件的方法进行了详细的阐述,涵盖了组件创建、类库、控件修改、窗口控件、图形控件、子类化 Windows 控件、非可视组件等方面的内容。...

    Delphi组件编写者指南.rar

    本指南将深入探讨如何在Delphi中编写自己的组件,这对于提升应用程序的功能性和可重用性至关重要。 1. 组件基础 组件是预编译的代码单元,封装了特定的功能,可以在Delphi的可视化界面中拖放使用。它们通常继承自...

    Delphi COM组件编程实例.rar

    Delphi COM组件编程实例,例子不多,不过都挺实用,包括:  Delphi实现的com 组件数据库连接池  delphi实现的COM 组件处理数据库Blob字段  Delphi编写的 COM 组件实现客户端、服务器回调

    delphi编写windows服务程序

    标题 "Delphi编写Windows服务程序" 涉及的核心知识点主要集中在使用Delphi这一编程环境来创建能够在Windows操作系统后台...通过学习和理解这些代码,开发者可以掌握在Windows环境下用Delphi编写服务程序的技巧和实践。

    AES加密组件(Delphi编写)

    AES加密组件是基于高级加密标准(Advanced Encryption...同时,由于是用Delphi编写,与Delphi环境的兼容性和性能都将得到保证。在实际应用中,可以结合其他安全措施,如数字签名和完整性校验,以构建更完善的安全系统。

    Delphi7~Delphi2010 JSON 读写组件(源码)

    `tests`目录则可能包含了一些单元测试,用以验证组件的功能和性能,这对于确保代码质量和稳定性非常关键。 在使用这个JSON组件时,开发者需要注意以下几点: 1. **安装和导入**:将源代码文件添加到Delphi项目中,...

    delphi ACM语音组件for 2010源码

    总的来说,"delphi ACM语音组件for 2010源码" 提供了一套完整的音频处理解决方案,包括播放、采集和格式设置功能,适合于开发需要音频处理能力的Delphi应用程序。通过深入理解和熟练运用这些组件,开发者可以创建出...

    delphi编写的计算器

    本项目是一个用Delphi编写的简单计算器,它实现了基本的数学运算,包括加法、减法、乘法和除法。这个计算器可以作为一个基础学习项目,帮助初学者了解Delphi编程以及GUI(图形用户界面)的设计。 首先,让我们深入...

    delphi视频显示组件

    "delphi视频显示组件"是一个用户自定义的解决方案,旨在提供一种简便的方式在Delphi应用程序中展示视频流。Delphi是一款强大的Windows应用程序开发工具,以其高效的代码生成和直观的可视化设计界面而闻名。下面将...

    用Delphi编写MHT图片提取工具..rar

    在本压缩包中,"用Delphi编写MHT图片提取工具"是一个利用Delphi编程语言编写的程序,该程序专门用于从MHT(MHTML,即单个文件网页)文件中提取嵌入的图片资源。 MHT文件是一种Web页面保存格式,它可以将网页的所有...

    利用Delphi编写Socket通信程序.doc

    利用Delphi编写Socket通信程序 Delphi是一个功能强大的开发工具,它提供了丰富的组件和库,帮助开发者快速构建各种应用程序。其中,Socket通信是Delphi中一个非常重要的组件,用于实现计算机之间的网络通信。本文将...

    一个用delphi编写的股票分析系统,值得大家讨论研究

    本篇文章将深入探讨一个用Delphi编写的股票分析系统,希望能为相关领域的学习者和开发者提供有价值的信息和启示。 首先,我们来理解Delphi在股票分析系统中的应用价值。Delphi拥有优秀的图形用户界面(GUI)设计...

    Delphi编写DLL组件并调用的演示示例.rar

    Delphi编写DLL组件并调用的演示示例,内含:使用抽象类(示例程序8-5)、使用接口(示例程序7-8)、未使用DLL(示例程序3-13)、用Dll封装对象(示例程序7-6)。主要研究Delphi 中的DLL 封装和调用对象技术,...

Global site tag (gtag.js) - Google Analytics