01-08-2020 01:19 AM
Hi all,
I'm trying to horizontally center a picture into an image control. Unfortunately, this is not working so far...
I can't change the image control size as I'm using different pictures which have not the same dimensions.
There is a lot of posts talking about pictures in LabView, but I didn't find any concrete answer for my specific issue.
Here is a screenshot of my current try.
Could someone help me?
Thank you in advance for your precious help!
Julien
Solved! Go to Solution.
01-08-2020 01:27 AM
Hi Gub,
it would really help when you would attach your VI instead of a simple image of a part of your block diagram…
@Gub156 wrote:
I'm trying to horizontally center a picture into an image control. Unfortunately, this is not working so far...
What is "not working"? (That's not an error message from LabVIEW…)
01-08-2020 02:00 AM
Hi GerdW,
Thank you for your answer. Attached, you'll find the related VI.
Also here are more details about my issue: I can't figure out how the horizontal alignment works. Currently, I have two different pictures and one is centering correctly. The second one is absolutely not centered (see pictures).
Hope that my comments help to understand my issue.
Thank you in advance.
Julien
01-08-2020 02:52 AM - edited 01-08-2020 02:57 AM
I'd keep the origin at 0,0. That's usually more intuitive:
The horizontal center to draw the image (with it's original W\H!), is ( control.W - img.H*scale ) / 2 / scale.
01-08-2020 02:59 AM
BTW. The build in function "Get File Extension.vi" returns the file extension.
01-08-2020 03:12 AM
Hi wiebe,
Thank you for your answer. I'm actually running LabView 2017 and I can't run your VI. Is this "Get File Extension" VI new? I never saw it?
Anyway, I'll try your solution in my VI and post my answer later.
Regards,
Julien
01-08-2020 03:15 AM
Hi Gub,
@Gub156 wrote:
I'm actually running LabView 2017 and I can't run your VI. Is this "Get File Extension" VI new? I never saw it?
GetFileExtension is also available in LV2017. As it's a file-related function you should look into the file functions palette (or use Quickdrop)…
01-08-2020 03:20 AM
Note that x2^-1 is simply a x/2 or x*.5.
x2^-1 is beneficial when scaling integers, because the output is an integer.
In your example, the input was an integer, before I changed it to a dbl.
01-08-2020 03:34 AM
Thank you for your solution! It works perfectly!
I hope this will help other users as well.
Regards,
Julien