Recent

Author Topic: New version of BGRABitmap  (Read 285414 times)

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: New version of BGRABitmap
« Reply #375 on: May 21, 2018, 09:22:27 pm »
Ok. That's fixed in version 9.7.4.

https://github.com/bgrabitmap/bgrabitmap/releases
Conscience is the debugger of the mind

Josh

  • Hero Member
  • *****
  • Posts: 1271
Re: New version of BGRABitmap
« Reply #376 on: May 28, 2018, 01:59:33 am »
Hi Circular,

Using BGRASVG. BCSVGAViewer

I seem to have a weird problem,
I am creating a control that has several states; like a button.

If I change the states using svg.loadfromfile Then the states changes.
So I thought I would load the svg into a text array, and use
svg.createfromstring; but this does not always change the state.
If I make my form update a label or control, then the createfromstring works.
i have also tried using AsUTF8String; and this does the same.
It's as though the drawing/rendering is not done when using these properties. Do I have to this manually after loading in the string?

Hope it makes sense


[SOLVED]
Forgot to call the BCSVGAViewer.RedrawBitmap   :-X
« Last Edit: May 28, 2018, 02:24:50 am by josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: New version of BGRABitmap
« Reply #377 on: May 28, 2018, 02:03:08 pm »
That may help  :D

Anyway, happy to see the component useful  :)
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: New version of BGRABitmap
« Reply #378 on: May 29, 2018, 01:58:11 pm »
@josh, you will share your component?

And a suggestion, maybe load all SVG into memory, and switch between them, because loading from disk is slower.. I don't think these use too much memory.


Edit: I readed it better, you're loading from string, good =)
« Last Edit: May 29, 2018, 04:27:23 pm by lainz »

Josh

  • Hero Member
  • *****
  • Posts: 1271
Re: New version of BGRABitmap
« Reply #379 on: May 30, 2018, 04:20:30 am »
Hi

My current 'component' Is not really geared towards a standard component, as it get changed via various triggers. I use the component purely for its events.

So I have been working on a version that I could use for a svg button using svgviewer as a template, the problem I have at the moment is that text property in object inspector appears to be limited to 1024 chars, I thought I could have 3 text properties normal,hover,down but need to think of another approach that does not have this limitation.

Maybe If I could utilize the text caption that statictext uses, but have not investigates to see how it creates the 'memo' popup dialog yet.

The best way to get accurate information on the forum is to post something wrong and wait for corrections.

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: New version of BGRABitmap
« Reply #380 on: May 30, 2018, 02:00:57 pm »
You can use TStringList TStrings, like is used in TMemo and similar components.
« Last Edit: May 30, 2018, 02:09:22 pm by lainz »

Josh

  • Hero Member
  • *****
  • Posts: 1271
Re: New version of BGRABitmap
« Reply #381 on: May 31, 2018, 01:04:08 pm »
Hi Lainz,

Well progressing, slow mainly due to time constraints. And the fact that I do not normally create general components.

I have come across a couple of issues you may be able to help with.

1) How to get a component to draw itself when created, I think the issue is that the svg data is held in tstrings, and at what point do these values get populated on the creation a component, it seems that they are populated after the image has been rendered for the first time, I could be wrong though here.

2) I would like to group the extra properties in a 'Group' property to keep them clear of the normal properties, I created a Tpersistant class, but run into an issue as to how the properties in this class can access class variables in the main class. Not something I normally have to do, so any pointers would be appreciated.

I have googled and searched but I suspect i am searching for the wrong terminology, also only having an hour spare during working days does not help.. ;)
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: New version of BGRABitmap
« Reply #382 on: May 31, 2018, 02:03:24 pm »
1) Good question. Well, it will be easier to see the code. I did a component some time ago called TBGRAImageButton, that was using a resource image stored with the object inspector. And I did it work, so it must be the same, because you're creating from a resource.

https://sourceforge.net/p/bgracontrols/svn/1/tree/custombgraimagebutton.inc

Code: Pascal  [Select][+][-]
  1. procedure TCustomBGRAImageButton.SetFBmp(const AValue: TBitmap);
  2. begin
  3.   if FBmp = AValue then
  4.     exit;
  5.   FBmp.Assign(AValue);
  6.  
  7.   InvalidatePreferredSize;
  8.   AdjustSize;
  9.   Changed;
  10.  
  11.   Invalidate;
  12. end;

