Pixmap
public final class Pixmap
Undocumented
-
Creates
Pixmapfrom info width, height,AlphaType, andColorType. addr points to pixels, ornil. This computes the bytes per row from theinfoparameter.No parameter checking is performed; it is up to the caller to ensure that
addrandrowBytesagree withinfo.The memory lifetime of pixels is managed by the caller. When
Pixmapgoes out of scope,addris unaffected.Pixmapmay be later modified byreset()to change its size, pixel type, or storage.Declaration
Swift
public init(info: ImageInfo, addr: UnsafeMutableRawPointer)Parameters
infoaddrpointer to pixels allocated by caller; may be
nilReturn Value
initialized
Pixmap -
Creates
Pixmapfrom info width, height,AlphaType, andColorType.addrpoints to pixels, ornil.rowBytesshould beinfo.widthtimesinfo.bytesPerPixel, or larger. No parameter checking is performed; it is up to the caller to ensure thataddrandrowBytesagree withinfo. The memory lifetime of pixels is managed by the caller. WhenPixmapgoes out of scope, addr is unaffected.Pixmapmay be later modified byreset()to change its size, pixel type, or storage.Declaration
Swift
public init(info: ImageInfo, addr: UnsafeMutableRawPointer, rowBytes: Int)Parameters
infoaddrpointer to pixels allocated by caller; may be
nilrowBytessize of one row of addr; width times pixel size, or larger
Return Value
initialized
Pixmap -
Sets width, height,
AlphaType, andColorTypefrominfo. Sets pixel address fromaddr, which may benil. Sets row bytes fromrowBytes, which should beinfo.widthtimesinfo.bytesPerPixel, or larger. Does not checkaddr. Asserts if built with SK_DEBUG defined and ifrowBytesis too small to hold one row of pixels. The memory lifetime pixels are managed by the caller. WhenPixmapgoes out of scope,addris unaffected.Declaration
Swift
public func reset(info: ImageInfo, addr: UnsafeMutableRawPointer, rowBytes: Int)Parameters
infoaddrpointer to pixels allocated by caller; may be
nilrowBytessize of one row of
addr; width times pixel size, or larger -
Returns width, height,
AlphaType,ColorType, andColorSpace.Declaration
Swift
public var info: ImageInfo { get } -
Returns pixel count in each pixel row. Should be equal or less than:
rowBytes/info.bytesPerPixelDeclaration
Swift
public var width: Int32 { get } -
Returns pixel row count.
Declaration
Swift
public var height: Int32 { get } -
Return the dimensions of the pixmap (from its ImageInfo)
Declaration
Swift
public var rect: IRect { get } -
Returns the ColorType for this pixmap
Declaration
Swift
public var colorType: ColorType { get } -
Returns the AlphaType for this pixmap
Declaration
Swift
public var alphaType: AlphaType { get } -
Returns SkColorSpace, the range of colors, associated with ImageInfo. The reference count of SkColorSpace is unchanged. The returned SkColorSpace is immutable.
Declaration
Swift
public var colorSpace: ColorSpace? { get } -
Returns true if SkAlphaType is kOpaque_SkAlphaType. Does not check if SkColorType allows alpha, or if any pixel value has transparency.
Declaration
Swift
public var isOpaque: Bool { get } -
Returns pixel address, the base address corresponding to the pixel origin.
Declaration
Swift
public var pixels: UnsafeMutableRawPointer { get } -
Undocumented
Declaration
Swift
public func getPixels(x: Int32, y: Int32) -> UnsafeRawPointer -
Undocumented
Declaration
Swift
public func getPixel(x: Int32, y: Int32) -> Color -
Undocumented
Declaration
Swift
public func scalePixels(destination: Pixmap, quality: FilterQuality) -
Copies a rectangle of pixels to
dstPixels. Copy starts at (srcX,srcY), and does not exceedPixmap(width, height).dstInfospecifies width, height,ColorType,AlphaType, andColorSpaceof destination. dstRowBytes specifics the gap from one destination row to the next. Returnstrueif pixels are copied. ReturnsfalseifdstInfoaddress equalsnil, ordstRowBytesis less thandstInfo.minRowBytes(Pixels are copied only if pixel conversion is possible. If
PixmapcolorTypeis.gray8, or.alpha8;dstInfo.colorTypemust match. IfPixmapcolorTypeis.gray8,dstInfo.colorSpacemust match. IfPixmapalphaTypeis.opaque,dstInfo.alphaTypemust match. IfPixmapcolorSpaceisnil,dstInfo.colorSpacemust match.srcXandsrcYmay be negative to copy only top or left of source. Returns false ifPixmapwidthorheightis zero or negative.Declaration
Swift
public func readPixels(dstInfo: ImageInfo, dstPixels: UnsafeMutableRawPointer, dstRowBytes: Int, srcX: Int32 = 0, srcY: Int32 = 0, behavior: TransferFunctionBehavior = .respect) -> BoolParameters
dstInfodestination width, height,
ColorType,AlphaType,ColorSpacedstPixelsdestination pixel storage
dstRowBytesdestination row length
srcXcolumn index whose absolute value is less than width()
srcYrow index whose absolute value is less than height()
Return Value
true if pixels are copied to dstPixels, or
falseif the pixel convesion is not possible, or if width/height is zero or negative, or abs(srcX) >= Pixmap width(), or if abs(srcY) >= Pixmap height(). -
Copies a rectangle of pixels to dst. Copy starts at
(srcX, srcY), and does not exceedPixmap(width, height).dstspecifies width, height,ColorType,AlphaType, andColorSpaceof destination. Returns true if pixels are copied. Returns false if dst address equalsnil, ordst.rowBytesis less than dstImageInfo.minRowBytes. Pixels are copied only if pixel conversion is possible. IfPixmapcolorTypeis.gray8, or.alpha8;dstInfo.colorTypemust match. IfPixmapcolorTypeis.gray8,dstInfo.colorSpacemust match. IfPixmapalphaTypeis.opaque,dstInfo.alphaTypemust match. IfPixmapcolorSpaceisnil,dstInfo.colorSpacemust match.srcXandsrcYmay be negative to copy only top or left of source. Returns false ifPixmapwidthorheightis zero or negative.Declaration
Swift
public func readPixels(into: Pixmap, srcX: Int32 = 0, srcY: Int32 = 0) -> BoolParameters
dstImageInfoand pixel address to write tosrcXcolumn index whose absolute value is less than width()
srcYrow index whose absolute value is less than height()
Return Value
true if pixels are copied to dst, or
falseif the pixel convesion is not possible, or if width/height is zero or negative, or abs(srcX) >= Pixmap width(), or if abs(srcY) >= Pixmap height(). -
Encodes the bitmap using the specified format.
Declaration
Swift
public static func encode(dest: SKWStream, src: Bitmap, encoder: EncodedImageFormat, quality: Int32) -> BoolParameters
destthe stream to write the encoded bitmap into
srcthe source bitmap to encode
encoderthe format to use to encode the bitmap
Return Value
true on success, false on failure
-
Encodes the pixmap using the specified format.
Declaration
Swift
public static func encode(dest: SKWStream, src: Pixmap, encoder: EncodedImageFormat, quality: Int32) -> BoolParameters
destthe stream to write the encoded pixmap into
srcthe source pixmap to encode
encoderthe format to use to encode the pixmap
Return Value
true on success, false on failure
-
Encodes the pixmap using the specified format.
Declaration
Swift
public func encode(encoder: EncodedImageFormat, quality: Int32) -> SKData?Parameters
encoderthe format to use to encode the pixmap
Return Value
nil on error, or Data containing the image in the specified format with the specified quality on success
-
Undocumented
Declaration
Swift
public func extract(subset: IRect) -> Pixmap? -
Undocumented
Declaration
Swift
public func extract(into: Pixmap, subset: IRect) -> Bool -
Undocumented
Declaration
Swift
public func erase(_ color: Color) -
Undocumented
-
Undocumented
Declaration
Swift
public func withColorType(_ colorType: ColorType) -> Pixmap -
Undocumented
Declaration
Swift
public func withColorSpace(_ colorSpace: ColorSpace) -> Pixmap -
Undocumented
Declaration
Swift
public func withAlphaType(_ alphaType: AlphaType) -> Pixmap
View on GitHub
Install in Dash
Pixmap Class Reference