Best way to represent a color in a SQL Database?

前端 未结 6 1201
情歌与酒
情歌与酒 2021-01-12 04:14

If I am using .Net and SQL Server 2008, what is the best way for me to store a color in the database, should I use ToString or convert it to an integer, or something else?

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-12 04:25

    Color can be surprisingly tricky on some industries like digital cameras, desktop publishing, sanners and other. Most programmers associate color with the 24 bit color (RGB usually), some associate it with the 32 bit (RGBA). The few that work in industries like DTP that make heavy use of color have a richer set of terms that includes color correction, color space and so on and so forth. So what exactly do you need to store?

    • Do you need to store a single format that is not going to change?
    • Do you need to store multiple formats and know what format is actually stored (RGB vs. RGBA vs. CMY vs. HSV etv) ? Note that even something apparently as simple as RGB actually can be Adobe RGB or sRGB.
    • Do you need to store color space and correction? Note often the RGB color has no meaning w/o proper color management.
    • Do you need to store a simple text description ('red', 'lime', 'teal' etc) ?
    • Do you need to store the 'web' color (ie. RGB or RGBA as hex) ?

提交回复
热议问题