TNGBitmapFormat

<< Click to Display Table of Contents >>

Navigation:  Data Formats >

TNGBitmapFormat

Previous pageReturn to chapter overviewNext page

TNGBitmapFormat class implements standard CF_BITMAP data format and allows to drag/receive bitmaps. NG Drag&Drop use TBitmap standard Delphi type for working with bitmap data.

 

The class declares two methods: Data and Ref. Data method can be used to drag image data at the source side, while Ref method can be used to receive images at the target side. NG Drag&Drop declares special type alias CF.BITMAP to make user's code more readable:

 

NGDropSource.Add(CF.BITMAP.Data(b))
            .Execute;
 
NGDropTarget.Register(MyTargetPanel, procedure(C: TNGTargetContext)
var
  b: TBitmap;
begin
  b := Tbitmap.Create;
  try
    if C.Accept(CF.BITMAP.Ref(b)) then
      ShowBitmap(b);
  finally
    b.Free;
  end;
end);

 

Moreover, special methods are declared for working with bitmap data, which can simplify code even more:

 

NGDropSource.AddBitmap(b)
            .Execute;
 
NGDropTarget.Register(MyTargetPanel, procedure(C: TNGTargetContext)
var
  b: TBitmap;
begin
  b := Tbitmap.Create;
  try
    if C.AcceptBitmap(b) then
      ShowBitmap(b);
  finally
    b.Free;
  end;
end);