Delphining grafik imkoniyatlari


-listing. Rasmni resursdan yuklash


Download 0.58 Mb.
bet26/29
Sana09.03.2023
Hajmi0.58 Mb.
#1254496
1   ...   21   22   23   24   25   26   27   28   29
Bog'liq
delphi uzb графика

10.11-listing. Rasmni resursdan yuklash
unit aplanel_;
{$R images.res} // resurs faylni qo’shish
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, Buttons;
type
TForm1 = class(TForm)
Timer1: TTimer;
Image1: ТImage;
procedure FormActivate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction); private
{ Private declarations } public
{ Public declarations } end;
var
Form1: TForm1;
Back, bitmap, Buf : TBitMap;
// fon, rasm, bufer
BackRct, BufRet: TRect;
// fonninng sohasi, rasm, bufer
х,у:integer;
// rasmning yuqori chap burchagi картинки
W,H: integer; // rasm o’lchamlari
implementation
{$R *.DFM}
procedure TForm1.FormActivate(Sender: TObject);
begin
Back := TBitmap.Create; // fon
bitmap := TBitmap.Create; // rasm
Buf := TBitmap.Create; // bufer
// fonni resursdan yuklash
Back.LoadFromResourceName(HInstance,'FACTORY');
Forml.Image1.canvas.Draw(0,0,Back);
// harakatlanuvchi rasmni resursdan yuklash
bitmap.LoadFromResourceName(HInstance,'APLANE');
bitmap.Transparent := True;
bitmap.TransParentColor := bitmap.canvas.pixels[1,1];
// fonning harakatlanayotgan rasm joylashuvchi sohasining
// nusxasini saqlash uchun bufer tashkil qilish
W:= bitmap.Width;
Н:= bitmap.Height;
Buf.Width:= W;
Buf.Height:=H;
Buf.Palette:=Back.Palette; // palitralar mosligini ta’minlash uchun !!
Buf.Canvas.CopyMode:=cmSrcCopy;
BufRct:=Bounds(0,0,W,H);
x:=-W; y:=20;
// fonning saqlanuvchi sohasini aniqlaymiz
BackRct:=Bounds(x,y,W,H); // va uni saqlaymiz
Buf.Canvas.CopyRect(BufRet,Back.Canvas, BackRct);

Download 0.58 Mb.

Do'stlaringiz bilan baham:
1   ...   21   22   23   24   25   26   27   28   29




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling