Recent

Author Topic: [Solved] Component à la TPicShow (delphi)  (Read 8158 times)

WimVan

  • Jr. Member
  • **
  • Posts: 76
[Solved] Component à la TPicShow (delphi)
« on: January 06, 2019, 08:19:52 am »
What a difficult component to fidn for Lazarus.  On the whole internet we can only find a few references that TPicshow (last update in 2014) should be available for Lazarus.
I tried to import , convert but after some days I stop.  Too much items to be rewritten, faulting functions, procedures, properties ...
If someone knows where to find a running Tpicshow-component for Lazarus, be welcome
Meanwhile I tried to note down -how a component for a slideshow could work.
1) a TImage based component
2) the background should be an image too, with the same posibilities (stretch, autosize, ...) as the showed images.  The region that is not filled with the image should be a color we can choose.  So we have to images.  Backgroundimage and a full-component overlaying foregroundimage.
Action
1) load background and foreground.
2) fade in .  At the beginning the background can be a black, ...
3) Once faded in.  We see the foreground.
4) load foreground to background
5) close foreground so we see the background.
6) load foreground as unvisible by other words, to see it, we must fade in again ..

Needed properties above that of timage
1) time for fade in
2) eventually the time a picture is shown

procedure: copy foreground  to background when fade in is 100% and immediately make foreground unvisible fade in is now 0% so a new foreground can be laded.

Some interested of can help me ?

Thanks

SOLUTION. Take a look to all documentation available and learn your own.  If you can't, be a member of my group. To dummy...
« Last Edit: January 12, 2019, 08:02:14 pm by WimVan »

Handoko

  • Hero Member
  • *****
  • Posts: 2899
  • My goal: build my own game engine using Lazarus
Re: Component à la TPicShow (delphi)
« Reply #1 on: January 06, 2019, 08:32:08 am »
I never knew TPicshow, but maybe you will interested to try glSlideshow:
http://forum.lazarus.freepascal.org/index.php/topic,35313.msg256719.html#msg256719

WimVan

  • Jr. Member
  • **
  • Posts: 76
Re: Component à la TPicShow (delphi)
« Reply #2 on: January 06, 2019, 10:24:47 am »
Thanks for the info and suggestion.
But, where can I find the latest version of your component ?
I will give it a try.  Curious to see if it does what I want.

Meanwhile I tested version 0.95
Nice example, except.
I fades in from a black background.
I prefer a Fading in, out from the previous images, so we do not have a black intermedium.  When you look to very much images, it becomes disturbing and renders headache.


« Last Edit: January 06, 2019, 10:37:19 am by WimVan »

Handoko

  • Hero Member
  • *****
  • Posts: 2899
  • My goal: build my own game engine using Lazarus
Re: Component à la TPicShow (delphi)
« Reply #3 on: January 06, 2019, 11:26:20 am »
I prefer a Fading in, out from the previous images, so we do not have a black intermedium.  When you look to very much images, it becomes disturbing and renders headache.

I understand what you meant.

I'm not very proficient in using OpenGL. Actually, I wanted to create the transition as what you meant but I failed. So instead of direct fading, I created fade to black, white and background.

The code is open source and I know there are many OpenGL experts here. Hope they will improve the code someday.

WimVan

  • Jr. Member
  • **
  • Posts: 76
Re: Component à la TPicShow (delphi)
« Reply #4 on: January 06, 2019, 06:57:46 pm »
I was thinking in this direction ....
1) transparent yes.  Does thhis mean if I have a picture to fade in  is not visible, background is not visible to, so I look just through w kind of window.
If this is the way it acts
1) a panel with a background fe black and then 2 timages with panel als parent, asigned as client .
in that case I can construct an slideshow in the way i wanted.
2) finding out how to fade in timage.

Handoko

  • Hero Member
  • *****
  • Posts: 2899
  • My goal: build my own game engine using Lazarus
Re: Component à la TPicShow (delphi)
« Reply #5 on: January 06, 2019, 07:23:09 pm »
Standard visual components do not support transparency, including TPanel. It's still possible to make it support transparency but you have to write the code, and put it on the OnPaint event.

Maybe TPanel can be used but I think it is more suitable if you use TPaintBox or TOpenGLControl. I prefer TOpenGLControl because it is hardware accelerated.

I think direct fading transition isn't too hard to write. Do you need it to support other effects? Maybe zooming, moving, etc. If it's just a simple image fading program, I can write it for you. But I'm busy currently, not available to do programming until March.

You should do some research about BGRABitmap first. It supports transparency and it's relatively easy to learn:
http://wiki.freepascal.org/BGRABitmap_tutorial

circular

  • Hero Member
  • *****
  • Posts: 2828
    • Personal webpage
Re: Component à la TPicShow (delphi)
« Reply #6 on: January 07, 2019, 02:32:00 pm »
If you're writing your fading with BGRABitmap, you could use TBGRABitmap.CrossFade function to fade between two images. Otherwise to fade one image in, you can use PutImage with a value for the opacity parameter. Note that this works on a TBGRABitmap which is not a regular Canvas. The component TBGRAVirtualScreen and TBCGraphicControl from BGRAControls package can be used for this.

TBGRAVirtualScreen and TPanel are opaque controls, they cannot have a transparent background.
TBCGraphicControl can have a transparent background.

I am wondering if it would be worth making a TBCTransparentImage control that could contain an image with transparent background and have an opacity property.
Conscience is the debugger of the mind

WimVan

  • Jr. Member
  • **
  • Posts: 76
Re: Component à la TPicShow (delphi)
« Reply #7 on: January 09, 2019, 08:54:35 am »
@circular
Thanks for the suggestion.
I tried to install BGRABITMap and the controls but ...
When all installation is done, I can't find anywhere a component like 'BGRABitmap'

