MainUnit.pas
资源名称:JPEG解码源码.rar [点击查看]
上传用户:lvs5012005
上传日期:2007-03-06
资源大小:11k
文件大小:1k
源码类别:
图形图象
开发平台:
Delphi
- unit MainUnit;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, ExtCtrls;
- type
- TForm1 = class(TForm)
- Image1: TImage;
- Button1: TButton;
- OpenDialog1: TOpenDialog;
- procedure Button1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- uses JpegDecode;
- {$R *.DFM}
- procedure TForm1.Button1Click(Sender: TObject);
- var
- fileName:string;
- Bf:BITMAPFILEHEADER;
- MS:TMemoryStream;
- pImg:Pointer;
- begin
- if OpenDialog1.Execute then
- begin
- fileName:=OpenDialog1.FileName;
- if LoadJpegFile(FileName,pImg) then
- begin
- MS:=TMemoryStream.Create;
- CopyMemory(@bf,pImg,sizeof(BITMAPFILEHEADER));
- MS.Write(pImg^,bf.BfSize);
- MS.Position:=0;
- Image1.Picture.Bitmap.LoadFromStream(MS);
- MS.Free;
- FreeMem(pImg);
- end else
- ShowMessage('调用失败');
- end;
- end;
- end.
English
