@@ -1232,22 +1232,27 @@ export interface Canvas extends EmbindObject<Canvas> {
12321232 markCTM ( marker : string ) : void ;
12331233
12341234 /**
1235- * Copies the given rectangle of pixels into a new Uint8Array and returns it. If alphaType,
1236- * colorType, and colorSpace are provided, those will describe the output format.
1237- * @param x
1238- * @param y
1239- * @param w
1240- * @param h
1241- * @param alphaType - defaults to Unpremul
1242- * @param colorType - defaults to RGBA_8888
1243- * @param colorSpace - defaults to SRGB
1244- * @param dest - If provided, the pixels will be copied into the allocated buffer allowing access to the
1245- * pixels without allocating a new TypedArray.
1246- * @param dstRowBytes
1235+ * Returns a TypedArray containing the pixels reading starting at (srcX, srcY) and does not
1236+ * exceed the size indicated by imageInfo. See SkCanvas.h for more on the caveats.
1237+ *
1238+ * If dest is not provided, we allocate memory equal to the provided height * the provided
1239+ * bytesPerRow to fill the data with.
1240+ *
1241+ * This is generally a very expensive call for the GPU backend.
1242+ *
1243+ * @param srcX
1244+ * @param srcY
1245+ * @param imageInfo - describes the destination format of the pixels.
1246+ * @param dest - If provided, the pixels will be copied into the allocated buffer allowing
1247+ * access to the pixels without allocating a new TypedArray.
1248+ * @param bytesPerRow - number of bytes per row. Must be provided if dest is set. This
1249+ * depends on destination ColorType. For example, it must be at least 4 * width for
1250+ * the 8888 color type.
1251+ * @returns a TypedArray appropriate for the specified ColorType. Note that 16 bit floats are
1252+ * not supported in JS, so that colorType corresponds to raw bytes Uint8Array.
12471253 */
1248- readPixels ( x : number , y : number , w : number , h : number , alphaType ?: AlphaType ,
1249- colorType ?: ColorType , colorSpace ?: ColorSpace , dstRowBytes ?: number ,
1250- dest ?: MallocObj ) : Uint8Array ;
1254+ readPixels ( srcX : number , srcY : number , imageInfo : ImageInfo , dest ?: MallocObj ,
1255+ bytesPerRow ?: number ) : Uint8Array | Float32Array | null ;
12511256
12521257 /**
12531258 * Removes changes to the current matrix and clip since Canvas state was
@@ -1564,18 +1569,24 @@ export interface Image extends EmbindObject<Image> {
15641569
15651570 /**
15661571 * Returns a TypedArray containing the pixels reading starting at (srcX, srcY) and does not
1567- * exceed the size indicated by imageInfo. See Image.h for more on the caveats.
1572+ * exceed the size indicated by imageInfo. See SkImage.h for more on the caveats.
1573+ *
1574+ * If dest is not provided, we allocate memory equal to the provided height * the provided
1575+ * bytesPerRow to fill the data with.
15681576 *
1569- * @param imageInfo - describes the destination format of the pixels.
15701577 * @param srcX
15711578 * @param srcY
1572- * @param dest - If provided, the pixels will be copied into the allocated buffer allowing access to the
1573- * pixels without allocating a new TypedArray.
1574- * @returns a Uint8Array if RGB_8888 was requested, Float32Array if RGBA_F32 was requested. null will be returned
1575- * on any error.
1576- *
1577- */
1578- readPixels ( imageInfo : ImageInfo , srcX : number , srcY : number , dest ?: MallocObj ) : Uint8Array | Float32Array | null ;
1579+ * @param imageInfo - describes the destination format of the pixels.
1580+ * @param dest - If provided, the pixels will be copied into the allocated buffer allowing
1581+ * access to the pixels without allocating a new TypedArray.
1582+ * @param bytesPerRow - number of bytes per row. Must be provided if dest is set. This
1583+ * depends on destination ColorType. For example, it must be at least 4 * width for
1584+ * the 8888 color type.
1585+ * @returns a TypedArray appropriate for the specified ColorType. Note that 16 bit floats are
1586+ * not supported in JS, so that colorType corresponds to raw bytes Uint8Array.
1587+ */
1588+ readPixels ( srcX : number , srcY : number , imageInfo : ImageInfo , dest ?: MallocObj ,
1589+ bytesPerRow ?: number ) : Uint8Array | Float32Array | null ;
15791590
15801591 /**
15811592 * Return the width in pixels of the image.
0 commit comments