react-native-mask-segment-c.../dist/utils/compositePaintedImage.d.ts
a1518 acd6d3a73d feat: add MaskSegmentApp source code and config
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 00:27:28 -07:00

44 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type { BgrColor, SavePaintResult } from '../components/MaskSegmentCanvas.types';
import type { SkImage } from '@shopify/react-native-skia';
export type CompositePaintInput = {
originBuffer: Uint8Array;
cols: number;
rows: number;
pickBuffer: Uint8Array;
paintedRegions: Map<number, BgrColor>;
destDir?: string;
/**
* Preferred path for rich export: PNG base64 from makeImageSnapshot() — written
* directly to disk without an extra decode/re-encode round trip.
*/
exportPngBase64?: string;
/**
* Preferred path for rich export: if the caller (MaskSegmentCanvas) provides bytes
* that were produced by makeImageSnapshot() on a high-resolution Canvas rendering the
* exact same PaintShaderLayer + regionPaint SkSL at work resolution, we write them
* directly. This captures the live editor 质感 (lighting + high/low-freq texture)
* without CPU pixel math and without a second declarative drawAsImage.
*/
exportPngBytes?: Uint8Array;
/**
* Fallback rich path (when no pre-captured snapshot bytes): pass the live textures
* so we can try renderPaintedImageOffscreen (drawAsImage with the shader tree).
*/
shaderTextures?: {
originImage: SkImage;
paintColorMap: SkImage;
lowFreqImage: SkImage;
highFreqImage: SkImage;
};
/** The logical size at which to render the shader tree for export (typically the work image res). */
renderWidth?: number;
renderHeight?: number;
};
/** 将上色区域导出为 recolored PNG。
* 优先级(从好到保底):
* 1. exportPngBytes调用方用 makeImageSnapshot 在高分辨率 Canvas 上捕获的完整 shader 结果)—— 推荐的“保存快照”路径,无 CPU 逐像素,无二次 drawAsImage。
* 2. shaderTextures + render*(通过 renderPaintedImageOffscreen / drawAsImage 重建同一套 PaintShaderLayer + SkSL
* 3. CPU 逐像素 recolorflat无光照/纹理,仅作最后兜底,保证保存不中断)。
*/
export declare function compositePaintedImage(input: CompositePaintInput): Promise<SavePaintResult>;
//# sourceMappingURL=compositePaintedImage.d.ts.map