Recent

Author Topic: Adding 'Packages'  (Read 6202 times)

J-G

  • Hero Member
  • *****
  • Posts: 953
Adding 'Packages'
« on: October 25, 2016, 09:47:26 pm »
Wanting to try 'rotating images' I did a forum search and found a reference to BGRAControls and BGRABitmap.

A little further research and I downloaded bgrabitmap9.2.1.zip which unzipped as I would anticipate giving me 4 .LPK files which seem to be 'packages' that I need to 'install'.

Now I start going around in circles  -  simply because I have no idea what I need to do next, despite reviewing all the controls in [Packages] and clicking on 'Open Package file', selecting the 4 files then clicking on each in turn as listed under 'Open Recent Package' I still don't have anything 'BGRAB...' listed in the [Install] section.

I've just reviewed the [Package Links] and have three 'BGRAB...' and one 'BGLC...' files listed along with 'lpk file invalid (4)' ticked.

I'm obviously well out of my depth and looking for someone to throw me a lifeline  :)

Fortunately Laz still compiles the project I'm working on so it appears that I haven't done any harm with my meddling. Purely by chance I did add JuJiBo components a little while ago but it seems that was a fluke.

HELP !!
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Adding 'Packages'
« Reply #1 on: October 25, 2016, 09:57:03 pm »
Open the bgrabitmappack.lpk (double click). Then click on Compile. Then click on Use > Add to project. And that's all, the project can find the units of BGRABitmap.

You don't need to open the other 3 packages if you don't need them or don't know for what are.

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Adding 'Packages'
« Reply #2 on: October 25, 2016, 10:55:01 pm »
Open the bgrabitmappack.lpk (double click). Then click on Compile. Then click on Use > Add to project. And that's all, the project can find the units of BGRABitmap.

You don't need to open the other 3 packages if you don't need them or don't know for what are.
Thanks lainz  -  that has got me half there  -  two issues now to address  :

1   -   the project I'm looking at which prompted my interest is 'protateimage.lpr' and that now tells me that I need  'bgracontrols'  -  whilst I have found the source of bgracontrols.lpk I can't see way to download it  -  assuming that is what I need to do !!

2   -   I had anticipated that 'adding a package' would insert another [Tab] to the Laz Menu Bar  -  just as JuJiBo did  -  and give further components to pick from. I may well be totally mis-understanding what BGRA.... is of course.

FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Adding 'Packages'
« Reply #3 on: October 25, 2016, 10:59:40 pm »
Not all packages adds new tabs.

To download bgracontrols go here:
https://github.com/bgrabitmap/bgracontrols/releases

Pick the latest release and click on "Download source (zip)". Then you need to do this:

Open the package bgracontrols.lpk, choose Install. and click yes on all prompts, so lazarus is build and you get two new tabs BGRA Controls and BGRA Custom Drawn. To work you need at least Lazarus 1.6.

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Adding 'Packages'
« Reply #4 on: October 25, 2016, 11:24:43 pm »
Thanks lainz

Not all packages adds new tabs.
Right  -  so to use the facilities I would simply add  'BGRAGraphicControl, BGRABitmap, BGRABitmapTypes'  as required to the [Uses] section   ---   is that correct?

To download bgracontrols go here:
https://github.com/bgrabitmap/bgracontrols/releases

Pick the latest release and click on "Download source (zip)". Then you need to do this:

Open the package bgracontrols.lpk, choose Install. and click yes on all prompts, so lazarus is build and you get two new tabs BGRA Controls and BGRA Custom Drawn. To work you need at least Lazarus 1.6.
Fantastic  -  I seem to now have more graphic control components than I can get to grips with this year  :D

I am using Laz 1.6  -  I don't dare think of installing 'Trunk'  -  if I have problems installing a 'package' think what damage I could inflict on a development environment  :(

I'll have to consider myself an 'Early adopter' - V4.3.1 being only 5 hours old !!

FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Adding 'Packages'
« Reply #5 on: October 25, 2016, 11:37:36 pm »
Thankyou for downloading it.

BGRAGraphicControl needs to be added from the tab because it's a visual component that you can drag and drop in the form editor. But if you want to code it by hand you can do it too.

The BGRABitmap units all must be added as you say.

Lazarus 1.6 is really good, so isn't neccessary to use trunk, I test it with the trunk and the 1.6

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Adding 'Packages'
« Reply #6 on: November 01, 2016, 02:35:23 pm »
Thankyou for downloading it.

Thank YOU lainz for making the components available  (why is there no 'applause' emoticon?)

I'm now investigating the BGRABitmap  controls but not getting very far.
I've tried adding a [Knob] which I hoped would allow me to plant a .PNG image on top of it and make the knob itself transparent - this second part was OK but I can't add an image.
Next I tried a [Panel] which turns out to be black even when color= none.