'TBGRAVirtualScreen' and 'TBCGraphicControl' are available ...

What's wrong ?
Lazarus 1.8.4
Online-installation used.


GetMem

  • Hero Member
  • *****
  • Posts: 3414
Re: Component à la TPicShow (delphi)
« Reply #8 on: January 09, 2019, 09:07:38 am »
@WimVan
Quote
When all installation is done, I can't find anywhere a component like 'BGRABitmap
You can find it on the component palette. It can be tedious though if you have a lots of components installed. As an alternative solution just press(Ctrl + Alt +P) or go to menu-->view-->components. After the components window appears go to the pallette tab and type bgra.

WimVan

  • Jr. Member
  • **
  • Posts: 76
Re: Component à la TPicShow (delphi)
« Reply #9 on: January 09, 2019, 09:26:37 am »
As I marked, these I have.  The only which I'l looking for is  BGRABitmap.

Handoko

  • Hero Member
  • *****
  • Posts: 2899
  • My goal: build my own game engine using Lazarus
Re: Component à la TPicShow (delphi)
« Reply #10 on: January 09, 2019, 09:32:04 am »
Lazarus main menu > View > Components > type: bgra

GetMem

  • Hero Member
  • *****
  • Posts: 3414
Re: Component à la TPicShow (delphi)
« Reply #11 on: January 09, 2019, 09:56:15 am »
@WimVan
Quote
As I marked, these I have.  The only which I'l looking for is  BGRABitmap.
OK. Maybe it's just me, but your message was a little bit confusing. Anyways BGRABitmap it's not a visual component, you cannot find it in the component pallette, just add BGRABitmap to the uses clauses, then similarly to a TBitmap declare it like this:
Code: Pascal  [Select]
  1. var
  2.   BGRABitmap: TBGRABitmap;
  3.  
Please note that BGRABitmapPack must be in the required packages(see project inspector). If not you should add it first.

WimVan

  • Jr. Member
  • **
  • Posts: 76
Re: Component à la TPicShow (delphi)
« Reply #12 on: January 09, 2019, 12:40:28 pm »
Ok, now I follow ... 
I thought it was a visual component ...
Thanks

WimVan

  • Jr. Member
  • **
  • Posts: 76
Re: Component à la TPicShow (delphi)
« Reply #13 on: January 12, 2019, 09:11:06 am »
A small question.  When I have created 2 image using bgradbitmap ... how now usig crossfade so I see the fadeing on the screen.

I put it here in a button-click-event that calls a form refresh.  bgradbitmap .... seems very very powerful and it is, but the learning-curve is huge. And I find no all needed info to try it on my own.  There is a huge amount of doc too, which helps me, but I find no clear example.
I understand I have to create a new image with the crossfade-function, but how show this action onto the screen ?
Here my ugly code.
Code: Pascal  [Select]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  9.   BGRABitmap, BGRABitmapTypes;
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     procedure Button1Click(Sender: TObject);
  17.     procedure FormCreate(Sender: TObject);
  18.     procedure FormPaint(Sender: TObject);
  19.   private
  20.     image: TBGRABitmap;
  21.     image_1: TBGRABitmap;
  22.     image_2: TBGRABitmap;
  23.   public
  24.  
  25.   end;
  26.  
  27. var
  28.   Form1: TForm1;
  29.  
  30. implementation
  31.  
  32. {$R *.lfm}
  33.  
  34. { TForm1 }
  35.  
  36. procedure TForm1.Button1Click(Sender: TObject);
  37. begin
  38.   image := TBGRABitmap.Create(image_1.Width,image_2.Height); //note that size may be different between bmp1 and bmp2
  39.   form1.Tag := 1;
  40.   form1.Repaint;
  41. end;
  42.  
  43. procedure TForm1.FormCreate(Sender: TObject);
  44. begin
  45.   image_1 := TBGRABitmap.Create('F:\pict_test\img_044016d.jpg');
  46.   image_2 := TBGRABitmap.Create('F:\pict_test\img_044216d.jpg');
  47. end;
  48.  
  49. procedure TForm1.FormPaint(Sender: TObject);
  50. begin
  51.   if form1.Tag = 1 then
  52.   begin
  53.     image.CrossFade(Rect(0,0,image.Width,image.Height), image, image, round(0.3*255), dmSet);
  54.     Form1.Tag := 2; // ready to next
  55.   end;
  56. end;
  57.  
  58. end.
  59.  

circular

  • Hero Member
  • *****
  • Posts: 2828
    • Personal webpage
Re: Component à la TPicShow (delphi)
« Reply #14 on: January 12, 2019, 04:28:41 pm »
Hi Wim,

First, try to display an image that is stretched how you want. You need to determine the ratio with something like that:
Code: Delphi  [Select]
  1. uses math, Types;
  2.  
  3. procedure TForm1.FormPaint(Sender: TObject);
  4. var ratio: single;
  5.   destRect: TRect;
  6. begin
  7.   image.SetSize(ClientWidth,ClientHeight);
  8.   image.Fill(BGRABlack);
  9.  
  10.   ratio := min(image.width/image_1.width, image.height/image_1.height);
  11.   //determine destination size
  12.   destRect := rect(0,0, round(image_1.width*ratio), round(image_1.width*ratio));
  13.   //center rectangle
  14.   OffsetRect(destRect, (image.width - destRect.width) div 2, (image.height - destRect.height) div 2);
  15.  
  16.   image.StretchPutImage(destRect, image_1, dmDrawWithTransparency, round(0.3*255) );
  17.  
  18.   image.Draw(Canvas, 0,0);
  19. end;
Conscience is the debugger of the mind