Jump to content

How to speed up GUICtrlSetImage()


4Eyes
 Share

Recommended Posts

Hi guys, this is my first post.

I'm seeing quite slow update with GUICtrlSetImage. I have 6 of them being updated with the same image (for test purposes) and I can see about 0.5 second delay between the 1st to the 2nd to the 3rd ... you can guess the rest.

The code concerned is as follows:

GUICtrlSetImage($ctrlPic1, $PicNameArray[$counter]) ; display next pic

If $NumPicsOnScreen > 1 Then GUICtrlSetImage($ctrlPic2, $PicNameArray[$counter]) ; display pic in 2nd posi

If $NumPicsOnScreen > 2 Then GUICtrlSetImage($ctrlPic3, $PicNameArray[$counter]) ; display pic in 3rd posi

If $NumPicsOnScreen > 3 Then GUICtrlSetImage($ctrlPic4, $PicNameArray[$counter]) ; display pic in 4th posi

If $NumPicsOnScreen > 4 Then GUICtrlSetImage($ctrlPic5, $PicNameArray[$counter]) ; display pic in 5th posi

If $NumPicsOnScreen > 5 Then GUICtrlSetImage($ctrlPic6, $PicNameArray[$counter]) ; display pic in 6th posi

Is there a way to speed this up?

Thanks,

4Eyes

Link to comment
Share on other sites

  • Moderators

4Eyes,

First, welcome to the AutoIt forums. A good start - some code to work on and a clear question. I wish some other newcomers would do the same. :-)

As to your problem, it is difficult to determine what might be happening from such a small snippet of code. Although the code you posted is not exactly "optimised", it should not give a .5 second delay - so the problem must be elsewhere. Please post or upload the whole script (and perhaps the image you are using) so I can take a look.

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

Mate, I appreciate your interest but the code is ugly and not really up to the standard of the experts here. basically a series of quick and dirties to test whether a new project will fly. Clearly, I don't really want to see the same graphic 6 times in 1 gui, but as I said, it's a test. Um... if you'd pm me your email I can email it to you.

I think the issue may be related to the resizing of the graphic that needs to be displayed.

Thanks,

4Eyes

Link to comment
Share on other sites

I don't know how to speed up the GUICtrlSetImage(), but for code optimization I suggest:

Dim $ctrlPic[6]

$ctrlPic[0] = GUICtrlCreatePic(....

; ... add [1], [2], ..., [6] here ....;

For $i = 0 To $NumPicsOnScreen

GUICtrlSetImage($ctrlPic[$i], $PicNameArray[$counter])

Next

I can't tell if this is faster or anything, but it's another way of doing it, be it better or worse, don't know.
[font="Courier New"]http://RomanK.hondadesigns.com[/font]
Link to comment
Share on other sites

I don't know how to speed up the GUICtrlSetImage(), but for code optimization I suggest:

I can't tell if this is faster or anything, but it's another way of doing it, be it better or worse, don't know.

RomanK,

Adding another array access is not going to speed it up, but thanks for the suggestion. BTW, I know the code may look a little odd but I did it that way on purpose as there may be anywhere from 1 to 6 picture controls on the screen so it's not a matter of writing into all of them all of the time.

BTW, I have a feeling that I did not keep the pic controls to a 4:3 ration when I wrote the test code. So not only do the pic's have to be scaled down from 2000 odd pixels x 2000 odd pixels they would need to be further manipulated to the odd aspect ratio. I hope to test this shortly and advise.

Thanks,

4Eyes

Link to comment
Share on other sites

A half-second doesn't sound unreasonable to read, resize and display a 2000x2000+ image.

I'd think you'd need to generate (and store) thumbnails or down-sized versions to speed things up.

Or, stripe three Western Digital Velociraptors together :D

Link to comment
Share on other sites

A half-second doesn't sound unreasonable to read, resize and display a 2000x2000+ image.

I'd think you'd need to generate (and store) thumbnails or down-sized versions to speed things up.

Or, stripe three Western Digital Velociraptors together :D

Spiff59,

Well, I dunno how you could pluck a figure out of the air like that. To start with it would depend on the h/w the app is running on. In my case Core2Quad @ 2.4GHz, a reasonable video card (NVidia 9600) and 2GB of ram.

Setting the controls to be 4:3 aspect ratio made no appreciable difference but scaling down the source image to 100 x 75 made it lightening quick. That's too small but then the originals are 2592 x 1944 ... shock, horror!

I was REALLY hoping to avoid manipulating the images as this project is destined for non-computer literate users. Hmm... I could provide a button that they could click to scan and resize as nec. That'll have to do I think.

Ok, thanks to all those who gave my problem consideration. It's appreciated.

Regards,

4Eyes

Link to comment
Share on other sites

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...