• Welcome to PlanetSquires Forums.
 

CImageCtx upgrades

Started by Paul Squires, December 15, 2018, 03:56:12 PM

Previous topic - Next topic

Paul Squires

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!
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

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


Paul Squires

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?
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

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.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca


Paul Squires

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

Paul Squires

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).
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

Quote from: Paul Squires on December 15, 2018, 10:05:19 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.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer