RRGarment

Objective-C

@interface RRGarment : NSObject

Swift

class RRGarment : NSObject

This object models a garment and all related metadata for virtual try-on. Further, it provides methodes for reading and writing garments from/to different sources as well as convenience methods. To display a garment a RRGarmentRenderable is required together with a RRGLRenderView.

  • Unused property. Can be used to store an URL to a highres image of the garment.

    Declaration

    Objective-C

    @property (nonatomic, strong) NSString *_Nullable highresColorURL;

    Swift

    var highresColorURL: String? { get set }
  • Returns whether the garment is in compressed form. If the garment is in compressed form the optical quality will be drastically reduced. The visual quality can be fully restored using the colorImage property: with the full resolution color image on a corresponding RRGarmentRenderable instance or by directly updating the RRGarment’s image using its updateColorImage: function.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL isCompressed;

    Swift

    var isCompressed: Bool { get }
  • Returns the compression type of the garment. The visual quality can be fully restored using the colorImage property: with the full resolution color image on a corresponding RRGarmentRenderable instance or by directly updating the RRGarment’s image using its updateColorImage: function.

    Declaration

    Objective-C

    @property (nonatomic, readonly) RRGarmentCompressionType compressionType;

    Swift

    var compressionType: RRGarmentCompressionType { get }
  • Returns YES if the garment together with an RRAvatar can be used to compute a tryon. This method, in contrast to RRGarmentType.isTryonable, also checks if all required (internal) data is present (instead of only checking whether or not the type of garment can be used for a tryon).

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL isTryonable;

    Swift

    var isTryonable: Bool { get }
  • Gets or sets the color image of the garment. The provided image must be a 4-channel (RGBA) image.

    Note

    This is useful if the garment is in compressed format (see isCompressed) and you want to update the image with a high-resolution version. Providing a different image (other than the same image in a different resolution) will break the garment.

    Declaration

    Objective-C

    @property (nonatomic, strong) RRImage *_Nonnull colorImage;

    Swift

    var colorImage: RRImage { get set }
  • Returns an instance of the RRGarmentType class containing meta information about the garment.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) RRGarmentType *_Nonnull garmentType;

    Swift

    var garmentType: RRGarmentType { get }
  • Returns the garment data packed into a single byte buffer.

    Declaration

    Objective-C

    - (NSData *_Nonnull)byteBufferWithCompressionType:
        (RRGarmentCompressionType)compressionType;

    Swift

    func byteBuffer(withCompressionType compressionType: RRGarmentCompressionType) -> Data

    Parameters

    compressionType

    Specifies the desired compression type of the garment

    Return Value

    The garment data in a single byte buffer

  • Creates a garment from a .garment file. The content of a .garment file is binary and is equivalent to the byte buffer encoding that is necessary to create a RRGarment instance using garmentFromByteBuffer:

    Declaration

    Objective-C

    + (RRGarment *_Nullable)garmentFromFile:(NSString *_Nonnull)path;

    Swift

    /*not inherited*/ init?(fromFile path: String)

    Parameters

    path

    Path to the garment file.

    Return Value

    An instance of the RRGarment class on success, nil otherwise.

  • Creates a garment from a byte buffer. This encoding is useful when transferring garments via binary data channels.

    Declaration

    Objective-C

    + (RRGarment *_Nullable)garmentFromByteBuffer:(NSData *_Nonnull)byteBuffer;

    Swift

    /*not inherited*/ init?(fromByteBuffer byteBuffer: Data)

    Parameters

    byteBuffer

    Garment data as byte buffer.

    Return Value

    An instance of the RRGarment class on success, nil otherwise.

  • Creates a thumbnail with the requested size and padding. The garment is fitted into the specified size without distorting the garment’s image. Increasing the padding means that the garment is displayed smaller (the padding is not added to the target size). This function is intended for rendering thumbnails of arbitrary size needed for GUI purposes.

    Declaration

    Objective-C

    - (RRImage *_Nullable)createThumbnail:(CGSize)size
                              withPadding:(unsigned int)padding
                         didFailWithError:(NSError *_Nullable *_Nullable)error;

    Swift

    func createThumbnail(_ size: CGSize, withPadding padding: UInt32) throws -> RRImage

    Parameters

    size

    Target size of the thumbnail in pixels.

    padding

    Padding around the garment in pixels.

    error

    An optional pointer to an NSError pointer. When this method fails, it will set an NSError instance to this pointer if provided.

    Return Value

    A thumbnail with the specified size and transparent background. This method returns nil if an error occurs.

  • The same as createThumbnail:withPadding but with an optional shadow behind the garment.

    See

    -[RRGarment createThumbnail:withPadding:]

    Declaration

    Objective-C

    - (RRImage *_Nullable)createThumbnail:(CGSize)size
                              withPadding:(unsigned int)padding
                                andShadow:(_Bool)shadow
                         didFailWithError:(NSError *_Nullable *_Nullable)error;

    Swift

    func createThumbnail(_ size: CGSize, withPadding padding: UInt32, andShadow shadow: Bool) throws -> RRImage

    Parameters

    size

    Target size of the thumbnail in pixels.

    padding

    Padding around the garment in pixels.

    shadow

    Adds a shadow if YES

    error

    An optional pointer to an NSError pointer. When this method fails, it will set an NSError instance to this pointer if provided.

    Return Value

    A thumbnail with the specified size and transparent background. This method returns nil if an error occurs.

  • Creates a thumbnail in the requested size directly from a garment’s byteBuffer without having to create a RRGarment object beforehand. The garment is fitted into the specified size without distorting the garment’s image. This function is intended for rendering thumbnails of arbitrary size needed for GUI purposes.

    Declaration

    Objective-C

    + (RRImage *_Nullable)thumbnailFromByteBuffer:(NSData *_Nonnull)byteBuffer
                                         withSize:(CGSize)size;

    Swift

    class func thumbnail(fromByteBuffer byteBuffer: Data, with size: CGSize) -> RRImage?

    Parameters

    byteBuffer

    Garment data byte buffer.

    size

    Target size of the thumbnail

    Return Value

    Thumbnail with the specified size on success, nil otherwise.