将灰度值转换为RGB表示形式? [英] Convert grayscale value to RGB representation?

查看:1787
本文介绍了将灰度值转换为RGB表示形式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将灰度值(0-255)转换为RGB值/表示形式?
它是用于在一个SVG图像,似乎没有灰度支持,只有RGB ...

How can I convert a grayscale value (0-255) to an RGB value/representation? It is for using in an SVG image, which doesn't seem to come with a grayscale support, only RGB...

注意:这不是RGB - >灰度,这已经在另一个问题中回答,例如将RGB转换为灰度/强度

Note: this is not RGB -> grayscale, which is already answered in another question, e.g. Converting RGB to grayscale/intensity)

推荐答案

快速和肮脏的方法是重复RGB的每个分量的灰度强度。所以,如果你有灰度120,它转换为RGB(120,120,120)。

The quick and dirty approach is to repeat the grayscale intensity for each component of RGB. So, if you have grayscale 120, it translates to RGB (120, 120, 120).

这是快速和脏,因为你获得的有效亮度取决于实际您使用的设备的R,G和B子像素的亮度。

This is quick and dirty because the effective luminance you get depends on the actual luminance of the R, G and B subpixels of the device that you're using.

这篇关于将灰度值转换为RGB表示形式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