Pixmap
public final class Pixmap
Undocumented
-
Creates
Pixmap
from info width, height,AlphaType
, andColorType
. addr points to pixels, ornil
. This computes the bytes per row from theinfo
parameter.No parameter checking is performed; it is up to the caller to ensure that
addr
androwBytes
agree withinfo
.The memory lifetime of pixels is managed by the caller. When
Pixmap
goes out of scope,addr
is unaffected.Pixmap
may be later modified byreset()
to change its size, pixel type, or storage.Declaration
Swift
public init(info: ImageInfo, addr: UnsafeMutableRawPointer)
Parameters
info
addr
pointer to pixels allocated by caller; may be
nil
Return Value
initialized
Pixmap
-
Creates
Pixmap
from info width, height,AlphaType
, andColorType
.addr
points to pixels, ornil
.rowBytes
should beinfo.width
timesinfo.bytesPerPixel
, or larger. No parameter checking is performed; it is up to the caller to ensure thataddr
androwBytes
agree withinfo
. The memory lifetime of pixels is managed by the caller. WhenPixmap
goes out of scope, addr is unaffected.Pixmap
may be later modified byreset()
to change its size, pixel type, or storage.Declaration
Swift
public init(info: ImageInfo, addr: UnsafeMutableRawPointer, rowBytes: Int)
Parameters
info
addr
pointer to pixels allocated by caller; may be
nil
rowBytes
size of one row of addr; width times pixel size, or larger
Return Value
initialized
Pixmap
-
Sets width, height,
AlphaType
, andColorType
frominfo
. Sets pixel address fromaddr
, which may benil
. Sets row bytes fromrowBytes
, which should beinfo.width
timesinfo.bytesPerPixel
, or larger. Does not checkaddr
. Asserts if built with SK_DEBUG defined and ifrowBytes
is too small to hold one row of pixels. The memory lifetime pixels are managed by the caller. WhenPixmap
goes out of scope,addr
is unaffected.Declaration
Swift
public func reset(info: ImageInfo, addr: UnsafeMutableRawPointer, rowBytes: Int)
Parameters
info
addr
pointer to pixels allocated by caller; may be
nil
rowBytes
size 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.bytesPerPixel
Declaration
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)
.dstInfo
specifies width, height,ColorType
,AlphaType
, andColorSpace
of destination. dstRowBytes specifics the gap from one destination row to the next. Returnstrue
if pixels are copied. Returnsfalse
ifdstInfo
address equalsnil
, ordstRowBytes
is less thandstInfo.minRowBytes(
Pixels are copied only if pixel conversion is possible. If
Pixmap
colorType
is.gray8
, or.alpha8
;dstInfo.colorType
must match. IfPixmap
colorType
is.gray8
,dstInfo.colorSpace
must match. IfPixmap
alphaType
is.opaque
,dstInfo.alphaType
must match. IfPixmap
colorSpace
isnil
,dstInfo.colorSpace
must match.srcX
andsrcY
may be negative to copy only top or left of source. Returns false ifPixmap
width
orheight
is zero or negative.Declaration
Swift
public func readPixels(dstInfo: ImageInfo, dstPixels: UnsafeMutableRawPointer, dstRowBytes: Int, srcX: Int32 = 0, srcY: Int32 = 0, behavior: TransferFunctionBehavior = .respect) -> Bool
Parameters
dstInfo
destination width, height,
ColorType
,AlphaType
,ColorSpace
dstPixels
destination pixel storage
dstRowBytes
destination row length
srcX
column index whose absolute value is less than width()
srcY
row index whose absolute value is less than height()
Return Value
true if pixels are copied to dstPixels, or
false
if 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)
.dst
specifies width, height,ColorType
,AlphaType
, andColorSpace
of destination. Returns true if pixels are copied. Returns false if dst address equalsnil
, ordst.rowBytes
is less than dstImageInfo.minRowBytes
. Pixels are copied only if pixel conversion is possible. IfPixmap
colorType
is.gray8
, or.alpha8
;dstInfo.colorType
must match. IfPixmap
colorType
is.gray8
,dstInfo.colorSpace
must match. IfPixmap
alphaType
is.opaque
,dstInfo.alphaType
must match. IfPixmap
colorSpace
isnil
,dstInfo.colorSpace
must match.srcX
andsrcY
may be negative to copy only top or left of source. Returns false ifPixmap
width
orheight
is zero or negative.Declaration
Swift
public func readPixels(into: Pixmap, srcX: Int32 = 0, srcY: Int32 = 0) -> Bool
Parameters
dst
ImageInfo
and pixel address to write tosrcX
column index whose absolute value is less than width()
srcY
row index whose absolute value is less than height()
Return Value
true if pixels are copied to dst, or
false
if 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) -> Bool
Parameters
dest
the stream to write the encoded bitmap into
src
the source bitmap to encode
encoder
the 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) -> Bool
Parameters
dest
the stream to write the encoded pixmap into
src
the source pixmap to encode
encoder
the 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
encoder
the 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