MPSImageScale(3) MetalPerformanceShaders.framework MPSImageScale(3)
NAME
MPSImageScale
SYNOPSIS
#import <MPSImageResampling.h>
Inherits MPSUnaryImageKernel.
Inherited by MPSImageBilinearScale, and MPSImageLanczosScale.
Instance Methods
(nonnull instancetype) - initWithDevice:
(nullable instancetype) - initWithCoder:device:
Properties
const MPSScaleTransform * scaleTransform
Additional Inherited Members
Detailed Description
MPSImageResampling.h MetalPerformanceShaders
Copyright:
Copyright (c) 2015 Apple Inc. All rights reserved. Resampling
filters for MetalPerformanceShaders
Resize an image and / or change its aspect ratio The MPSImageScale
filter can be used to resample an existing image using a different
sampling frequency in each dimension. This can be used to enlarge or
reduce the size of an image, or change the aspect ratio of an image.
The resample methods supported are: Bilinear Bicubcic Lanczos
Method Documentation
- (nullable instancetype) initWithCoder: (NSCoder *__nonnull)
aDecoder(nonnull id< MTLDevice >) device
NSSecureCoding compatability While the standard
NSSecureCoding/NSCoding method -initWithCoder: should work, since the
file can't know which device your data is allocated on, we have to
guess and may guess incorrectly. To avoid that problem, use
initWithCoder:device instead.
Parameters:
aDecoder The NSCoder subclass with your serialized MPSKernel
device The MTLDevice on which to make the MPSKernel
Returns:
A new MPSKernel object, or nil if failure.
Reimplemented from MPSUnaryImageKernel.
Reimplemented in MPSImageLanczosScale, and MPSImageBilinearScale.
- (nonnull instancetype) initWithDevice: (nonnull id< MTLDevice >) device
Standard init with default properties per filter type
Parameters:
device The device that the filter will be used on. May not be NULL.
Returns:
a pointer to the newly initialized object. This will fail,
returning nil if the device is not supported. Devices must be
MTLFeatureSet_iOS_GPUFamily2_v1 or later.
Reimplemented from MPSUnaryImageKernel.
Reimplemented in MPSImageLanczosScale, and MPSImageBilinearScale.
Property Documentation
- scaleTransform [read], [write], [nonatomic], [assign]
An optional transform that describes how to scale and translate the
source image If the scaleTransform is NULL, then the
MPSImageLanczosScale filter will rescale the image so that the source
image fits exactly into the destination texture. If the transform is
not NULL, then the transform is used for determining how to map the
source image to the destination. Default: NULL
When the scaleTransform is set to non-NULL, the values pointed to by
the new scaleTransform are copied to object storage, and the pointer is
updated to point to internal storage. Do not attempt to free it. You
may free your copy of the MPSScaleTransform as soon as the property set
operation is complete.
When calculating a scaleTransform, use the limits of the bounding box
for the intended source region of interest and the destination
clipRect. Adjustments for pixel center coordinates are handled
internally to the function. For example, the scale transform to convert
the entire source image to the entire destination image size (clipRect
= MPSRectNoClip) would be:
scaleTransform.scaleX = (double) dest.width / source.width;
scaleTransform.scaleY = (double) dest.height / source.height;
scaleTransform.translateX = scaleTransform.translateY = 0.0;
The translation parameters allow you to adjust the region of the source
image used to create the destination image. They are in destination
coordinates. To place the top left corner of the destination clipRect
to represent the position {x,y} in source coordinates, we solve for the
translation based on the standard scale matrix operation for each axis:
dest_position = source_position * scale + translation;
translation = dest_position - source_position * scale;
For the top left corner of the clipRect, the dest_position is
considered to be {0,0}. This gives us a translation of:
scaleTransform.translateX = -source_origin.x * scaleTransform.scaleX;
scaleTransform.translateY = -source_origin.y * scaleTransform.scaleY;
One would typically use non-zero translations to do tiling, or provide
a resized view into a internal segment of an image.
Changing the Lanczos scale factor may trigger recalculation of
signficant state internal to the object when the filter is encoded to
the command buffer. The scale factor is scaleTransform->scaleX,Y, or
the ratio of source and destination image sizes if scaleTransform is
NULL. Reuse a MPSImageLanczosScale object for frequently used scalings
to avoid redundantly recreating expensive resampling state.
Author
Generated automatically by Doxygen for
MetalPerformanceShaders.framework from the source code.
Version MetalPerformanceShaders-Thu2Jul 13 2017 MPSImageScale(3)
Mac OS X 10.12.6 - Generated Mon Oct 30 18:14:24 CDT 2017