Vantha Posted June 13, 2024 Share Posted June 13, 2024 I have an image GUI object and would like to dynamically resize it to its texture's aspect ratio. Is it possible to read an image file's resolution in JavaScript or does it require editing the C++ source code? Link to comment Share on other sites More sharing options...
nani Posted June 13, 2024 Share Posted June 13, 2024 (edited) Not possible directly. But maybe you can hack it around and implicitly get the values by creating a parent object that you can get it GUISize from Engine.getGUIObject(...) javascript call and have the children object centered & have the image at 1:1 ratio (I think you an customize the ratio by adding some string at the end, check the C++ code). Then by iterative approximation calculate when the parent object matches the child object size. Thus you will have the ratio (but not the real resolution). Another easier solution is to set all your textures to the same aspect ration so you can know it in advance. Edited June 13, 2024 by nani Link to comment Share on other sites More sharing options...
Vantha Posted June 13, 2024 Author Share Posted June 13, 2024 (edited) 1 hour ago, nani said: But maybe you can hack it around and implicitly get the values by creating a parent object that you can get it GUISize from Engine.getGUIObject(...) javascript call and have the children object centered & have the image at 1:1 ratio (I think you an customize the ratio by adding some string at the end, check the C++ code). Then by iterative approximation calculate when the parent object matches the child object size. Thus you will have the ratio (but not the real resolution). Not exactly sure if I understand that correctly, what appendage string do you mean? Maybe the best way would be to simply store the images' resolutions somewhere in a file and read it from there. Edited June 13, 2024 by Vantha Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now