📄 loadimageu.pas
字号:
unit LoadImageU;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, FileCtrl, ExtCtrls;
type
TForm1 = class(TForm)
FileListBox1: TFileListBox;
DirectoryListBox1: TDirectoryListBox;
DriveComboBox1: TDriveComboBox;
Label1: TLabel;
Panel1: TPanel;
Panel2: TPanel;
Image1: TImage;
Image2: TImage;
Label2: TLabel;
Label3: TLabel;
procedure FileListBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FileListBox1Click(Sender: TObject);
var
TheBitmap: THandle; // holds a newly loaded bitmap image
BitmapInfo: Windows.TBitmap; // holds the bitmap information
TheOffscreenDC: HDC; // holds a handle to a memory device context
begin
{create a memory device context}
TheOffscreenDC := CreateCompatibleDC(0);
{load the specified bitmap file}
TheBitmap := LoadImage(0,PChar(FileListBox1.FileName),IMAGE_BITMAP,0,0,
LR_LOADFROMFILE);
{retrieve information about the bitmap (width and height will be used)}
GetObject(TheBitmap, SizeOf(Windows.TBitmap), @BitmapInfo);
{select the bitmap into the memory device context}
SelectObject(TheOffscreenDC, TheBitmap);
{copy the image to Image1 at its original size}
BitBlt(Image1.Canvas.Handle,0,0,Image1.Width,Image1.Height,TheOffscreenDC,
0,0,SRCCOPY);
{copy the image to Image2, and compress it to fit}
StretchBlt(Image2.Canvas.Handle,0,0,Image2.Width,Image2.Height,TheOffscreenDC,
0,0,BitmapInfo.bmWidth,BitmapInfo.bmHeight,SRCCOPY);
{update the images on screen}
Image1.Refresh;
Image2.Refresh;
{delete the loaded image and the offscreen device context}
DeleteDC(TheOffscreenDC);
DeleteObject(TheBitmap);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -