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 Buttons,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.




bt = Button[sd, Null, ImageSize -> {10, 20}]; Rasterize[bt][[2, 2]] ImageDimensions[Rasterize[bt, ImageSize -> {10, 20}]] Rasterize[bt][[2, 2]]It gives me result as(*{10, 28},{10, 20},{10, 28}*). I want to find exact button size. The idea you have given isRasterizethe button size and give result, but i want to extract exact size. – niren Jan 17 '13 at 08:17