Jump to content

Image on different resolutions


DakiLLa

Recommended Posts

Hi! I have a problem here, I think you can help me a bit..

I have to render a picture on my screen. The size of the picture is 128x128. And I made it so the pic size is depends on user's screen resolution.

I'll try to show you, what I mean:

local scX, scY = guiGetScreenSize();
local hX, hY = scX/10, scY/8;
 
addEventHandler( 'onClientRender', root, function()
dxDrawImage( scX/1.5, scY/2-hY/2, hX, hY, 'house.png' );
end );
 

Now let's see, how this picture will look like on diffrent screen resolutions:

800x600

-broken image link removed at the request of OP-

1280x1024

-broken image link removed at the request of OP-

1920x1080

-broken image link removed at the request of OP-

As you can see, house picture on the last screenshot is a bit streched. Well, the question is: how to make that the picture won't be streched on wide screens?

Link to comment

That's because you use relative width and height.

You should always leave the proportions intact.

If the width and height is too big for a smaller resolution, then just divide both values with the same divisor, which depends on, for example, the width of the screen.

So, for example:

width = 128 * screenWidth / 1280
height = 128 * screenWidth / 1280

Here, your size of the image is also made for an 1280px width resolution. That means that the original size will be shown at this resolution, although at smaller ones, the image will also get smaller. Same for higher resolutions, the higher, the bigger the image.

Hope I made no mistakes myself ;)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...