gpt4 book ai didi

react-native - react native : How do I programmatically make images black-and-white-filtered?

转载 作者:行者123 更新时间:2023-12-05 04:19:30 27 4
gpt4 key购买 nike

有什么方法可以在 React Native 中以编程方式对图像进行黑白过滤?我有一些带有白色背景和彩色字母的图像。我希望这些字母都是黑色的,这样它们很容易脱颖而出。

最佳答案

你好@Jinwook Kim,

您需要 style 属性来对图像应用灰度滤镜。以下是如何执行此操作的示例:

import React from 'react';
import { Image, StyleSheet } from 'react-native';
const styles = StyleSheet.create({
image: {
filter: 'grayscale(100%)', // You can adjust the intensity of the grayscale accoding. value of 0% will produce a normal images.
},
});

the grayscale(100%) filter in the Image component, which will make black and white.

const MyImage = () => {
return (
<Image
source={require('./my-image.png')}
style={styles.image}
/>
);
};

export default MyImage;

关于react-native - react native : How do I programmatically make images black-and-white-filtered?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74794521/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com