picture:=Tpicture.Create;
 picture.assgin(XXXX);
解释下这个assgin的用法

解决方案 »

  1.   

    procedure TPicture.Assign(Source: TPersistent);
    begin
      if Source = nil then
        SetGraphic(nil)
      else if Source is TPicture then
        SetGraphic(TPicture(Source).Graphic)
      else if Source is TGraphic then
        SetGraphic(TGraphic(Source))
      else
        inherited Assign(Source);
    end;
      

  2.   

    RAD Studio VCL Reference   TPicture.Assign Method
    TPicture Class | TPicture Members | Graphics Namespace | Description | See Also
    Collapse AllCopies one object to another by copying the contents of that object to the other.Pascal
    procedure Assign(Source: TPersistent); override;
    C++
    virtual __fastcall Assign(TPersistent * Source);
    Description
    When Source is a object type that is valid for the Graphic property, Assign makes that graphic the value of the Graphic property. The actions performed by Assign depend on the actual types of the TPicture Graphic property and Source. For example, if the Graphic property and Source are bitmaps (TBitmap), the bitmap contained in Source is copied into the Graphic property. Similar conversions are valid, for example, for TIcon or TMetafile. If the Source parameter is not a valid object for the Graphic property, Assign calls the inherited method so that the picture can be copied from any object with which it is compatible.  C++ Examples:  /*
    This example uses an image, a button, and a shape component
    on a form. When the user clicks the button, an image of the
    form is stored in the FormImage variable and copied to the
    Clipboard. The image of the form is then copied back to
    the image component, producing an interesting result,
    especially if the button is clicked multiple times.  Add
    ExtCtrls, StdCtrls, and Clipbrd to the uses clause.
    }
    */#include <Clipbrd.hpp>void __fastcall TForm1::Button1Click(TObject *Sender)
    {
      Graphics::TBitmap *FormImage = GetFormImage();
      try
      {
        Clipboard()->Assign(FormImage);
        Image1->Picture->Assign(Clipboard());
      }
      __finally
      {
        delete FormImage;
      }
    }void __fastcall TForm1::FormCreate(TObject *Sender)
    {
      Shape1->Shape = stEllipse;
      Shape1->Brush->Color = clLime;
      Image1->Stretch = true;
    }
     Delphi Examples: {
    This example uses an image, a button, and a shape component
    on a form. When the user clicks the button, an image of the
    form is stored in the FormImage variable and copied to the
    Clipboard. The image of the form is then copied back to
    the image component, producing an interesting result,
    especially if the button is clicked multiple times.  Add
    ExtCtrls, StdCtrls, and Clipbrd to the uses clause.
    }
    procedure TForm1.Button1Click(Sender: TObject);
    var
      FormImage: TBitmap;
    begin
      FormImage := GetFormImage;
      try
        Clipboard.Assign(FormImage);
        Image1.Picture.Assign(Clipboard);
      finally
        FormImage.Free;
      end;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      Shape1.Shape := stEllipse;
      Shape1.Brush.Color := clLime;
      Image1.Stretch := True;
    end;  See Also
    Graphic Assign
      

  3.   

    picture:=Tpicture.Create;
     picture.assgin(XXXX);如果XXXX是Tpicture类型的对象,并且不为nil,则把XXXX赋给picture。并且XXXX和picture是相互独立的,XXXX释放了对picture也没有影响
      

  4.   

    一个对象赋值给另一个对象,可以理解为A:=B;
    nil是允许的,但不为nil时,类型必须相同或者祖先相同