I see that in the setter of the Bitmap property, I call Invalidate that calls Paint event.

2) Create a group into a TPersistent

Code: Pascal  [Select][+][-]
  1.   TColorState = class(TPersistent)
  2.   private
  3.     FOwner: TControl;
  4.     FBorderColor: TColor;
  5.     FBorderWidth: integer;
  6.     FColor: TColor;
  7.     procedure SetFBorderColor(AValue: TColor);
  8.     procedure SetFBorderWidth(AValue: integer);
  9.     procedure SetFColor(AValue: TColor);
  10.   public
  11.     constructor Create(AOwner: TControl);
  12.   published
  13.     property Color: TColor read FColor write SetFColor;
  14.     property BorderColor: TColor read FBorderColor write SetFBorderColor;
  15.     property BorderWidth: integer read FBorderWidth write SetFBorderWidth;
  16.   end;  

Notice that you can't publish all things in "published" section, for example you can't publish TBGRAPixel.

Josh

  • Hero Member
  • *****
  • Posts: 1271
Re: New version of BGRABitmap
« Reply #383 on: June 01, 2018, 04:54:33 am »
Hi Lainz.

Attached In Progress package; which contains a simple demo.

It is not finished yet, but thought If I upload it you can have a look see.. ;)

IMPORTANT
ps You will need to move FSVG: TBGRASVG from protected to public in BCSVGViewer

attachment updated 2nd June 2018
« Last Edit: June 02, 2018, 02:48:42 am by josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: New version of BGRABitmap
« Reply #384 on: June 01, 2018, 04:30:02 pm »
Hi josh.

the following code:
Code: Delphi  [Select][+][-]
  1. if fsvgnormal = AValue then
compares the pointer values, but I suppose you want to compare the actual content.

It is not necessary to move FSVG from protected to public. As you derive the class, it has access to its ancestors protected fields. That's why there is such thing as "protected". It is better to avoid making it public because we don't want users to access it directly.
Conscience is the debugger of the mind

Josh

  • Hero Member
  • *****
  • Posts: 1271
Re: New version of BGRABitmap
« Reply #385 on: June 01, 2018, 06:21:41 pm »
Hi Circular,

Thanks for spotting that, if a change with fsvgnormal.text=avalue.text that should correct.

Sorry my mistake with FSVG in the SVGVIEWER it is in the PRIVATE section, not protected.
If I move it to the Protected Section then all OK.
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: New version of BGRABitmap
« Reply #386 on: June 01, 2018, 09:46:23 pm »
Hi, yes, that kind of problems are always easy to fix (private to protected). At least when these are not inside the LCL or something that we can't change at all...

I will try your component tomorrow, and see how it's going.

Josh

  • Hero Member
  • *****
  • Posts: 1271
Re: New version of BGRABitmap
« Reply #387 on: June 02, 2018, 02:46:06 am »
Hi Circular and Lainz.

I have upated the zip with the fixes and some extra properties, previous post has the updated zip. above

FileNameDown,FileNameHover,FileNameNormal. with these you enter the full path name to the svg file, the contents are then transferred to the svgstrings, and the property is then cleared.

Also a new test project and a folder containing the svg images used in the demo, these are not needed in the compiled app of course, just for convenience.
The demo contains 4 buttons covering the form, expanding/stretching the form to re-scale.

ps still need to move the FSVG from private to protetected.

pps should this really be in a new thread or something?
« Last Edit: June 02, 2018, 02:49:22 am by josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Lulu

  • Full Member
  • ***
  • Posts: 226
Re: New version of BGRABitmap
« Reply #388 on: June 02, 2018, 04:30:39 pm »
Hello,
When it is used TBGRATextEffectFontRenderer associated with TBGRABitmap.TextOut(), what is the good way to do text measurment ?
Does TBGRABitmap.TextSize () take into account the outline width and text shadows ?

Edit: I've just see that TBGRATextEffectFontRenderer have a TextSize method. I have to call this instead TBGRABitmap.TextSize ?
« Last Edit: June 02, 2018, 04:32:58 pm by Lulu »
wishing you a nice life

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: New version of BGRABitmap
« Reply #389 on: June 02, 2018, 05:08:57 pm »
It is the same, TBGRABitmap.TextSize call the font renderer TextSize.

I suppose it is a bug in my library. But I don't understand why it's not working.  :'(

I will have a look again and see if I get it.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018