How does the "Pixel shapping" work?

Here everybody can post his problems with PhotoLine
Simon
Mitglied
Beiträge: 40
Registriert: Do 23 Jan 2014 21:35

How does the "Pixel shapping" work?

Beitrag von Simon »

Hi,

Do you know how the "Layer / Pixel snapping" or "Layout / Alignment / Align To Pixels" work?

From the manual:
controls whether the layer will be aligned to the pixel grid of the document
1. What is the "pixel grid of the document"?
2. Does it work with any type of layer?
3. What are the necessary steps to see its functionality?

In other programs* the "Force Pixel Alignment" is made to avoid decimals in pixels, ie. with this turned off you can made an square with x= 1.2, y=1.5, length= 2.3 and height = 2.1, with this turned on the square would be x=1, y=1, length= 2 and height = 2.

In PL I made this:
i) New Image
ii) Set [Layer / Pixel snapping / on] of the Background
iii) Create a vector square

The vector did not match to the pixels, its x and y axis as well as its height and length got decimals, I mean, they were not aligned to any pixel.
I also tried turning on the Pixel snapping option of the vector layer and clicking Layout / Alignment / Align To Pixels but nothing happens.

What am I doing wrong?

Thank you

*I do not mention what programs because I do not want to promote them, my intention is to know (helping others like me), how PL works.
Benutzeravatar
Herbert123
Mitglied
Beiträge: 2140
Registriert: Sa 12 Mai 2012 21:38

Re: How does the "Pixel shapping" work?

Beitrag von Herbert123 »

1) the pixel grid is the bitmap resolution of any given file open in PhotoLine. If the image is 320x200, then that is the pixel grid. If it is a 300ppi A4 document, the pixel grid will be 2480x3508 pixels.

2) It works with text layers and vector layers. Image layers are already bitmap/pixel based, so there is no visible effect IF and WHEN those image layers are displayed at 100% their native pixel dimensions. But if you scale an image up or down, it will have an effect depending on the settings. The rendering of transformed image layers will be affected by these settings.

3) This is an interplay between anti-aliasing on/off and pixel snapping on/off, as well as activating pixel view mode.

Before I continue this explanation, it is important to understand that PhotoLine's internal transformation system is decimal based. Even with pixel snapping turned on for one or more layers, or the entire document, the positioning will never snap to exact pixels. That is not how PhotoLine works (the same holds true for a number of other image editors out there. (Although it would be nice if PhotoLine actually would have this behaviour AS AN OPTION in my opinion - an option, because the current behaviour does have advantages).

What PhotoLine does in pixel snapping mode is rounding the transformation values to non-decimal values during the rendering. It will not snap the actual transformation /positioning to the pixel grid.

For example: (PS you MUST enter PIXEL MODE (view-->pixel mode) for this to work)
Draw a vector rectangle, yellow with black 1px outline. Turn anti-aliasing on for this layer, and pixel snapping off. Move it. Notice the smooth transition between decimal values and its effect on the overall anti-aliasing. This can be a boon, since it allows us to control how the rectangle's anti-aliasing is affecting the overall look of the edges via decimal positioning.

Now turn on pixel snapping. Keep anti-aliasing activated. Notice how the values are rounded to the nearest pixel. Even though anti-aliasing is turned on, the edges snap to exact pixels, and the rectangle's edges are rendered without anti-aliasing. (A rounded rectangle would still have anti-aliased corners, however). Rotate the rectangle and the anti-aliasing kicks in (as it should).

Now turn anti-aliasing off as well. Notice that no anti-aliasing is used at all, even when rotating the rectangle.

That's how it works in PhotoLine: it's an interplay of pixel view mode, anti-aliasing setting, and pixel snapping. Vector edges that run along the x or y axis will snap exactly to the pixel grid.

Text layers will also snap, and the anti-aliasing of text will be fixed no matter the position. With smaller text this may mean that letter distances might snap to a different pixel averaging, i.e.: kerning may vary based on position.

