Kod klassa:
Â
unit KLimg;
Â
interface
uses
 Classes, ExtCtrls;
type
 Kimg=class(Timage)
  private
   img:Timage;
   h,w:Integer;
  public
  Constructor Create(im:TComponent); override;
   procedure nowy(img1:Timage; h1,w1:Integer) ;
   function NewImg:TImage;
   end;
implementation
Â
  constructor Kimg.Create(im:TComponent);
   begin
    inherited Create(im);
   end;
Â
   procedure Kimg.nowy(img1:Timage; h1,w1:Integer) ;
   begin
    img:=img1;
    h:=h1;
    w:=w1;
    img.Canvas.StretchDraw(Rect(0, 0, h, w), img.Picture.bitmap);
    img.Picture.Bitmap.Height:=w;
    img.Picture.Bitmap.Width:=h;
    img.Height:=w;
    img.Width:=h;
   end;
Â
   function Kimg.NewImg:TImage;
   begin
    result:=img;
   end;
Â
end.
Â
Â
kusok koda ispolzuushii klass:
Â
procedure TForm1.Button3Click(Sender: TObject);
var
 Img:Kimg;
 h,w:Integer;
 begin
  img:=Kimg.Create(nil);
  h:=strtoint(edit1.text);
  w:=strtoint(edit2.text);
  img.nowy(image1,h,w);
  image1:=img.newimg;
 end;
Add a code snippet to your website: www.paste.org