Followers 0

# Truncate resolution

## 9 posts in this topic

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.

Simple gif of gradients demonstrating the effect over its range.

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 AnthonyScoffler
0

##### Share on other sites

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

Any ideas?

Thankyou

0

##### Share on other sites

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.

1

##### 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!

0

##### 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
1

##### Share on other sites

OK thanks somemore

0

##### Share on other sites

AnthonyScoffler,

Save your uploads as ZIP files. DLL's get flagged by everything with an "anti" in their description.

0

##### Share on other sites

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

Norton must be stupid because the source code is right there. I recommend MalwareBytes over all else (Avast became too troublesome to me, never tried AVG, but Kaspersky Security is good).

Save your uploads as ZIP files. DLL's get flagged by everything with an "anti" in their description.

But all kinds of software had Dll files in it. I just don't see how the people who made Norton, as programmers, could be ignorant enough to assume all .dll files are virus-related. That would be stupider than politics. Zipping the .dll files won't do anything because unless Paint.NET extracts them from zips when it runs, then the dlls will need to be extracted and according to Don Gordon, it gets deleted even then.

Don Gordon, all I can do is recommend you stop using Norton and McAfee. Please, for the betterment of software.

0

##### Share on other sites

No need to be so drastic, Norton allows the user to exclude an apps and folders from it's virus scan.

0