Placed image layers at 100% original pixel resolution remain unaffected by all these settings, but whenscaled and/or rotated, or distorted, or similar, the anti-aliasing setting will have an impact. Unfortunately, pixel snapping doesn't seem to affect these transformed images, which results in issues when pixel art, for example, is positioned to a decimal x and/or y position and anti-aliasing must be turned off: pixels will disappear in this case. Ideally images would always snap to pure non-decimal values when pixel snapping is turned on. The only viable solution in this last case is to manually adjust the x and y position to non-decimal ones.
/*---------------------------------------------*/
System: Win10 64bit - i7 920@3.6Ghz, p6t Deluxe v1, 48gb (6x8gb RipjawsX), Nvidia GTX1080 8GB, Revodrive X2 240gb, e-mu 1820, 2XSamsung SA850 (2560*1440) and 1XHP2408H 1920*1200 portrait
Simon
Mitglied
Beiträge: 40
Registriert: Do 23 Jan 2014 21:35

Re: How does the "Pixel shapping" work?

Beitrag von Simon »

Thank you very much for your explanation.

Now I can say this feature is not well implemented. the decimals when the Pixel Snapping is turned on are because the layer frame does not match with its image.

To reproduce the problem:
1. New image.
2. Create a 30px X 30px rectangle.
3. Turn Pixel Snapping on and Antialias.
4. Move the rectangle: In the layer tools panel you will see decimals in the position.
5. Apply a 1000% zoom.
6. Move the rectangle: You will see how the image is aligned to the pixels but not its layer frame, actually it never falls in a pixel border.
7. Turn Antialias off: You will see how the image moves to the layer frame position. By doing this the image is no longer aligned to a pixel border.
8. Click Align to Pixels: You will see how the layer frame moves to a pixel border, actually, it takes the place that its image had when Antialias was turned on, then, if you click Align to pixels when Antialias is on, the layer frame takes the place of its image.

If see two problems:
i) The layer frame does not match with its image when Antialias is turned on. as a result, the image gets moved to its frame when the Antialias is turned off. Solution: The layer frame and its image must share the same place always (in real time).
ii) The layer frame (with its image) is not aligned to pixels when the Antialias is turned off and Pixel Snapping on, as a result, the image is aligned to pixels when the Antialias is turned on but not its layer frame. Solution, The layer frame must be aligned to pixel borders when the Pixel Snapping is on.

As you can see both problems are solved when you click Align to pixels, but if you are drawing an icon or something that requires pixel precision, you need WYSIWYG, We are in the XXI Century!!! You should not be guessing where the layer will drop or how it will be exported. You can not click Align to pixels every time you change something. I think this behaviour is a heritage of the past (as well as the Fix Layer feature) but modern programs work in real time, not in batch. PL must solve this to survive, remember it does not compete with the leader but the newcomers.
Benutzeravatar
Herbert123
Mitglied
Beiträge: 2140
Registriert: Sa 12 Mai 2012 21:38

Re: How does the "Pixel shapping" work?

Beitrag von Herbert123 »

I agree that "Align To Pixels" ought to be implemented as a mode instead of an action. And this should be amended with an additional sub-option to move by exact pixels only.

Illustrator has these options, which I would like to see in PhotoLine at some point:
Pixel-snapping-options.png
As a work-around, in the meantime we can create a shortcut key for the Align to Pixels option to call it quickly.
Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.
/*---------------------------------------------*/
System: Win10 64bit - i7 920@3.6Ghz, p6t Deluxe v1, 48gb (6x8gb RipjawsX), Nvidia GTX1080 8GB, Revodrive X2 240gb, e-mu 1820, 2XSamsung SA850 (2560*1440) and 1XHP2408H 1920*1200 portrait
Simon
Mitglied
Beiträge: 40
Registriert: Do 23 Jan 2014 21:35

Re: How does the "Pixel shapping" work?

Beitrag von Simon »

As a work-around, in the meantime we can create a shortcut key for the Align to Pixels option to call it quickly
What I do (you know Pixel snapping does not work for me) is setting the grid to one pixel, turning snap to grid on and work in Pixel Mode.

However, I encourage PL team to fix the Pixel snapping functionality.
Martin Huber
Entwickler
Entwickler
Beiträge: 4159
Registriert: Di 19 Nov 2002 15:49

Re: How does the "Pixel shapping" work?

Beitrag von Martin Huber »

