• Delphi中的jpg、png、gif 图片及 gif 动画的显示


    unit Unit1;
    
    interface
    
    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls, ExtCtrls;
    
    type
    TForm1 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        Button3: TButton;
        Button4: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure Button3Click(Sender: TObject);
        procedure Button4Click(Sender: TObject);
    end;
    
    var
    Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    uses jpeg, GIFImg, pngimage;
    
    {显示 jpg 图片}
    procedure TForm1.Button1Click(Sender: TObject);
    var
    jpg: TJPEGImage;
    begin
    jpg := TJPEGImage.Create;
    jpg.LoadFromFile('C:\Temp\Test.jpg');
    Canvas.Draw(0, 0, jpg);
    jpg.Free;
    end;
    
    {显示 png 图片}
    procedure TForm1.Button2Click(Sender: TObject);
    var
    png: TPngImage;
    begin
    png := TPngImage.Create;
    png.LoadFromFile('C:\Temp\Test.png');
    Canvas.Draw(0, 0, png);
    png.Free;
    end;
    
    {显示 gif 图片}
    procedure TForm1.Button3Click(Sender: TObject);
    var
    gif: TGIFImage;
    begin
    gif := TGIFImage.Create;
    gif.LoadFromFile('C:\Temp\Test.gif');
    Canvas.Draw(0, 0, gif);
    gif.Free;
    end;
    
    {显示 gif 动画}
    procedure TForm1.Button4Click(Sender: TObject);
    var
    gif: TGIFImage;
    begin
    gif := TGIFImage.Create;
    gif.LoadFromFile('C:\Temp\Test.gif');
    gif.Animate := True;
    
    with TImage.Create(Self) do begin
        Parent := Self;
        Left := 0;
        Top := 0;
        Picture.Assign(gif);
    end;
    
    gif.Free;
    end;
    
    end.
  • 相关阅读:
    div弹出层
    经典SQL语句
    sql连接及操作
    给flash加上连接
    在c#中图片原比例缩放
    悬浮提示筐
    拖动板块
    IFrame自适应高度
    SQL语句中的日期计算
    注意Request.Cookies["UserID"]的用法
  • 原文地址:https://www.cnblogs.com/hssbsw/p/2389214.html
Copyright © 2020-2023  润新知