I've reviewed the code in the demo  [protateimage]  and now think that I have to use [PutImageAngle] and to that end I've added the three units BGRAGraphicControl, BGRABitmap, BGRABitmapTypes  to my project but I'm struggling to understand how I

1  -  assign a specific bitmap to be rotated
2  -  pass the specific angle to [PutImageAngle]

I already have two transparent .PNG images of the clock hands I want to use - one hour and one minute they are both 200px square - just different lengths - in case it helps I've attached one.



« Last Edit: November 01, 2016, 02:41:51 pm by J-G »
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Adding 'Packages'
« Reply #7 on: November 01, 2016, 02:54:07 pm »
Please download and test the attachment.

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Adding 'Packages'
« Reply #8 on: November 01, 2016, 05:53:02 pm »
Please download and test the attachment.
Brilliant !!!   :D :D :D

I knew that it ought to be fairly straight-forward but I've done next to no work with bitmaps (in Pascal) as yet.

Now I have to get to understand all the new features you've put in my armoury  :)

Pleased I thought to attach the transparent .PNG I'll be using. If you ever need any graphics creating don't hesitate to ask !






FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Adding 'Packages'
« Reply #9 on: November 02, 2016, 04:08:28 pm »
Thankyou, I'm graphics designer too :) but any help is welcome!

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Adding 'Packages'
« Reply #10 on: November 02, 2016, 06:15:08 pm »
Thankyou, I'm graphics designer too :) but any help is welcome!

 :D  I did cogitate for 10 minutes or so before adding that offer - Grandma and Egg Sucking  :D

I now need some more assistance. From other posts you'll see that I've got a three hand smooth seconds working as a modification of your project1 but I've now moved the pertinent code into my main program and although it compiles and displays the form, it's missing the hands and the digital time caption (though that could just be an Application.processmessages issue)  - throwing up a SIGSEGV Error at line 314.

This is the assembler debug window with the error line starting '>>>>>':
Code: Pascal  [Select][+][-]
  1. 000000010002D2FE 8a05ecf22e00             mov    0x2ef2ec(%rip),%al        # 0x10031c5f0 <U_$INVOL_CLOCK_$$_INVCLOCK+16>
  2. 000000010002D304 3a45e0                   cmp    -0x20(%rbp),%al
  3. 000000010002D307 730a                     jae    0x10002d313 <TIMER1TIMER+131>
  4. invol_clock.pas:310                       Read_Date;
  5. 000000010002D309 e8b2fcffff               callq  0x10002cfc0 <READ_DATE>
  6. invol_clock.pas:311                       Show_Date;
  7. 000000010002D30E e89df9ffff               callq  0x10002ccb0 <SHOW_DATE>
  8. invol_clock.pas:314                       BGRAGraphicControl1.DiscardBitmap;
  9. >>>>>  000000010002D313 488b45f0                 mov    -0x10(%rbp),%rax
  10. 000000010002D317 488b8878070000           mov    0x778(%rax),%rcx
  11. 000000010002D31E e81dea1500               callq  0x10018bd40 <BGRAGRAPHICCONTROL$_$TBGRAGRAPHICCONTROL_$__$$_DISCARDBITMAP>
  12. invol_clock.pas:298                       begin
  13. 000000010002D323 90                       nop
  14. 000000010002D324 4889e9                   mov    %rbp,%rcx
  15. 000000010002D327 e844ffffff               callq  0x10002d270 <fin$4>
  16. invol_clock.pas:316                       end;
  17.  

and here is a code fragment to give context :

Code: Pascal  [Select][+][-]
  1. procedure Calc_Hand_Angles(T : Time);
  2. begin
  3.   Alpha := 30 * ((Time_Now.H Mod 12) + Time_Now.M/60 + Time_Now.S/3600);
  4.   Beta  := 6 * (Time_Now.M + Time_Now.S/60);
  5.   Gamma := 6 * (Time_Now.S);
  6. end;
  7.  
  8. procedure Show_Date;
  9.  
  10. procedure Read_Time;
  11. begin
  12.   Sys_Date := Now;
  13.   With Time_Now do
  14.     begin
  15.       H := HourOf(Sys_Date);
  16.       M := MinuteOf(Sys_Date);
  17.       S := SecondOf(Sys_Date) + MilliSecondOf(Sys_date)/1000;
  18.     end;
  19.   Calc_Hand_Angles(Time_Now);
  20. end;
  21.  
  22. procedure Read_Date;
  23.  
  24. procedure TInvClock.FormCreate(Sender: TObject);
  25.  
  26. procedure TInvClock.FormDestroy(Sender: TObject);
  27.  
  28. procedure TInvClock.Timer1Timer(Sender: TObject);
  29. Var T : Time;
  30. begin
  31.   T := Time_Now;
  32.   Read_Time;                               // reads Time_Now - also sets hand angles
  33.  
  34.   InvClock.DigitTime.Caption := Format_Time(Time_Now);
  35.  
  36.   if Time_Now.h <> T.H then;    // Hour has changed  update Involute Dot
  37.     SetHourDot(T);
  38.  
  39.   if Time_Now.h < T.h then      // Day has changed - show new date & dayname
  40.     begin
  41.       Read_Date;
  42.       Show_Date;
  43.     end;
  44.  
  45. >>>>>  BGRAGraphicControl1.DiscardBitmap;
  46.  
  47. end;
  48.  