Simon hat geschrieben: Di 12 Feb 2019 06:00To reproduce the problem:
1. New image.
2. Create a 30px X 30px rectangle.
3. Turn Pixel Snapping on and Antialias.
4. Move the rectangle: In the layer tools panel you will see decimals in the position.
5. Apply a 1000% zoom.
6. Move the rectangle: You will see how the image is aligned to the pixels but not its layer frame, actually it never falls in a pixel border.
7. Turn Antialias off: You will see how the image moves to the layer frame position. By doing this the image is no longer aligned to a pixel border.
I don't understand this. "image" means the rectangle here? If you turn off antialiasing, a rectangle (in fact, any kind of layer) should always be aligned to pixels. And this isn't happening in your example?
Simon hat geschrieben: Di 12 Feb 2019 06:008. Click Align to Pixels: You will see how the layer frame moves to a pixel border, actually, it takes the place that its image had when Antialias was turned on, then, if you click Align to pixels when Antialias is on, the layer frame takes the place of its image.

If see two problems:
i) The layer frame does not match with its image when Antialias is turned on. as a result, the image gets moved to its frame when the Antialias is turned off. Solution: The layer frame and its image must share the same place always (in real time).
ii) The layer frame (with its image) is not aligned to pixels when the Antialias is turned off and Pixel Snapping on, as a result, the image is aligned to pixels when the Antialias is turned on but not its layer frame. Solution, The layer frame must be aligned to pixel borders when the Pixel Snapping is on.
I will fix that, so that the the visual representation of a pixel aligned vector layer doesn't differ in antialiased and aliased mode.
Simon hat geschrieben: Di 12 Feb 2019 06:00As you can see both problems are solved when you click Align to pixels, but if you are drawing an icon or something that requires pixel precision, you need WYSIWYG, We are in the XXI Century!!! You should not be guessing where the layer will drop or how it will be exported. You can not click Align to pixels every time you change something. I think this behaviour is a heritage of the past (as well as the Fix Layer feature) (...)
Pixel alignment being an attribute isn't any kind of heritage, but allows higher flexibility. This way the shape can dynamically be adjusted, if the stroke width changes. It is also more flexible on scaling a layer.
The command "Align to pixels" is intended for the rare cases, when you really need to fix the positions of vector points.

The same is true for "Fix Layer". Usually it is not needed, but there may be situations, that you want real pixels instead of dynamic effects.

Martin
Martin Huber
Entwickler
Entwickler
Beiträge: 4159
Registriert: Di 19 Nov 2002 15:49

Re: How does the "Pixel shapping" work?

Beitrag von Martin Huber »

Herbert123 hat geschrieben: Di 12 Feb 2019 08:22 I agree that "Align To Pixels" ought to be implemented as a mode instead of an action. And this should be amended with an additional sub-option to move by exact pixels only.

Illustrator has these options, which I would like to see in PhotoLine at some point:
I really would have preferred a comment like this a few years ago when we implemented pixel alignment.

Martin
Benutzeravatar
Herbert123
Mitglied
Beiträge: 2140
Registriert: Sa 12 Mai 2012 21:38

Re: How does the "Pixel shapping" work?

Beitrag von Herbert123 »

Martin Huber hat geschrieben: Do 21 Feb 2019 11:31
Herbert123 hat geschrieben: Di 12 Feb 2019 08:22 I agree that "Align To Pixels" ought to be implemented as a mode instead of an action. And this should be amended with an additional sub-option to move by exact pixels only.

Illustrator has these options, which I would like to see in PhotoLine at some point:
I really would have preferred a comment like this a few years ago when we implemented pixel alignment.

Martin
I recall suggesting that in pixel mode objects ought to snap (automatically) to non-decimal values when positioning back in 2014:
https://www.pl32.com/forum3/viewtopic.p ... 639#p32639
/*---------------------------------------------*/
System: Win10 64bit - i7 920@3.6Ghz, p6t Deluxe v1, 48gb (6x8gb RipjawsX), Nvidia GTX1080 8GB, Revodrive X2 240gb, e-mu 1820, 2XSamsung SA850 (2560*1440) and 1XHP2408H 1920*1200 portrait