PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: CImageCtx upgrades  (Read 372 times)

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8762
  • Windows 10
    • PlanetSquires Software
CImageCtx upgrades
« 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!
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3170
Re: CImageCtx upgrades
« Reply #1 on: December 15, 2018, 04:40:42 PM »

Excellent. I have updated the Git repository and the documentation.

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8762
  • Windows 10
    • PlanetSquires Software
Re: CImageCtx upgrades
« Reply #2 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?
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8762
  • Windows 10
    • PlanetSquires Software
Re: CImageCtx upgrades
« Reply #3 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.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3170
Re: CImageCtx upgrades
« Reply #4 on: December 15, 2018, 06:17:02 PM »

No, it is not supported.

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8762
  • Windows 10
    • PlanetSquires Software
Re: CImageCtx upgrades
« Reply #5 on: December 15, 2018, 06:21:50 PM »

Thanks Josť, I will use png's instead.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8762
  • Windows 10
    • PlanetSquires Software
Re: CImageCtx upgrades
« Reply #6 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).
 
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8762
  • Windows 10
    • PlanetSquires Software
Re: CImageCtx upgrades
« Reply #7 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.
 
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer