Scaling

Scaling/Fit Modes

Each scaling modes has unique behavior for different window-size to pixmap-size ratios.

Unfortunately, there are no universally applicable naming conventions for these modes. In fact, different implementations tend to contradict each other.
Mode feature matrix
ModeAspect RatioPixel RatioCroppingBorderComment(s)
nonepreservedpreservedyes4Crops if the window.size < pixmap.size.
stretchnonononone
containpreservednono2Letterboxing/Pillarboxing
integerpreservedpreservedno4Works only if window.size >= pixmap.size.
intHybridpreservedwhen upno4 or 2Hybrid: int upscaling, decimal downscaling
coverpreservednoyesnone
Integer scaling – Note that the resulting integer ratio of a window smaller than a pixmap is 0.

Use intHybrid to prevent the pixmap from disappearing on disproportionately small window sizes. It uses integer-mode for upscaling and the regular contain-mode for downscaling.

FeatureDefinition
Aspect RatioWhether the original aspect ratio (width ÷ height) of the input frame is preserved
Pixel RatioWhether the orignal pixel ratio (= square) is preserved
CroppingWhether the outer areas of the input frame might get cut off
BorderThe number of padding-areas/borders that can potentially appear around the frame

For your convience, aliases matching the `object-fit` CSS property are provided, too. These are prefixed with css. Currently there is no equivalent for scale-down as it does not appear to be particularly useful here.

Values

ValueMeaning
none0
stretch
contain
integer
intHybrid
cover
centernone
keepAspectRatiocontain
cssNonenone

equivalent CSS: object-fit: none;

cssContaincontain

equivalent CSS: object-fit: contain;

cssFillstretch

equivalent CSS: object-fit: fill;

cssCovercover

equivalent CSS: object-fit: cover;

Meta