⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rgb_4bit.c

📁 Graphics Gems 源码 a collection of algorithms, programs, and mathematical techniques for the computer
💻 C
字号:
/*Mapping RGB Triples onto Four Bitsby Alan Paethfrom "Graphics Gems", Academic Press, 1990*/remap8(R, G, B, R2, G2, B2)    float R, G, B, *R2, *G2, *B2;    {/* * remap8 maps floating (R,G,B) triples onto quantized * (R2,B2,B2) triples and returns the code (vertex) * value/color table entry for the quantization. The * points (eight) are the vertices of the cube. */    int code;    *R2 = *G2 = *B2 = 0.0;    code = 0;    if (R >= 0.5) { *R2 = 1.0; code |= 1; }    if (G >= 0.5) { *G2 = 1.0; code |= 2; }    if (B >= 0.5) { *B2 = 1.0; code |= 4; }    return(code);    }/* * remap14 maps floating (R,G,B) triples onto quantized * (R2,B2,B2) triples and returns the code (vertex) * value/color table entry for the quantization. The * points (fourteen) are the vertices of the cuboctahedron. */float rval[] = { 0.,.5 ,.5 , 1.,.0 , 0., 0.,.5,                .5 , 1., 1., 1., 0.,.5 ,.5 , 1.};float gval[] = { 0.,.5 , 0., 0.,.5 , 1., 0.,.5,                .5 , 1., 0.,.5 , 1., 1.,.5 , 1.};float bval[] = { 0., 0.,.5 , 0.,.5 , 0., 1.,.5,                .5 , 0., 1.,.5 , 1.,.5 , 1., 1.};int remap14(R, G, B,  R2, G2, B2)    float R, G, B, *R2, *G2, *B2;    {    int code = 0;    if ( R + G + B > 1.5) code |= 8;    if (-R + G + B > 0.5) code |= 4;    if ( R - G + B > 0.5) code |= 2;    if ( R + G - B > 0.5) code |= 1;    *R2 = rval[code];    *G2 = gval[code];    *B2 = bval[code];    return(code);    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -