Recent

Author Topic: reading image from clipboard slow  (Read 3136 times)

BubikolRamios

  • Sr. Member
  • ****
  • Posts: 397
reading image from clipboard slow
« on: January 19, 2013, 05:00:56 pm »
I made as simple prog in vb6 which accepts clipboard image and shows it in my prog in image component.
Rewrote it in Lazarus.

While CTRL+V has instant effect in VB, only the code belov in lazarus takes 2-3 seconds.
That is, it takes ~ 5 s from CTRL+V to point when image shows.

Win 7 64 bit.

The file copyed from clipbrdi is originaly 12 MB, nikon NEF.

Any suggestion ?

Code: [Select]
    if Clipboard.HasFormat(PredefinedClipboardFormat(pcfDelphiBitmap)) then
    bmp.LoadFromClipboardFormat(PredefinedClipboardFormat(pcfDelphiBitmap))

    else  if Clipboard.HasFormat(PredefinedClipboardFormat(pcfBitmap)) then
    bmp.LoadFromClipboardFormat(PredefinedClipboardFormat(pcfBitmap));
lazarus 3.2-fpc-3.2.2-win32/win64

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: reading image from clipboard slow
« Reply #1 on: January 20, 2013, 12:03:52 am »
Just something you can try... Make sure that -gv (valgrind) is disabled in Linking tab in Project options. If i recall, that made my 3D-models load ~100 times slower, from 0.1 second to 10 seconds.

BubikolRamios

  • Sr. Member
  • ****
  • Posts: 397
Re: reading image from clipboard slow
« Reply #2 on: January 20, 2013, 02:35:01 am »
Thanks.

That was default false, so it does not influence a thing.

Any other idea ?
« Last Edit: January 20, 2013, 02:44:38 am by BubikolRamios »
lazarus 3.2-fpc-3.2.2-win32/win64

BubikolRamios

  • Sr. Member
  • ****
  • Posts: 397
Re: reading image from clipboard slow
« Reply #3 on: January 20, 2013, 03:32:20 am »
Anyway, fishing in dark. should that work ?:
Code: [Select]

    if Clipboard.HasFormat(PredefinedClipboardFormat(pcfBitmap)) then
    begin
       bmp.Assign(Clipboard);
    end;   


it dies in last line here in TFPImageBitmap  with message: Wrong image format




Code: [Select]
procedure TFPImageBitmap.ReadStream(AStream: TMemoryStream; ASize: Longint);
var
  SCB: TSharedCustomBitmap;
  IntfImg: TLazIntfImage;
  ImgReader: TFPCustomImageReader;
  LazReader: ILazImageReader;
begin
  IntfImg := nil;
  ImgReader := nil;
  try
    // read image
    ImgReader := GetReaderClass.Create;
    ImgReader.OnProgress := Self.OnProgress;
    IntfImg := TLazIntfImage.Create(0,0,[]);
    InitializeReader(IntfImg, ImgReader);
    if Supports(ImgReader, ILazImageReader, LazReader)
    then LazReader.UpdateDescription := True
    else IntfImg.DataDescription := GetDescriptionFromDevice(0, 0, 0); // fallback to default
    ImgReader.ImageRead(AStream, IntfImg);
    ...                 
lazarus 3.2-fpc-3.2.2-win32/win64

 

TinyPortal © 2005-2018