Jump to content

dxDrawImage scaling


iNev.

Recommended Posts

Posted

Hello,can anyone explain me how to scale dxDrawImage that will look as nice on 640x480 as nice it's looking on 1920x1080? I heard someone maked a function 'zoom' or something, can someone tell me how to make a function like this? Yeah, I know I can just don't scale the picture but I want to make an image 300x420, so it's 1/8 of a Full HD screen, but if I don't scale it, it will be a half screen on 640x480. So I need to scale it, but it's being ugly blurry on 640x480. Please help me.

Posted

You can do it like this.

 

local myX, myY = 1280, 1024 -- The resolution you've used for making the guis
local sX, sY = guiGetScreenSize() -- The resolution of the player
local gX, gY, gW, gH = 500, 500, 250, 50 -- The size of the image obtained from the guieditor with my resolution 1280 1024

local rX = gX / myX -- (0.3906) We obtain the relative position, for making it equal in all screen resolutions
local rY = gY / myY -- (0.4883)
local rW = gW / myX -- (0.1953)
local rH = gH / myY -- (0.0488) 

local aX = sX * rX -- Now we multiply the relative position obtained previously by the client resolution for having an absolute position from the client screen
local aY = sY * rY
local aW = sX * rW
local aH = sY * rH

dxDrawImage( aX, aY, aW, aH, "image.png" )

-- Now you know what you have to do, so you can make it smaller by making the calculations directly.

 

"Keep making it simplex."

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