Olaf Doschke
Programmer
This is a follow up for the thread thread184-1803757
The suspicion of vernspace there is that the VFP image control has a memory leak problem if used extensively with larger images (a few MB) and may be related to stretch="isometric".
I couldn't confirm, but the obvious test of such suspicion is using an alternative control and maybe the MS Office Forms Image ActiveX control would be the simplest candidate, where available.
I said it would be far fetched to use the MS WebBrowser control, as it likely has an even worse memory footprint. It creates a dependency, AFAIR with the shdocview.dll, VFP viewcode tool says ieframe.dll. It's simpler to use an ActiveX control that has a dedicated redistributable setup. What to add for Webbrowser control might depend on IE and Windows version.
Anyway, I [highlight #FCE94F]DON'T[/highlight] recommend this, and this demo code also shows one of the much simpler problems before going deeper into the technical problems: Using isometric stretching of an image you will need to put this webbrowser image control on your form in the exact right aspect ratio size, as it has no way to render any excess margin pixels transparent. That's literally an easy to overlook VFP image control feature: When there are some excess pixels as the WxH of the VFP image control is not the image aspect ratio, VFP can render these pixels transparent (BackStyle is transparent by default). The WebBrowser won't.
I still wanted to post the result, as it may help someone to use an image type only browsers support. It will expect a URL in its Picture property, to use a local file instead of a URL prepend the file name with "file://" essentialy and you can also use this with image files not hosted somewhere. I wanted to make the URI capability a feature at least, as it's a disadvantage on the other side anyway, as an image now also needs a download and doesn't show immediately.
Changing the picture at runtime also is not covered by this. The HTML for image display is generated at INIT() time and so requires the wbimage.Picture property to be set at design time. A runtime change won't change the picture.
One of the other few advantages besides being able to use internet images where internet connection is available and the image types browsers support, but VFP doesn't is, that the pictures render better, if you ask me. Especially when the real image size is larger than the WebBrowser control and this the image is downsized, VFPs isometric stretch does not result in the same quality. You can also nicely resized and resampled images using GDI+, but that's a whole different story and may also be an image control replacement I suggested in the PictureVal thread already. It would be more intense work, though.
If you want to use this, subclass the OleControl based on the Webbrowser control and add in the few new properties, Init(), Refresh(), and Destroy() event code, instead of using the class as a PRG. In the visual class and form designer, you won't see the image at design time, but it's far easier to size and anchor the control, any control, visually than by code. The PRG code is only for easier posting.
Bye, Olaf.
Olaf Doschke Software Engineering
The suspicion of vernspace there is that the VFP image control has a memory leak problem if used extensively with larger images (a few MB) and may be related to stretch="isometric".
I couldn't confirm, but the obvious test of such suspicion is using an alternative control and maybe the MS Office Forms Image ActiveX control would be the simplest candidate, where available.
I said it would be far fetched to use the MS WebBrowser control, as it likely has an even worse memory footprint. It creates a dependency, AFAIR with the shdocview.dll, VFP viewcode tool says ieframe.dll. It's simpler to use an ActiveX control that has a dedicated redistributable setup. What to add for Webbrowser control might depend on IE and Windows version.
Anyway, I [highlight #FCE94F]DON'T[/highlight] recommend this, and this demo code also shows one of the much simpler problems before going deeper into the technical problems: Using isometric stretching of an image you will need to put this webbrowser image control on your form in the exact right aspect ratio size, as it has no way to render any excess margin pixels transparent. That's literally an easy to overlook VFP image control feature: When there are some excess pixels as the WxH of the VFP image control is not the image aspect ratio, VFP can render these pixels transparent (BackStyle is transparent by default). The WebBrowser won't.
I still wanted to post the result, as it may help someone to use an image type only browsers support. It will expect a URL in its Picture property, to use a local file instead of a URL prepend the file name with "file://" essentialy and you can also use this with image files not hosted somewhere. I wanted to make the URI capability a feature at least, as it's a disadvantage on the other side anyway, as an image now also needs a download and doesn't show immediately.
Changing the picture at runtime also is not covered by this. The HTML for image display is generated at INIT() time and so requires the wbimage.Picture property to be set at design time. A runtime change won't change the picture.
One of the other few advantages besides being able to use internet images where internet connection is available and the image types browsers support, but VFP doesn't is, that the pictures render better, if you ask me. Especially when the real image size is larger than the WebBrowser control and this the image is downsized, VFPs isometric stretch does not result in the same quality. You can also nicely resized and resampled images using GDI+, but that's a whole different story and may also be an image control replacement I suggested in the PictureVal thread already. It would be more intense work, though.
If you want to use this, subclass the OleControl based on the Webbrowser control and add in the few new properties, Init(), Refresh(), and Destroy() event code, instead of using the class as a PRG. In the visual class and form designer, you won't see the image at design time, but it's far easier to size and anchor the control, any control, visually than by code. The PRG code is only for easier posting.
Bye, Olaf.
Code:
o = CreateObject("testform")
o.show(1)
Define Class testform as form
Height = 325
Width = 500
Add Object img1 as wbimage With;
Picture = '[URL unfurl="true"]https://picsum.photos/400/300',;[/URL]
Top = 50,;
Left= 50
EndDefine
**************************************************
*-- Class: wbimage
*-- ParentClass: olecontrol
*-- BaseClass: olecontrol
*-- Time Stamp: 07/04/20 06:45:07 PM
*-- OLEObject = C:\Windows\SysWOW64\ieframe.dll
*
Define Class wbimage As OleControl
OleClass = 'Shell.Explorer.2'
Height = 225
Width = 400
*-- Specifies the graphics file or field to display on the control.
Picture = ("")
*-- html for this image "control" (as it's a webbrowser control under the hood)
imagehtml = ""
Name = "wbimage"
Procedure Refresh
*** ActiveX Control Method ***
NoDefault
Endproc
Procedure Init
Local lcHTML, lcHTMLFile
TEXT To lcHTML NoShow TextMerge
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge; chrome=1" />
<title>HTML img</title>
<style>
* {
margin:0;
border:0;
padding:0;
}
.fullviewport {
display:block;
min-width:100%;
min-height:100%;
width:100%;
height:100%;
background-color:rgba(128,128,128,0.0);
overflow: hidden;
}
.imageblock {
display: table;
width:100vw;
height:100vh;
text-align: center;
white-space: nowrap;
}
.centered {
display: table-cell;
vertical-align: middle;
}
</style>
</head>
<body class="fullviewport">
<div class="imageblock">
<div class="centered">
<img src="<<This.Picture>>" style="max-width:100vw; max-height:100vh;">
</div>
</div>
</body>
</html>
ENDTEXT
This.imagehtml = Addbs(Getenv("TEMP"))+Sys(2015)+".html"
Strtofile(lcHTML,This.imagehtml)
This.navigate2("file://"+This.imagehtml)
Endproc
Procedure Destroy
Try
Erase (This.imagehtml)
Catch
*
Endtry
Endproc
Enddefine
*
*-- EndDefine: wbimage
**************************************************
Olaf Doschke Software Engineering