Jump to content
How to Install Plugins ×

Truncate resolution


NinthDesertDude

Recommended Posts

Overview

This simulates resolution loss. All it does is take the values of each color channel (and optionally the transparency channel), divide by a number, round, and multiply by that number again. This simple math trick causes values to snap to multiples of the given number. So if I take the image and provide 8 as a number, every color channel should, theoretically, be a multiple of 8.

 

Edit: This effect can be simulated by the Channel Ops plugin I developed, so this effect is only good for convenience if used often.

 

39h9UnT.gif Simple gif of gradients demonstrating the effect over its range.

SCoYQGn.png Progressive resolution (this was manually done).

Purpose and Application

You can make stylized images, create unusual and aesthetic dithering effects, and simulate different resolutions without actually saving the image in two different resolutions. Located in the Stylize menu under the Effects tab.

 

Options

Resolution Loss: The colors (and optionally alpha) will become multiples of this number to simulate resolution loss.

 

Affect transparency: Whether or not the transparency channel should be affected by the truncation process.

 

Remarks

With the resolution loss, from 171 and on, a natural effect of the multiples causes the image to get a bit darker before progressing towards 255. This is because at 170, there can no longer be any multiples that reach 255, making 171 the largest possible number. 170 and under are immune to this effect because White / 170 = 1.5, which is the last number that rounds up (white = 255). There are other small divots in color change due to prime number multiples that cannot get high enough to reach 255. This is not contrast and cannot be simulated properly by contrast algorithms. I was a bit surprised not to see one of these already, as they're quite simple :)

 

Source

#region UICode
int Amount1 = 30; //[1, 255] Resolution Loss
bool Amount2 = false; //[0,1] Affect transparency
#endregion

//Simply rounds a number to the nearest 'roundTo' point.
//roundTo is an absolute value, so negative numbers are ignored.
float Round(float roundTo, float data)
{
    data = (int)Math.Round(data / roundTo) * roundTo;
    return data;
}

void Render(Surface dst, Surface src, Rectangle rect)
{
    ColorBgra CurrentPixel;
    for (int y = rect.Top; y < rect.Bottom; y++)
    {
        if (IsCancelRequested) return;
        for (int x = rect.Left; x < rect.Right; x++)
        {
            CurrentPixel = src[x,y];
            //Truncates the colors.
            CurrentPixel.R = Int32Util.ClampToByte((int)Round(Amount1, (float)CurrentPixel.R));
            CurrentPixel.G = Int32Util.ClampToByte((int)Round(Amount1, (float)CurrentPixel.G));
            CurrentPixel.B = Int32Util.ClampToByte((int)Round(Amount1, (float)CurrentPixel.);
                
            //Truncates alpha if the user wanted it to do so.
            if (Amount2)
            {
                CurrentPixel.A = Int32Util.ClampToByte((int)Round(Amount1, (float)CurrentPixel.A));
            }
            dst[x,y] = CurrentPixel;
        }
    }
}

Truncate Resolution.zip

Edited by Joshua Lamusga
  • Upvote 1
Link to comment
Share on other sites

  • 2 weeks later...

When I download the .dll Norton finds and deletes it.

If I turn off Norton, install it, Norton finds it in the PDN folder and deletes it.

 

Any ideas?

 

 Thankyou

Link to comment
Share on other sites

When I download the .dll Norton finds and deletes it.

If I turn off Norton, install it, Norton finds it in the PDN folder and deletes it.

 

Any ideas?

 

 Thankyou

Here's an idea: Get rid of Norton's Anti-Virus.

Seriously, it is the worst anti-virus program out there. There are free ones that are WAY better than Norton's.

  • Upvote 1
Link to comment
Share on other sites

Here's an idea: Get rid of Norton's Anti-Virus.

Seriously, it is the worst anti-virus program out there. There are free ones that are WAY better than Norton's.

Agreed.

Norton and all the other paid variations throw out false positives to justify their price tag!

 

ZXCBOoZ.png

 

 

Link to comment
Share on other sites

Try Avast Free. Excellent AV. Been using it for years on the laptop and now the mobile version on the phone & tablet.

 

Back on topic- interesting plugin Anthony. Nice gif showing what it can do. Thanks. :)

Edited by Goonfella
  • Upvote 1

 

 

Please feel free to visit my Gallery on PDNFans

And my Alternatives to PDN

Link to comment
Share on other sites

Quote

When I download the .dll Norton finds and deletes it.

If I turn off Norton, install it, Norton finds it in the PDN folder and deletes it.

I have zipped my .dll file.

Edited by Joshua Lamusga
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...