Jump to content

dxDrawImage blurring


Decro

Recommended Posts

29 minutes ago, Decro said:

It seems to me that you misunderstood me.

I'm talking about the images "losing quality", become's a bit blurred or something like this on low screen resolutions. Is there a way to fix this?

use the image as a shader

well find a shader that looks like blur something , define it and dxDrawimage it :P

Edited by #BrosS
Link to comment
37 minutes ago, #BrosS said:

use the image as a shader

well find a shader that looks like blur something , define it and dxDrawimage it :P

eh, i'm not looking for a way to BLUR something. I'm trying to fix images LOSING QUALITY when drawn on a screen with resolutions.

Just look at the screenshots inside spoiler.

Edited by Decro
Link to comment
  • Moderators

By doing this:

scx,scy = guiGetScreenSize()
px = scx/1920

You are calculating a ratio for the X axis on the screen for the current resolution. That ratio has to be used to convert a value that is good for a 1920px wide resolution (for example width: 256px) into a value that will be good for another resolution. The ratio on the X axis you calculated will only be good for values on that X axis (so only for posX and width arguments of the dxDrawImage function).

As you don't have the same amount of pixels on the Y axis than on the X axis, you have to calculate another ratio but for that Y axis too. And then use that ratio to convert the posY and height arguments that are good for a 1080px tall resolution:

scx,scy = guiGetScreenSize()
px = scx/1920 -- ratio X
py = scy/1080 -- ratio Y

function draw()
    dxDrawImage(300*px,300*py,256*px,256*py,"image.png")
end

Also, even with that fix, you might still experience some blur according to the wiki page:

Quote

Image files should ideally have dimensions that are a power of two, to prevent possible blurring.
Power of two: 2px, 4px, 8px, 16px, 32px, 64px, 128px, 256px, 512px, 1024px...

(We are talking here about the image source file, not the width and height arguments of that function.)

So if you still see some small blurs (on the text especially), try to edit your image.png to apply that best practice.

Edited by Citizen
  • Like 2
Link to comment
13 hours ago, Citizen said:

By doing this:


scx,scy = guiGetScreenSize()
px = scx/1920

You are calculating a ratio for the X axis on the screen for the current resolution. That ratio has to be used to convert a value that is good for a 1920px wide resolution (for example width: 256px) into a value that will be good for another resolution. The ratio on the X axis you calculated will only be good for values on that X axis (so only for posX and width arguments of the dxDrawImage function).

As you don't have the same amount of pixels on the Y axis than on the X axis, you have to calculate another ratio but for that Y axis too. And then use that ratio to convert the posY and height arguments that are good for a 1080px tall resolution:


scx,scy = guiGetScreenSize()
px = scx/1920 -- ratio X
py = scy/1080 -- ratio Y

function draw()
    dxDrawImage(300*px,300*py,256*px,256*py,"image.png")
end

Also, even with that fix, you might still experience some blur according to the wiki page:

(We are talking here about the image source file, not the width and height arguments of that function.)

So if you still see some small blurs (on the text especially), try to edit your image.png to apply that best practice.

Thank's a lot.

I'm not using ratio Y just to keep image original ratio(by multiplying both sizes to similiar value). Course if you'r trying to draw some square on 16:9 - you would get an rectangle on 4:3, image loses own shapes and proportions this way

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