Jump to content

Deeplink image on GUI


Sannie72
 Share

Recommended Posts

I would like to have a Pic(ture) control in a gui that is filled with an online jpg, I have a deeplink to a library of images and depending on the selection I want to show a different URL.

This images has an url like https://fleet.siemens-healthineers.com/static/images/02_11060815_NL.jpg

Is this directly possible, or do I need to download an image first and then use it?

Link to comment
Share on other sites

  • Moderators

Sannie72,

Welcome to the AutoIt forums.

I am unsure quite what you want to do. How are you intending the user to select the image? I would suggest a combo filled with short item descriptions and then when the user selects the required item you can use a 2D array to link the item to an image URL and display it.

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

40 minutes ago, Melba23 said:

Sannie72,

Welcome to the AutoIt forums.

I am unsure quite what you want to do. How are you intending the user to select the image? I would suggest a combo filled with short item descriptions and then when the user selects the required item you can use a 2D array to link the item to an image URL and display it.

M23

 

The thing I want to do is the following. This is the GUI I created so far:

image.thumb.png.ac122ea8398c6d431bd602dc967fb1f9.png

It is an app to be used (mainly) by our Call Center to quickly find telephone numbers and system numbers for the systems installed throughout the country.
Select a city (1), select the customer (2), select the equipment (3) and see the contact and contract info (4). It would be nice to also show an image there, indicated by the red box. Because of compliance issues I cannot post the whole sourcecode, but I hope this makes it clear what I am trying to accomplish. The 8-digit number is also the number in the URL I posted before.
Because of the number of possibilities (thousands of images) I do not want to download all images but just show them on the fly.

Link to comment
Share on other sites

  • Moderators

Sannie72,

Much clearer now, thanks. I quite understand why you do not want to download all the images - so I think you will have to embed some form of browser to display the images when required.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Here one easy way you could do it :

#include <GUIConstantsEx.au3>
#include <InetConstants.au3>
#include <StaticConstants.au3>
#include <SendMessage.au3>
#include <GDIPlus.au3>

InetGet ("https://fleet.siemens-healthineers.com/static/images/02_11060815_NL.jpg", "Test.jpg", $INET_FORCERELOAD)
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile("Test.jpg")
$hImageRez = _GDIPlus_ImageResize($hImage, 100, 80)
_GDIPlus_ImageDispose($hImage)
$hGUI = GUICreate("Test")
$idPic = GUICtrlCreatePic("", 10, 10, 100, 80)
$hBitMap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageRez)
_GDIPlus_ImageDispose($hImageRez)
_WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($idPic), $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap))
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_Shutdown()
FileDelete("Test.jpg")

GUISetState()

While True
  Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
      ExitLoop
  EndSwitch
WEnd

 

Link to comment
Share on other sites

An even better way, without file :

#include <GUIConstantsEx.au3>
#include <InetConstants.au3>
#include <StaticConstants.au3>
#include <SendMessage.au3>
#include <GDIPlus.au3>

$dImage = InetRead ("https://fleet.siemens-healthineers.com/static/images/02_11060815_NL.jpg", $INET_FORCERELOAD)
_GDIPlus_Startup()
$hImage = _GDIPlus_BitmapCreateFromMemory($dImage)
$hImageRez = _GDIPlus_ImageResize($hImage, 100, 80)
_GDIPlus_ImageDispose($hImage)
$hGUI = GUICreate("Test")
$idPic = GUICtrlCreatePic("", 10, 10, 100, 80)
$hBitMap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageRez)
_GDIPlus_ImageDispose($hImageRez)
_WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($idPic), $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap))
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_Shutdown()

GUISetState()

While True
  Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
      ExitLoop
  EndSwitch
WEnd

 

Link to comment
Share on other sites

Link to comment
Share on other sites

Reading OP's description it sounds like a picture control isnt needed, but just want to show an Image there.

If that's the case, then this could do it.

#include <GDIPlus.au3>

$hGUI = GUICreate("Test")
GUISetState()

_GDIPlus_Startup()
_GDIPlus_GraphicsDrawImageRect(_GDIPlus_GraphicsCreateFromHWND($hGUI),_GDIPlus_BitmapCreateFromMemory(InetRead("https://fleet.siemens-healthineers.com/static/images/02_11060815_NL.jpg", 1)), 10, 10, 100, 80)
_GDIPlus_Shutdown()

While True
  Switch GUIGetMsg()
    Case - 3
      ExitLoop
  EndSwitch
WEnd

No variables other than HGUI and nothing to dispose. :D

Edited by Werty

Some guy's script + some other guy's script = my script!

Link to comment
Share on other sites

1 hour ago, Werty said:

No variables other than HGUI and nothing to dispose

No. You do not get it.  It is not just drawing ONE image in a whole GUI.  He needs to show hundreds of images on a small portion of a larger GUI.  Your example is useless for what he needs to do.

Edited by Nine
Link to comment
Share on other sites

Please explain 😕

include <GDIPlus.au3>

$hGUI = GUICreate("Test")
GUISetState()

_GDIPlus_Startup()

For $loop = 1 To 100; Hundreds!

_GDIPlus_GraphicsDrawImageRect(_GDIPlus_GraphicsCreateFromHWND($hGUI),_GDIPlus_BitmapCreateFromMemory(InetRead("https://fleet.siemens-healthineers.com/static/images/02_11060815_NL.jpg", 1)), Random(0, 320), Random(0, 240), 100, 80)

Next
_GDIPlus_Shutdown()

While True
  Switch GUIGetMsg()
    Case - 3
      ExitLoop
  EndSwitch
WEnd

Ofcourse the end result would require a variable, having all the jpg addresses in an array, so it would be something like...

_GDIPlus_GraphicsDrawImageRect(_GDIPlus_GraphicsCreateFromHWND($hGUI),_GDIPlus_BitmapCreateFromMemory(InetRead($Address_Of_JPG[$Loop]), 1)), 10, 10, 100, 80)

Else i dont see why it wouldnt work.

/edit

Just tried a 1000 loop and yes, there's memory leak ofcourse since it's "undisposable" :D

Without memory leak, and you get your variables and disposes :D

#include <GDIPlus.au3>

$hGUI = GUICreate("Test")
GUISetState()

_GDIPlus_Startup()

For $loop = 1 To 1000; Hundreds!
   $dImage = InetRead ("https://fleet.siemens-healthineers.com/static/images/02_11060815_NL.jpg", 1)
   $hImage = _GDIPlus_BitmapCreateFromMemory($dImage)
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, Random(0, 320), Random(0, 240), 100, 80)
_GDIPlus_ImageDispose($hImage)
_WinAPI_DeleteObject($hGraphics)
Next
_GDIPlus_Shutdown()

While True
  Switch GUIGetMsg()
    Case - 3
      ExitLoop
  EndSwitch
WEnd

 

Edited by Werty

Some guy's script + some other guy's script = my script!

Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...