Vantha Posted June 13 Report Share Posted June 13 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? Quote Link to comment Share on other sites More sharing options...
nani Posted June 13 Report Share Posted June 13 (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 by nani Quote Link to comment Share on other sites More sharing options...
Vantha Posted June 13 Author Report Share Posted June 13 (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 by Vantha Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.