Recent

Author Topic: ImageList SVG  (Read 2066 times)

lainz

  • Hero Member
  • *****
  • Posts: 3914
  • Leandro Diaz
Re: ImageList SVG
« Reply #15 on: October 18, 2020, 09:03:49 pm »
Going forward, what I really think would be great would be to be able to render the bitmaps on the fly. Basically when the button draws the glyph from the image list, at that point it could be computed with the adequate resolution.

Not sure what is needed to override. In bgracontrols we use getbitmap but as well can be used the draw method...

We definitely need to edit the sources of imagelist for that you need Lazarus trunk installed...

lainz

  • Hero Member
  • *****
  • Posts: 3914
  • Leandro Diaz
Re: ImageList SVG
« Reply #16 on: November 14, 2020, 03:31:01 pm »
I've implemented the BGRA SVG Image List, is not compatible with TImageList, but it will be useful for new SVG controls.

circular

  • Hero Member
  • *****
  • Posts: 3643
    • Personal webpage
Re: ImageList SVG
« Reply #17 on: November 14, 2020, 04:48:43 pm »
I am thinking that we can add a function to populate a TImageList. Like a function with an array of sizes.
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 3914
  • Leandro Diaz
Re: ImageList SVG
« Reply #18 on: November 14, 2020, 05:41:19 pm »
I am thinking that we can add a function to populate a TImageList. Like a function with an array of sizes.

Good idea.

winni

  • Hero Member
  • *****
  • Posts: 2113
Re: ImageList SVG
« Reply #19 on: November 14, 2020, 06:01:47 pm »
Hi!

I have not yet looked into the code, but more than  an imageList I would like to get an icon of any size on the fly:

Code: Pascal  [Select][+][-]
  1. MyBGRAbitmap := SVGimageList.exportIcon (1,48,48);
  2.  

Winni

lainz

  • Hero Member
  • *****
  • Posts: 3914
  • Leandro Diaz
Re: ImageList SVG
« Reply #20 on: November 15, 2020, 02:21:56 am »
Hi!

I have not yet looked into the code, but more than  an imageList I would like to get an icon of any size on the fly:

Code: Pascal  [Select][+][-]
  1. MyBGRAbitmap := SVGimageList.exportIcon (1,48,48);
  2.  

Winni

Good idea, thanks, I will implement it.

Edit: Done, is used like this

Code: Pascal  [Select][+][-]
  1. procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  2. var
  3.   bmp: TBGRABitmap;
  4. begin
  5.   bmp := BGRASVGImageList1.Get(0, Bitmap.Width, Bitmap.Height);
  6.   Bitmap.PutImage(0, 0, bmp, dmDrawWithTransparency);
  7.   bmp.Free;
  8. end;
« Last Edit: November 15, 2020, 02:32:44 am by lainz »

lainz

  • Hero Member
  • *****
  • Posts: 3914
  • Leandro Diaz
Re: ImageList SVG
« Reply #21 on: November 15, 2020, 03:46:57 am »
I am thinking that we can add a function to populate a TImageList. Like a function with an array of sizes.

Done

Code: Pascal  [Select][+][-]
  1. BGRASVGImageList1.PopulateImageList(ImageList1, [16, 20, 24, 32]);

circular

  • Hero Member
  • *****
  • Posts: 3643
    • Personal webpage
Re: ImageList SVG
« Reply #22 on: November 15, 2020, 11:20:42 pm »
Great stuff  :)

In order to have the size fully dynamic depending on the DPI, I suggest that the Width / Height of the image list be interpreted relative to a ReferenceDPI property with default value 96. Then the size in pixels for a certain surface will be Round(Width / ReferenceDPI * TargetDPI) and similarly vertically.

Following this principle, the Draw function with only x and y parameters would be replaced by a function with x and y parameters and a target DPI. Alternatively, we can have a Draw function with x and y and a target control or provide a function that computes the DPI. Indeed, the target DPI can be computed from the PixelsPerInch and GetCanvasScaleFactor.

To let the controls know what is the resulting size, it would be handy to have a function GetSizeOnSurface(ATargetDPI: integer): TSize. So the controls that use the image list can determine the layout to place the image.

What do you think?
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 3914
  • Leandro Diaz
Re: ImageList SVG
« Reply #23 on: November 15, 2020, 11:28:39 pm »
For me it's ok. By default the image list is designed to have at 96, but I'm not sure on macOS. On Windows say I have 16x16, I must provide in the array the values for each zoom factor, or at least the actual, say only 16 or if its 200%, 16 and 32.

lainz

  • Hero Member
  • *****
  • Posts: 3914
  • Leandro Diaz
Re: ImageList SVG
« Reply #24 on: December 13, 2020, 05:00:32 pm »
Tutorial on how to use the SVG Image List
https://forum.lazarus.freepascal.org/index.php/topic,52500.msg387077/topicseen.html

Tutorial on how to use the SVG Image List (Wiki)
https://wiki.freepascal.org/SVG_Image_List

 

TinyPortal © 2005-2018