Yea, I noticed that, BigSchottkyD. Sorry about that. I haven’t had a chance to look into it… maybe you can store the scaled data in a byte stream of some kind?
The bottleneck could be the database query. Is the database query fast? If not add an index on the PartID and/or the whichPicture column.
You might consider executing the database query sometime before you have to display the image and storing the image bytes somewhere in the client, perhaps in a Python module variable.
Then when you need to display the image read the bytes from where you stored them in the client and display the image.
I was having the same problem when loading the image from a file location, too. I think it is because the repaint is happening every 250ms (or whatever) and loading and resizing the image is CPU intensive, or at least causing Ignition client to respond slowly to user interaction.
Hey, maybe you could wrap the entire repaint functionality in an “invokeAsynchronous” function?
Maybe a silly question, but why are you reloading the image data on every repaint?
I’m using something very similar and have a custom Dataset property (named ImageBytes) defined for the canvas. The SQL query to get the image data is a SQL Query property binding.
In the repaint event i access the custom property:
if event.source.ImageBytes.rowCount > 0:
bytes = event.source.ImageBytes.getValueAt(0, 0)
else:
bytes = None
if bytes:
... your code here
else:
... paint a string like 'no image data available'