請問form貼圖 |
尚未結案
|
diehuman
初階會員 ![]() ![]() 發表:91 回覆:57 積分:29 註冊:2003-04-16 發送簡訊給我 |
|
Justmade
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:94 回覆:1934 積分:2030 註冊:2003-03-12 發送簡訊給我 |
|
ddy
站務副站長 ![]() ![]() ![]() ![]() ![]() ![]() 發表:262 回覆:2105 積分:1169 註冊:2002-07-13 發送簡訊給我 |
可以將小片圖以拼圖的方式貼滿Form
procedure BrushBitmapToForm(Sender: Tobject; bmpFilename: string; space: integer = 0); {功能:指定Form 填滿指定圖形(bmp) 傳入參數:Sender-->Form 名稱 bmpFileName-->圖檔路徑和名稱 space-->圖片間是否留有空白 注意: 須於Paint event 中執行 } var x, y: integer; Bitmap: TBitmap; begin Bitmap := Tbitmap.Create; Bitmap.LoadFromFile(bmpFilename); if sender is TForm then begin y := 0; while y < (sender as Tform).Height do begin X := 0; while X < (sender as Tform).Width do begin (sender as Tform).canvas.Draw(X, Y, Bitmap); X := X + Bitmap.Width + space; end; Y := Y + Bitmap.Height + space; end; bitmap.Free; end; end; |
qoo1234
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:256 回覆:1167 積分:659 註冊:2003-02-24 發送簡訊給我 |
引言: 可以將小片圖以拼圖的方式貼滿Form拼圖??那可不可以寫一個來玩玩~~procedure BrushBitmapToForm(Sender: Tobject; bmpFilename: string; space: integer = 0); {功能:指定Form 填滿指定圖形(bmp) 傳入參數:Sender-->Form 名稱 bmpFileName-->圖檔路徑和名稱 space-->圖片間是否留有空白 注意: 須於Paint event 中執行 } var x, y: integer; Bitmap: TBitmap; begin Bitmap := Tbitmap.Create; Bitmap.LoadFromFile(bmpFilename); if sender is TForm then begin y := 0; while y < (sender as Tform).Height do begin X := 0; while X < (sender as Tform).Width do begin (sender as Tform).canvas.Draw(X, Y, Bitmap); X := X + Bitmap.Width + space; end; Y := Y + Bitmap.Height + space; end; bitmap.Free; end; end; |
Justmade
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:94 回覆:1934 積分:2030 註冊:2003-03-12 發送簡訊給我 |
|
qoo1234
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:256 回覆:1167 積分:659 註冊:2003-02-24 發送簡訊給我 |
//直接在表單上加入背景圖 unit Unit1; interface uses
Windows, SysUtils, Classes, Graphics, Forms; type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure FormDestroy(Sender: TObject); private
{ Private declarations }
public
{ Public declarations }
backgroundImage : TBitmap;
end; var
Form1: TForm1; implementation {$R *.DFM} procedure TForm1.FormCreate(Sender: TObject);
begin
backgroundImage := TBitmap.Create;
backgroundImage.LoadFromFile(ExtractFilePath(Application.ExeName) 'background.bmp');
end; procedure TForm1.FormPaint(Sender: TObject);
begin
Canvas.Draw( 0, 0, backgroundImage );
end; procedure TForm1.FormDestroy(Sender: TObject);
begin
backgroundImage.Free;
end; end.
![]() |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |