PlanetSquires Forums

Support Forums => WinFBX - Windows Framework for FreeBASIC => Topic started by: Paul Squires on December 15, 2018, 03:56:12 PM

Title: CImageCtx upgrades
Post by: Paul Squires on December 15, 2018, 03:56:12 PM
Hi Josť,

I made some changes to your CImageCtx control that I'd like to share with you (please see attachment). I added code to handle a "hot" background color when the mouse is over the control. I also modified the image rendering code so that the background is always fully painted with either the normal or hot background color. This ensures that images that have transparent areas can show the correct background color. Of course, doing this introduced a degree of flickering so I also added code to double buffer the control rendering.

I am now using this control to replace the frmHotImageBtn control in the WinFBE source code.

Thanks!
Title: Re: CImageCtx upgrades
Post by: Josť Roca on December 15, 2018, 04:40:42 PM
Excellent. I have updated the Git repository and the documentation.

Title: Re: CImageCtx upgrades
Post by: Paul Squires on December 15, 2018, 05:44:43 PM
Thanks Josť,  :)

I have a feeling that this may not be possible because my initial research did not lead to anything substantive.... Can GDI+ display SVG vector images? It would be very cool if it could because then we could use vector graphics that will scale perfectly at various display resolutions rather than the pixelation we get with raster png, jpg, bmp, etc...  Have you done any work in this area?
Title: Re: CImageCtx upgrades
Post by: Paul Squires on December 15, 2018, 05:50:06 PM
One of the reasons I'm asking is because I now have the svg graphics for the find/replace dialog that the VSCode editor uses. I could convert them to png and use them that way but being able to use the svg directly would be better.
Title: Re: CImageCtx upgrades
Post by: Josť Roca on December 15, 2018, 06:17:02 PM
No, it is not supported.
Title: Re: CImageCtx upgrades
Post by: Paul Squires on December 15, 2018, 06:21:50 PM
Thanks Josť, I will use png's instead.
Title: Re: CImageCtx upgrades
Post by: Paul Squires on December 15, 2018, 10:05:19 PM
Hi Josť,

I made a few more changes to the code.

I added:
      DECLARE SUB SetImageSize (BYVAL nWidth AS LONG, BYVAL nHeight AS LONG, BYVAL fRedraw AS LONG = FALSE)
      DECLARE SUB SetImageWidth (BYVAL nWidth AS LONG, BYVAL fRedraw AS LONG = FALSE)
      DECLARE SUB SetImageHeight (BYVAL nHeight AS LONG, BYVAL fRedraw AS LONG = FALSE)

I changed (in the Constructor):
   ' // Set default values for background normal and hot colors
   m_BkColor    = GetSysColor(COLOR_BTNFACE)
   m_BkColorHot = m_BkColor
 
This allows you to specify a different width and height for the image after it is loaded. This is useful if you want to scale the image based on dpi settings (although obviously the better approach would be to have specific dedicated images for various dpi sizes).
 
Title: Re: CImageCtx upgrades
Post by: Paul Squires on December 16, 2018, 12:13:21 PM
(although obviously the better approach would be to have specific dedicated images for various dpi sizes).

...and this is what I have now done for some of the images in the Find/Replace dialog. I exported the svg image to 24x24 sized png and then loaded either the 16px or 24px image depending on dpi resolution. Looks much nicer.