久久―日本道色综合久久,亚洲欧美精品在线,狼狼色丁香久久婷婷综合五月,香蕉人人超,日本网站黄,国产在线观看不卡免费高清,无遮挡的毛片免费

2025年度未來(lái)銀行科技服務(wù)商TOP100
全世界各行各業(yè)聯(lián)合起來(lái),internet一定要實(shí)現(xiàn)!

將JPEG文件轉(zhuǎn)為Windows墻紙

2004-02-14 eNet&Ciweek

  JPEG是一種圖像壓縮標(biāo)準(zhǔn),很多精美的圖片都是采用這種格式標(biāo)準(zhǔn),其特點(diǎn)是文件體積較小,而且支持24位色深。但是,Windows9x只支持位圖文件(即以bmp為擴(kuò)展名的文件)的墻紙。下面這個(gè)程序就是將以jpg或jpeg為擴(kuò)展名的圖片文件轉(zhuǎn)化為位圖文件,并通過(guò)修改注冊(cè)表的鍵值來(lái)通知Windows更換墻紙。本程序使用了一個(gè)Tform;一個(gè)OpenPictureDialog用來(lái)讓用戶選擇圖片;三個(gè)SpeedButton;分別用來(lái)打開(kāi)OpenPictureDialog對(duì)話框,確定更換墻紙,退出程序。程序全部代碼如下:

    unit Unit1;

    interface

    uses

     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,

  Dialogs, jpeg, registry, ExtDlgs, StdCtrls, Buttons;

    type

     TForm1 = class(Tform)

     SpeedButton1: TSpeedButton;

     SpeedButton2: TSpeedButton;

     SpeedButton3: TSpeedButton;

     OpenPictureDialog1: TOpenPictureDialog;

    procedure SpeedButton1Click(Sender: Tobject);

    procedure SpeedButton2Click(Sender: Tobject);

    procedure SpeedButton3Click(Sender: Tobject);

     private

     { Private declarations }

     public

     { Public declarations }

     end;

    var

     Form1: TForm1;

    implementation

    {$R *.DFM}

    procedure TForm1.SpeedButton1Click(Sender: Tobject);

    begin

     openpicturedialog1.execute;{打開(kāi)OpenPictureDialog對(duì)話框}

    end;

    procedure TForm1.SpeedButton2Click(Sender: Tobject);

    var

     reg: tregistry;{Tregistry對(duì)象在Registry單元中聲明,需要在Uese 中引用Registry單元}

     jpeg: tjpegimage;{Tjpegimage對(duì)象在Jpeg單元中聲明,需要在Uese 中引用Jpeg單元}

     bmp: tbitmap;

    begin

     if (openpicturedialog1.filename=``)

     then {判斷OpenPictureDialog1中有無(wú)文件被選中}

  messagedlg(`請(qǐng)選擇一張圖片`,mtinformation,[mbOK],0)

     else

     begin

     jpeg:=tjpegimage.Create;

     jpeg.LoadFromFile(openpicturedialog1.filename);{加載被用戶選中的文件}

     bmp:=tbitmap.Create;

     bmp.assign(jpeg);

     bmp.savetofile(`c:\windows\wall.bmp`);{將轉(zhuǎn)換成功的文件保存的路徑及文件名}

     reg:=tregistry.Create;

    reg.rootkey:=hkey_current_user;{設(shè)置根鍵名稱}

    reg.openkey(`control panel\desktop`,false);{打開(kāi)Control Panel\Desktop路徑對(duì)應(yīng)的主

  鍵}

     reg.writestring(`tilewallpaper`,`0`);

     reg.writestring(`wallpaper`,`c:\windows\wall.bmp`);

  {覆蓋并寫(xiě)入新值TileWall- paper和Wallpaper串}

    systemparametersinfo(spi_setdeskwallpaper,0,nil,spif_sendchange);{通知win-dows更

  換墻紙}

    reg.closekey;{寫(xiě)入更改內(nèi)容并關(guān)閉注冊(cè)表}

     reg.Free;{釋放對(duì)象}

     close;

     end;

    end;

    procedure TForm1.SpeedButton3Click(Sender: Tobject);

    begin

     close;

    end;

    end.

    此程序只能將以jpg或jpeg為擴(kuò)展名的圖片文件轉(zhuǎn)化為Windows的墻紙,因此應(yīng)在OpenPictureDialog控件的Filter屬性中篩選顯示文件的類型,最好設(shè)置為JPEG Image File(*.jpg)和JPEG Image File(*.jpeg)文件。

相關(guān)頻道: eNews

您對(duì)本文或本站有任何意見(jiàn),請(qǐng)?jiān)谙路教峤唬x謝!

投稿信箱:tougao@enet16.com