图像滤镜
图像滤镜是对构成图像的像素的所有颜色位进行操作的效果。
组合滤镜
颜色滤镜和着色器也可以用作图像滤镜。在下面的示例中,我们首先将颜色矩阵应用于内容,然后应用模糊图像滤镜。
tsx
import {Canvas ,Blur ,Image ,ColorMatrix ,useImage } from "@shopify/react-native-skia";constComposeImageFilter = () => {constimage =useImage (require ("./assets/oslo.jpg"));if (!image ) {return null;}return (<Canvas style ={{flex : 1 }}><Image x ={0}y ={0}width ={256}height ={256}image ={image }fit ="cover"><Blur blur ={2}mode ="clamp"><ColorMatrix matrix ={[-0.578, 0.99, 0.588, 0, 0, 0.469, 0.535, -0.003, 0, 0, 0.015,1.69, -0.703, 0, 0, 0, 0, 0, 1, 0,]}/></Blur ></Image ></Canvas >);};
tsx
import {Canvas ,Blur ,Image ,ColorMatrix ,useImage } from "@shopify/react-native-skia";constComposeImageFilter = () => {constimage =useImage (require ("./assets/oslo.jpg"));if (!image ) {return null;}return (<Canvas style ={{flex : 1 }}><Image x ={0}y ={0}width ={256}height ={256}image ={image }fit ="cover"><Blur blur ={2}mode ="clamp"><ColorMatrix matrix ={[-0.578, 0.99, 0.588, 0, 0, 0.469, 0.535, -0.003, 0, 0, 0.015,1.69, -0.703, 0, 0, 0, 0, 0, 1, 0,]}/></Blur ></Image ></Canvas >);};
