hello ,
i want to access to a private property ( _imageHeight ) and (_imageWidth) to use this values before uploading picture.
any idea ??
thanks for help
hello ,
i want to access to a private property ( _imageHeight ) and (_imageWidth) to use this values before uploading picture.
any idea ??
thanks for help
You can simply access it like any other properties but we won t guarantee any back compatibility and we might change it in the future. Are you sure there are no corresponding public ?
i canât access to private property :
âerror TS2341: Property â_imageHeightâ is private and only accessible within class âImageâ.â
other corresponding public cant find to get image height and width
Maybe image.width or image.widthInPixels ? Its gui image? Or texture?
image.width always = 100% and imageInPixels always = 0
This is a message from typescript preventing the âuse at your own risk issuesâ but you can cast as any to access it or to a type containing them as public.
But be careful we are not supporting those cases, I can t emphasize this part enough
Its correct. If you use width in % you cant use width in pixels because you use %. In your case 100% from what container? Maybe you can set container width in pixels and get size from container? Or calculate and set image width in pixels?
Normally, you should get the value you want through .domImage.width
and .domImage.height
as it is how _imageWidth
and _imageHeight
are set in the first place.
how can i use cast with _imageHeight ?
.domImage.heigh always return 0 as value
Maybe playground from you help us?
So what are you trying to achieve? except for measurement for the sake of measurement.
https://doc.babylonjs.com/api/classes/babylon.gui.image
I use onImageLoadedObservable for wait loading image and after this take naturalWidth and naturalHeight from loaded image. You problem is try get size before image loaded.
https://www.babylonjs-playground.com/#G5H9IN#18
As @kvasss says, use onImageLoadedObservable
to get the width/height of the picture. Accessing _imageWidth / _imageHeight
wonât help you in your PG, they are both undefined.