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

查看:47
本文介绍了将灰度值转换为 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天全站免登陆