Core Plot (iOS and tvOS)
Cocoa plotting framework for macOS, iOS, and tvOS
CPTImage Class Reference

A bitmap image. More...

#import <CPTImage.h>

+ Inheritance diagram for CPTImage:
+ Collaboration diagram for CPTImage:

Public Class Methods

Factory Methods
(nonnull instancetype) + imageNamed:
 Initializes a CPTImage instance with the named image. More...
 
(nonnull instancetype) + imageWithNativeImage:
 Initializes a CPTImage instance with the provided platform-native image. More...
 
(nonnull instancetype) + imageWithContentsOfFile:
 Initializes a CPTImage instance with the contents of a file. More...
 
(nonnull instancetype) + imageWithCGImage:scale:
 Creates and returns a new CPTImage instance initialized with the provided CGImageRef. More...
 
(nonnull instancetype) + imageWithCGImage:
 Creates and returns a new CPTImage instance initialized with the provided CGImageRef and scale 1.0. More...
 
(nonnull instancetype) + imageForPNGFile:
 Creates and returns a new CPTImage instance initialized with the contents of a PNG file. More...
 
- Public Class Methods inherited from NSObject
(id+ alloc
 
(Class+ class
 
(void) + initialize
 
(void) + load
 
(id+ new
 
- Public Class Methods inherited from <NSSecureCoding>
(BOOL+ supportsSecureCoding:
 

Public Instance Methods

Initialization
(nonnull instancetype) - initWithContentsOfFile:
 Initializes a CPTImage instance with the contents of a file. More...
 
(nonnull instancetype) - initWithCGImage:scale:
 Initializes a CPTImage instance with the provided CGImageRef. More...
 
(nonnull instancetype) - initWithCGImage:
 Initializes a CPTImage instance with the provided CGImageRef and scale 1.0. More...
 
(nullable instancetype) - initWithCoder:
 Returns an object initialized from data in a given unarchiver. More...
 
(nonnull instancetype) - init [implementation]
 Initializes a newly allocated CPTImage object with a NULL image. More...
 
(nonnull instancetype) - initWithNativeImage:
 Initializes a CPTImage instance with the provided platform-native image. More...
 
(nonnull instancetype) - initForPNGFile:
 Initializes a CPTImage instance with the contents of a PNG file. More...
 
Drawing
(void) - drawInRect:inContext:
 Draws the image into the given graphics context. More...
 
Comparison
(BOOL- isEqual: [implementation]
 Returns a boolean value that indicates whether the received is equal to the given object. Images are equal if they have the same scale, tiled, tileAnchoredToContext, image size, color space, bit depth, and image data. More...
 
- Public Instance Methods inherited from NSObject
(Class- classForCoder
 
(id- copy
 
(void) - dealloc
 
(void) - finalize
 
(id- init
 
(id- mutableCopy
 
- Public Instance Methods inherited from <NSObject>
(NSString *) - description
 
(NSUInteger- hash
 
(BOOL- isEqual:
 
- Public Instance Methods inherited from <NSCopying>
(id- copyWithZone:
 
- Public Instance Methods inherited from <NSCoding>
(id- initWithCoder:
 
(void) - encodeWithCoder:
 

Properties

CPTNativeImagenativeImage
 A platform-native representation of the image. More...
 
CGImageRef image
 The image drawn into a CGImageRef. More...
 
CGFloat scale
 The image scale. Must be greater than zero. More...
 
BOOL tiled
 Draw as a tiled image? More...
 
CPTEdgeInsets edgeInsets
 The edge insets for a stretchable image. More...
 
BOOL tileAnchoredToContext
 Anchor the tiled image to the context origin? More...
 
BOOL opaque
 If YES, the image is completely opaque. More...
 

Detailed Description

A bitmap image.

If initialized from a file or UIImage, and an @2x version of the image file is available, the image will be rendered correctly on Retina and non-Retina displays.

Method Documentation

◆ drawInRect:inContext:

- (void) drawInRect: (CGRect rect
inContext: (nonnull CGContextRef context 

Draws the image into the given graphics context.

If the tiled property is YES, the image is repeatedly drawn to fill the clipping region, otherwise the image is scaled to fit in rect.

Parameters
rectThe rectangle to draw into.
contextThe graphics context to draw into.

◆ imageForPNGFile:

+ (nonnull instancetype) imageForPNGFile: (nonnull NSString *)  path

Creates and returns a new CPTImage instance initialized with the contents of a PNG file.

On systems that support hi-dpi or “Retina” displays, this method will look for a double-resolution image with the given name followed by “@2x”. If the “@2x” image is not available, the named image file will be loaded.

Parameters
pathThe file system path of the file.
Returns
A new CPTImage instance initialized with the contents of the PNG file.

◆ imageNamed:

+ (nonnull instancetype) imageNamed: (nonnull NSString *)  name

Initializes a CPTImage instance with the named image.

Parameters
nameThe name of the image to load.
Returns
A new CPTImage instance initialized with the named image.

◆ imageWithCGImage:

+ (nonnull instancetype) imageWithCGImage: (nullable CGImageRef anImage

Creates and returns a new CPTImage instance initialized with the provided CGImageRef and scale 1.0.

Parameters
anImageThe image to wrap.
Returns
A new CPTImage instance initialized with the provided CGImageRef.

◆ imageWithCGImage:scale:

+ (nonnull instancetype) imageWithCGImage: (nullable CGImageRef anImage
scale: (CGFloat newScale 

Creates and returns a new CPTImage instance initialized with the provided CGImageRef.

Parameters
anImageThe image to wrap.
newScaleThe image scale.
Returns
A new CPTImage instance initialized with the provided CGImageRef.

◆ imageWithContentsOfFile:

+ (nonnull instancetype) imageWithContentsOfFile: (nonnull NSString *)  path

Initializes a CPTImage instance with the contents of a file.

Parameters
pathThe full or partial path to the image file.
Returns
A new CPTImage instance initialized from the file at the given path.

◆ imageWithNativeImage:

+ (nonnull instancetype) imageWithNativeImage: (nullable CPTNativeImage *)  anImage

Initializes a CPTImage instance with the provided platform-native image.

Parameters
anImageThe platform-native image.
Returns
A new CPTImage instance initialized with the provided image.

◆ init

- (nonnull instancetype) init
implementation

Initializes a newly allocated CPTImage object with a NULL image.

Returns
The initialized object.

◆ initForPNGFile:

- (nonnull instancetype) initForPNGFile: (nonnull NSString *)  path

Initializes a CPTImage instance with the contents of a PNG file.

On systems that support hi-dpi or “Retina” displays, this method will look for a double-resolution image with the given name followed by “@2x”. If the “@2x” image is not available, the named image file will be loaded.

Parameters
pathThe file system path of the file.
Returns
A CPTImage instance initialized with the contents of the PNG file.

Provided by category CPTImage(CPTPlatformSpecificImageExtensions).

◆ initWithCGImage:

- (nonnull instancetype) initWithCGImage: (nullable CGImageRef anImage

Initializes a CPTImage instance with the provided CGImageRef and scale 1.0.

Parameters
anImageThe image to wrap.
Returns
A CPTImage instance initialized with the provided CGImageRef.

◆ initWithCGImage:scale:

- (nonnull instancetype) initWithCGImage: (nullable CGImageRef anImage
scale: (CGFloat newScale 

Initializes a CPTImage instance with the provided CGImageRef.

This is the designated initializer.

Parameters
anImageThe image to wrap.
newScaleThe image scale. Must be greater than zero.
Returns
A CPTImage instance initialized with the provided CGImageRef.

◆ initWithCoder:

- (nullable instancetype) initWithCoder: (nonnull NSCoder *)  coder

Returns an object initialized from data in a given unarchiver.

Parameters
coderAn unarchiver object.
Returns
An object initialized from data in a given unarchiver.

◆ initWithContentsOfFile:

- (nonnull instancetype) initWithContentsOfFile: (nonnull NSString *)  path

Initializes a CPTImage instance with the contents of a file.

Parameters
pathThe full or partial path to the image file.
Returns
A CPTImage instance initialized from the file at the given path.

◆ initWithNativeImage:

- (nonnull instancetype) initWithNativeImage: (nullable CPTNativeImage *)  anImage

Initializes a CPTImage instance with the provided platform-native image.

Parameters
anImageThe platform-native image.
Returns
A CPTImage instance initialized with the provided image.

Provided by category CPTImage(CPTPlatformSpecificImageExtensions).

◆ isEqual:

- (BOOL) isEqual: (nullable id object
implementation

Returns a boolean value that indicates whether the received is equal to the given object. Images are equal if they have the same scale, tiled, tileAnchoredToContext, image size, color space, bit depth, and image data.

Parameters
objectThe object to be compared with the receiver.
Returns
YES if object is equal to the receiver, NO otherwise.

Property Documentation

◆ edgeInsets

- (CPTEdgeInsets) edgeInsets
readwritenonatomicassign

The edge insets for a stretchable image.

The edge insets define the end caps or regions that do not resize when stretching the image. The middle sections between the end caps are stretched or tiled (as determined by the tiled property) to fill the remaining space in the final image. The default value is CPTEdgeInsetsZero which allows the entire image to stretch or tile to fill the final image size.

◆ image

- (nullable CGImageRef) image
readwritenonatomicassign

The image drawn into a CGImageRef.

◆ nativeImage

- (nullable CPTNativeImage *) nativeImage
readwritenonatomiccopy

A platform-native representation of the image.

◆ opaque

- (BOOL) opaque
readnonatomicassign

If YES, the image is completely opaque.

◆ scale

- (CGFloat) scale
readwritenonatomicassign

The image scale. Must be greater than zero.

◆ tileAnchoredToContext

- (BOOL) tileAnchoredToContext
readwritenonatomicassign

Anchor the tiled image to the context origin?

If YES, the origin of the tiled image is anchored to the origin of the drawing context. If NO, the origin of the tiled image is set to the origin of the rectangle passed to -drawInRect:inContext: . The default value is YES. If tiled is NO, this property has no effect.

◆ tiled

- (BOOL) tiled
readwritenonatomicassign

Draw as a tiled image?

If YES, the image is drawn repeatedly to fill the current clip region. Otherwise, the image is drawn one time only in the provided rectangle. The default value is NO.


The documentation for this class was generated from the following files: