Recent

Author Topic: TBitmap.LoadFromClipboardFormat method  (Read 13701 times)

skywriter

  • New Member
  • *
  • Posts: 28
TBitmap.LoadFromClipboardFormat method
« on: July 27, 2007, 02:07:24 pm »
The story so far.
Application contains
Form1:TForm,
Image1:TImage,
Button1:TButton
both in Lazarus and in Delphi project.

In Lazarus project:

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  BMP : TBitmap;
begin
  BMP := TBitmap.Create;
  BMP.LoadFromClipboardFormat( CF_BITMAP );
  Image1.Picture.Bitmap.Assign( BMP );
end;

In Delphi project:

procedure TForm1.Button1Click(Sender: TObject);
var
  BMP : TBitmap;
begin
  BMP := TBitmap.Create;
  BMP.LoadFromClipboardFormat(CF_Bitmap, ClipBoard.GetAsHandle(CF_Bitmap), 0);
  Image1.Picture.Bitmap.Assign( BMP );
end;

Then i copy part of image from MS Paint into clipboard.
After that, when i press "Button1" in Delphi project i see the same copied part of image on the form.  When i press "Button1" in Lazarus project there nothing happens.

What i do wrong?

arnoldb

  • Jr. Member
  • **
  • Posts: 96
RE: TBitmap.LoadFromClipboardFormat method
« Reply #1 on: July 27, 2007, 03:16:07 pm »
Slightly confusing...  You are trapping a BitBtn1Click in Lazarus, yet you say you have a Button1:TButton
Do you have a Button1Click event assigned in Lazarus to Button1's onclick, or is BitBtn1Click assigned to button1's onclick in Lazarus?

wile64

  • New Member
  • *
  • Posts: 19
    • http://wile64.neuf.fr/
TBitmap.LoadFromClipboardFormat method
« Reply #2 on: July 27, 2007, 05:50:37 pm »
I use this
Bitmap.LoadFromClipboardFormat(PredefinedClipboardFormat(pcfPixmap));
who run well…

skywriter

  • New Member
  • *
  • Posts: 28
TBitmap.LoadFromClipboardFormat method
« Reply #3 on: July 30, 2007, 11:07:10 am »
arnoldb: I think type of button control doesn't matter in this case.

Quote from: "wile64"
I use this
Bitmap.LoadFromClipboardFormat(PredefinedClipboardFormat(pcfPixmap));
who run well…


Tried. Result is the same as with BMP.LoadFromClipboardFormat( CF_BITMAP ). I went ste-by-step to method

Code: [Select]
function TClipboard.AssignToGraphic(Dest: TGraphic; FormatID: TClipboardFormat
  ): boolean;
var
  MemStream: TMemoryStream;
begin
  Result:=false;
  if FormatID=0 then exit;
  MemStream:=TMemoryStream.Create;
  try
    if not GetFormat(FormatID,MemStream) then exit;
    MemStream.Position:=0;
    Dest.LoadFromMimeStream(MemStream,ClipboardFormatToMimeType(FormatID));
  finally
    MemStream.Free;
  end;
  Result:=true;
end;


and i saw GetFormat(FormatID,MemStream) returns false. Where is bug?
I need this feature to get snapshot from clipboard as in method  TVideo.CapGrabFrame(Destination: TBitmap) of "SysRec" project...Please help! :cry:

skywriter

  • New Member
  • *
  • Posts: 28
TBitmap.LoadFromClipboardFormat method
« Reply #4 on: August 03, 2007, 07:53:17 am »
wile64: Can you tell which version of Lazarus you use and example of code properly works?
I believe the bug must be fixed. No matter is this my bug or Lazarus-developers bug.

skywriter

  • New Member
  • *
  • Posts: 28
TBitmap.LoadFromClipboardFormat method
« Reply #5 on: August 09, 2007, 10:37:27 am »
while64:

What about this (file \lazarus\lcl\include\intfbaselcl.inc):
Code: [Select]

// the clipboard functions are internally used by TClipboard
function TWidgetSet.ClipboardFormatToMimeType(FormatID: TClipboardFormat): string;
begin
  Result := '';
end;


How it can work at all?!

skywriter

  • New Member
  • *
  • Posts: 28
TBitmap.LoadFromClipboardFormat method
« Reply #6 on: August 10, 2007, 10:48:01 am »
Temporarily found usable workaround: function capFileSaveDIB of VfW then TBitmap.LoadFromFile.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2496
TBitmap.LoadFromClipboardFormat method
« Reply #7 on: August 14, 2007, 11:03:47 am »
TWidgetSet.xxx only contains empty "abstract" methods and functions. The real implementation is done in the derived widgetset like TWSWin32Widgetset or TWSgtkWidgetset
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker