I want to find the ImageSize
or at least dimensions of any control object irrespective of it being an image or an any other control such as Button
s,etc.
This is my code for button:
button = Button["ew", Null, ImageSize -> {100, 50}]
ImageDimensions
provides size of images only and not of control objects. So, initially, I rasterized my control object using Rasterize
. And then displayed the image dimensions. However the image dimensions is not exact value.
rastButton = Rasterize[button, RasterSize -> 100]
bt = Button["ew", Null, {ImageSize -> {100, 50}}]
rastbt = Rasterize[bt, RasterSize -> 100]
ImageSize[rastbt]
ImageDimensions[rastbt]
(* Out[272] = {100, 52} *)
bt = Button["ew", Null, {ImageSize -> {100, 1}}]
rastbt = Rasterize[bt, RasterSize -> 100]
ImageSize[rastbt]
ImageDimensions[rastbt]
(* Out[272] = {100, 17} *)
I also believe Rasterize
provides error values when I call Rasterize[button][[2, 2]]
. Is this a bug? Is there any workaround to estimate the size of control objects?
Ultimately, the purpose of estimating the size is to place the control object very accurately in a grid layout within specified co ordinates.