Recent

Author Topic: Form as PDF, DOC, XLS, PPT and JPG viewer  (Read 26567 times)

rajivsoft

  • New Member
  • *
  • Posts: 48
Re: Form as PDF, DOC, XLS, PPT and JPG viewer
« Reply #15 on: April 14, 2011, 04:08:15 pm »
I suppose with a TImage you can show these images and stretch them.
I have tried TImage and with enlagments it works well but when i reduse form size to half of image size (image TImage is alClient to form and strethed) it loose VERY much in qulity, now I'v tryed to use BGRABitmap and it's perfect with small size Form (tutorial example 2, at the end of page, on FormPaint) but it is really slow when i resize form over 780p dimensions... how can i faster it?

circular

  • Hero Member
  • *****
  • Posts: 4221
    • Personal webpage
Re: Form as PDF, DOC, XLS, PPT and JPG viewer
« Reply #16 on: April 14, 2011, 04:40:43 pm »
I am looking at Graphics32 code which seems faster, and provides also other filters. It's in the unit GR32_Resamplers.pas. It is possible to inspire from it.
Conscience is the debugger of the mind

rajivsoft

  • New Member
  • *
  • Posts: 48
Re: Form as PDF, DOC, XLS, PPT and JPG viewer
« Reply #17 on: April 14, 2011, 06:21:25 pm »
I am looking at Graphics32 code which seems faster, and provides also other filters. It's in the unit GR32_Resamplers.pas. It is possible to inspire from it.
Thinking about the fact that when i need to enlarge the image over it's original size TImage's stretch resample do practically identical result (tested with imgviewer example) as TBGRABitmap's, i putted this small fix

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   image := TBGRABitmap.Create('/Users/asd/Documents/itsanimage.jpg');
  4.   Img_View.Stretch := true;
  5. end;          
  6.  
  7. procedure TForm1.FormPaint(Sender: TObject);
  8. var
  9.   stretched: TBGRABitmap;
  10. begin
  11.   if (Img_View.Width < trunc(image.Width/3*2)) or (Img_View.Height < trunc(image.Height/3*2)) then
  12.   begin
  13.     stretched := image.Resample(Img_View.Width, Img_View.Height) as TBGRABitmap;
  14.     Img_View.Picture.Bitmap.Assign(stretched.Bitmap);
  15.     stretched.Free;
  16.   end;
  17. end;
But with big images (e.g. 1280x1024) when you mess around 800x600 size of form it's slow, so i putted /3*2 because TImage still make good result.

circular

  • Hero Member
  • *****
  • Posts: 4221
    • Personal webpage
Re: Form as PDF, DOC, XLS, PPT and JPG viewer
« Reply #18 on: April 15, 2011, 12:53:12 pm »
That's a nice workaround.

I've managed to optimize FineResampleLarger. Now it's 4 times faster and you can choose the interpolation filter with ResampleFilter property of TBGRABitmap. There are only 3 filters for now.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018