HUD Size Measurements

I couldn’t come up with a good title, but is there a way where you can use ScrW() and ScrH() to get the exact size of the picture? Like if the picture was 512 x 512, how could I get the exact size using ScrW() and ScrH()?

ScrW() and ScrH() are used to measure the size of the GMod window. It’s not meant to measure the size of an image for example.


I know, but I thought you could divide something by ScrW() or ScrH() to get the size of the image. Like if the ScrW() / 15 would be 512 pixels wide ( Just an example ).

What image are you trying to get the size of?

I know the size of the image, I am just trying to get it to be the exact size it is in photoshop on the screen. It’s 512 x 512 and I was wondering if I could do ScrW() / x and ScrH() / x to get it to be 512 x 512.

I don’t think that’s possible.

Draw it at 512 by 512 on the screen?

[editline]7th January 2011[/editline]


SizeToContents() will make it 512x512

Thanks _Undefined. And Drew, I wanted HUD, not Vgui, thanks though.


Divide the screen size for the image size, the result is the ratio between the screen size and the image size, divide the screen size by the result and you get the image size.

ratioy = ScrH / imagesxsize
imagesizey = ScrH() / ratioy