Again I've put '>>>>>' at the offending line   (and squeezed up irrelevant procs)  Line 8 referencing line 314 in Assembler is line 45 in the fragment. I've also tried it at line 33.

This is exactly the same line in the same procedure (Timer)  as it is in Project1 and that throws no error.  I did try to move that line to a called procedure in project1 but it didn't compile (I'd like to know why?)

I've previously seen reference to SIGSEG on the forum but not understood any of the answers.

As a subsidiary question, is it possible to incorporate the hand images on the form (using TImage ? ) and reference them that way rather than fetch them from 'ProgramDirectory + ...' ?
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Adding 'Packages'
« Reply #11 on: November 02, 2016, 07:06:58 pm »
Is hard to debug when you don't have the code, if you don't mind you can store it somewhere and send me it to PM, I will not share it with no one. If not well I'm not sure how to help you. Do you have a control named BGRAGraphicControl1 placed in the form and contains the event OnRedraw assigned?

Something you can try is to disable the timer in the object inspector, and then enable the timer OnShow event, to ensure that the calling to BGRAGraphicControl1.DiscardBitmap is done only when the component is visible.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormShow(Sender: TObject);
  2. begin
  3.   Timer1.Enabled := True;
  4. end;  

Quote
This is exactly the same line in the same procedure (Timer)  as it is in Project1 and that throws no error.  I did try to move that line to a called procedure in project1 but it didn't compile (I'd like to know why?)

The procedure must be a method of the form class, not a procedure outside. I suppose is that the bug when you try to move the line but I'm not sure.

Quote
I've previously seen reference to SIGSEG on the forum but not understood any of the answers.

Is a memory problem, reading or writing an invalid address or something like that.

Quote
As a subsidiary question, is it possible to incorporate the hand images on the form (using TImage ? ) and reference them that way rather than fetch them from 'ProgramDirectory + ...' ?

Is not a good idea since it takes a lot of space in the executable because are stored in a not efficient way. Better use resources.

Go to Project > Project Options > Resources > + Add > Select HourHand.png > OK. Now you have a new resource that will be stored in your executable with the same size as the bitmap has, a few kb.

Then you need to load them with this:

Code: Pascal  [Select][+][-]
  1. uses
  2.   LCLType;
  3.  
  4. //In your form, add this method:
  5.  
  6. procedure LoadBitmap(var ABitmap: TBGRABitmap; const ResourceName: String);

Code: Pascal  [Select][+][-]
  1. procedure TForm1.LoadBitmap(var ABitmap: TBGRABitmap; const ResourceName: String);
  2. var
  3.   res: TResourceStream;
  4. begin
  5.   res := TResourceStream.Create(HInstance, ResourceName, RT_RCDATA);
  6.   if ABitmap <> nil then
  7.     ABitmap.Free;
  8.   ABitmap := TBGRABitmap.Create(res);
  9.   res.Free;
  10. end;    

And you call this:

Code: Pascal  [Select][+][-]
  1. LoadBitmap(HourHand, 'HOURHAND');  

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Adding 'Packages'
« Reply #12 on: November 02, 2016, 07:56:43 pm »
Thanks for your detailed response lainz and I'm certainly happy to share the code which I'll do via my web-site space in a while and send you a pm as suggested. I appreciate that I'm now running well before I can really walk and am very grateful that I can lean upon you for support  :)

I've spent that last couple of hours 'reverse engineering' the project  ie. adding the various components/code from my main program into your project1  (rather than the other way round)   recompiling at each change in an attempt to see which bit of code it doesn't like. Everything is hunky-dory at the moment and fully working with three Hands, Digital-Time, Date and Day-Name displayed. The only thing I haven't moved is the form transparency which I'll do when I've had my evening meal !

FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Adding 'Packages'
« Reply #13 on: November 02, 2016, 08:02:15 pm »
Nice that's working well. We have some clock components in BGRA Controls that you can see, I forget to mention, these are placed at last in the toolbar. The demo that shows them is placed in bgracontrols\test\test_analog_controls.

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Adding 'Packages'
« Reply #14 on: November 03, 2016, 01:09:37 pm »
Now I have a working project with Transparency and Dragging I did a 'Save Project As..' but I wasn't given the option of naming a .PAS file and Unit1 still has that generic title which may well become confusing when I move the project to another location.

I can't see an option to manually rename Unit1 to something more meaningful.

FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

 

TinyPortal © 2005-2018