Import with #import "std/resample".

RESAMPLE_BOX :: 0
RESAMPLE_LANCZOS :: 1
RESAMPLE_BICUBIC :: 2
RESAMPLE_SCALAR :: 0
RESAMPLE_SSE2 :: 1
RESAMPLE_AVX2 :: 2
RESAMPLE_NEON :: 3
RESAMPLE_SIMD128 :: 4
ResampleAxis :: struct { input: s32; output: s32; size: s32; entry: s32; exact: bool; bounds: Vec(s32); weights: Vec(s32); packed: Vec(u32); scratch: Vec(float64); }

Weights from INPUT source positions to OUTPUT positions along one axis.

ResamplePlan :: struct { horizontal: ResampleAxis; vertical: ResampleAxis; source_width: s32; source_height: s32; width: s32; height: s32; horizontal_pass: bool; vertical_pass: bool; first_row: s32; rows: s32; intermediate: Vec(u8); }

Both passes of one resize and the rows between them.

ResampleKernels :: () -> s32

The fastest kernels this program and CPU have: RESAMPLE_AVX2, RESAMPLE_SSE2, RESAMPLE_NEON (AArch64, or ARMv7 with NEON), RESAMPLE_SIMD128 (a WebAssembly module built with -msimd128) or RESAMPLE_SCALAR. A build with ZIRAN_NO_ASM, a compiler without GNU assembly and .zx use the scalar ones.

ResampleUseKernels :: (level: s32) -> bool

For tests and benchmarks, before any rows run: use LEVEL's kernels from now on, or the fastest again for -1. False, changing nothing, when this CPU lacks them.

ResampleAxisBoxInto :: (axis: *ResampleAxis, input: s32, start: float64, end: float64, output: s32, filter: s32) -> bool

Pillow's weights for scaling the source span [START, END) of INPUT positions to OUTPUT positions, as Image.resize's box does; positions outside the source are left out and the rest renormalized. Reusing an axis reuses its storage. False leaves the axis empty.

ResampleAxisInto :: (axis: *ResampleAxis, input: s32, output: s32, filter: s32) -> bool

Pillow's weights for scaling all INPUT positions to OUTPUT positions.

ResampleRowHorizontal :: (axis: *ResampleAxis, source: *u8, target: *u8)

AXIS.output pixels of TARGET from AXIS.input pixels of SOURCE.

ResampleRowVertical :: (axis: *ResampleAxis, row: s32, source: *u8, stride: s64, width: s32, target: *u8)

Output row ROW of a vertical AXIS: WIDTH pixels of TARGET from the source rows at SOURCE, STRIDE bytes apart.

ResamplePremultiply :: (pixels: *u8, count: s64)

Pillow's premultiplication of COUNT RGBA pixels in place, and its inverse.

ResampleUnpremultiply :: (pixels: *u8, count: s64)
ResamplePlanInto :: (plan: *ResamplePlan, source_width: s32, source_height: s32, x: float64, y: float64, box_width: float64, box_height: float64, width: s32, height: s32, filter: s32) -> bool

Plans resizing the box (X, Y, BOX_WIDTH, BOX_HEIGHT) of a SOURCE_WIDTH by SOURCE_HEIGHT picture to WIDTH by HEIGHT, passes as Pillow chooses them. Reusing a plan reuses its storage. False leaves no pass to run.

ResamplePlanFirstRows :: (plan: *ResamplePlan) -> s32

Rows the first pass makes, then the second: ranges of these numbers can run on different threads, all first-pass rows before any second-pass row.

ResamplePlanSecondRows :: (plan: *ResamplePlan) -> s32
ResamplePlanFirst :: (plan: *ResamplePlan, source: *u8, stride: s64, target: *u8, target_stride: s64, first: s32, end: s32)

First-pass rows [FIRST, END) from premultiplied SOURCE (STRIDE bytes per row) into the plan, or into TARGET when there is no second pass.

ResamplePlanSecond :: (plan: *ResamplePlan, source: *u8, stride: s64, target: *u8, target_stride: s64, first: s32, end: s32)

Second-pass rows [FIRST, END) of TARGET (TARGET_STRIDE bytes per row).

ResamplePlanRun :: (plan: *ResamplePlan, source: *u8, stride: s64, target: *u8, target_stride: s64)

The whole resize on this thread: premultiplied SOURCE into TARGET.

Source ↗ · All modules