# Truncate resolution

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

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;
}
}
}```
Edited by Joshua Lamusga
##### Share on other sites

• 2 weeks later...

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

Any ideas?

Thankyou

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

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

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

Please feel free to visit my Gallery on PDNFans

And my Alternatives to PDN

##### Share on other sites

OK thanks somemore

##### Share on other sites

AnthonyScoffler,

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

Go out there and be amazing. Have Fun, TR

Some Pretty Pictures Some Cool Plugins

##### Share on other sites

Quote

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

Go out there and be amazing. Have Fun, TR

Some Pretty Pictures Some Cool Plugins

## Join the conversation

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

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×
×