本文整理匯總了C++中BLUE函數的典型用法代碼示例。如果您正苦於以下問題:C++ BLUE函數的具體用法?C++ BLUE怎麽用?C++ BLUE使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了BLUE函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: compose_over
pixel_t compose_over(pixel_t fg, pixel_t bg)
{
double mul;
double mul_cmp;
double res_a;
double res_r;
double res_g;
double res_b;
if (ALPHA(bg) == 255) {
res_a = 1;
mul = ((double) ALPHA(fg)) / 255.0;
mul_cmp = 1 - mul;
} else {
double fg_a = ((double) ALPHA(fg)) / 255.0;
double bg_a = ((double) ALPHA(bg)) / 255.0;
res_a = 1 - (1 - fg_a) * (1 - bg_a);
mul = fg_a / res_a;
mul_cmp = 1 - mul;
}
res_r = mul * ((double) RED(fg)) + mul_cmp * ((double) RED(bg));
res_g = mul * ((double) GREEN(fg)) + mul_cmp * ((double) GREEN(bg));
res_b = mul * ((double) BLUE(fg)) + mul_cmp * ((double) BLUE(bg));
return PIXEL((unsigned) (res_a * 255),
(unsigned) res_r, (unsigned) res_g, (unsigned) res_b);
}
示例2: glEnable
void PointSet::Draw ( float* view_mat, float rad )
{
char* dat;
Point* p;
glEnable ( GL_NORMALIZE );
if ( m_Param[PNT_DRAWMODE] == 0 ) {
glLoadMatrixf ( view_mat );
dat = mBuf[0].data;
for (int n = 0; n < NumPoints(); n++) {
p = (Point*) dat;
glPushMatrix ();
glTranslatef ( p->pos.x, p->pos.y, p->pos.z );
glScalef ( 0.2, 0.2, 0.2 );
if(p->type == 0)
glColor4f ( 0.1,0.3,1.0,1.0 );//glColor4f ( RED(p->clr), GRN(p->clr), BLUE(p->clr), ALPH(p->clr) );
else
glColor4f ( RED(p->clr), GRN(p->clr), BLUE(p->clr), 0.0 );
drawSphere ();
glPopMatrix ();
dat += mBuf[0].stride;
}
} else if ( m_Param[PNT_DRAWMODE] == 1 ) {
glLoadMatrixf ( view_mat );
dat = mBuf[0].data;
glBegin ( GL_POINTS );
for (int n=0; n < NumPoints(); n++) {
p = (Point*) dat;
glColor3f ( RED(p->clr), GRN(p->clr), BLUE(p->clr) );
glVertex3f ( p->pos.x, p->pos.y, p->pos.z );
dat += mBuf[0].stride;
}
glEnd ();
}
}
示例3: rain_init
static int
rain_init(video_adapter_t *adp)
{
video_info_t info;
int i;
if (!vidd_get_info(adp, M_VGA_CG320, &info)) {
scrmode = M_VGA_CG320;
} else if (!vidd_get_info(adp, M_PC98_PEGC640x480, &info)) {
scrmode = M_PC98_PEGC640x480;
} else if (!vidd_get_info(adp, M_PC98_PEGC640x400, &info)) {
scrmode = M_PC98_PEGC640x400;
} else {
log(LOG_NOTICE,
"%s: the console does not support M_VGA_CG320\n",
SAVER_NAME);
return (ENODEV);
}
scrw = info.vi_width;
scrh = info.vi_height;
/* intialize the palette */
for (i = 1; i < MAX; i++)
rain_pal[BLUE(i)] = rain_pal[BLUE(i - 1)] + INCREMENT;
return (0);
}
示例4: ALPHA
ColorARGB GifTranscoder::computeAverage(ColorARGB c1, ColorARGB c2, ColorARGB c3, ColorARGB c4) {
char avgAlpha = (char)(((int) ALPHA(c1) + (int) ALPHA(c2) +
(int) ALPHA(c3) + (int) ALPHA(c4)) / 4);
char avgRed = (char)(((int) RED(c1) + (int) RED(c2) +
(int) RED(c3) + (int) RED(c4)) / 4);
char avgGreen = (char)(((int) GREEN(c1) + (int) GREEN(c2) +
(int) GREEN(c3) + (int) GREEN(c4)) / 4);
char avgBlue = (char)(((int) BLUE(c1) + (int) BLUE(c2) +
(int) BLUE(c3) + (int) BLUE(c4)) / 4);
return MAKE_COLOR_ARGB(avgAlpha, avgRed, avgGreen, avgBlue);
}
示例5: rain_update
static void
rain_update(video_adapter_t *adp)
{
int i, t;
t = rain_pal[BLUE(MAX)];
for (i = MAX; i > 1; i--)
rain_pal[BLUE(i)] = rain_pal[BLUE(i - 1)];
rain_pal[BLUE(1)] = t;
vidd_load_palette(adp, rain_pal);
}
示例6: PT_CopyBlend
internal void
PT_CopyBlend(u32 *destPixels, PT_Rect *destRect, u32 destPixelsPerRow,
u32 *srcPixels, PT_Rect *srcRect, u32 srcPixelsPerRow,
u32 *newColor)
{
// If src and dest rects are not the same size ==> bad things
assert(destRect->w == srcRect->w && destRect->h == srcRect->h);
// For each pixel in the destination rect, alpha blend to it the
// corresponding pixel in the source rect.
// ref: https://en.wikipedia.org/wiki/Alpha_compositing
u32 stopX = destRect->x + destRect->w;
u32 stopY = destRect->y + destRect->h;
for (u32 dstY = destRect->y, srcY = srcRect->y;
dstY < stopY;
dstY++, srcY++) {
for (u32 dstX = destRect->x, srcX = srcRect->x;
dstX < stopX;
dstX++, srcX++) {
u32 srcColor = srcPixels[(srcY * srcPixelsPerRow) + srcX];
u32 *destPixel = &destPixels[(dstY * destPixelsPerRow) + dstX];
u32 destColor = *destPixel;
// Colorize our source pixel before we blend it
srcColor = PT_ColorizePixel(srcColor, *newColor);
if (ALPHA(srcColor) == 0) {
// Source is transparent - so do nothing
continue;
} else if (ALPHA(srcColor) == 255) {
// Just copy the color, no blending necessary
*destPixel = srcColor;
} else {
// Do alpha blending
float srcA = ALPHA(srcColor) / 255.0;
float invSrcA = (1.0 - srcA);
float destA = ALPHA(destColor) / 255.0;
float outAlpha = srcA + (destA * invSrcA);
u8 fRed = ((RED(srcColor) * srcA) + (RED(destColor) * destA * invSrcA)) / outAlpha;
u8 fGreen = ((GREEN(srcColor) * srcA) + (GREEN(destColor) * destA * invSrcA)) / outAlpha;
u8 fBlue = ((BLUE(srcColor) * srcA) + (BLUE(destColor) * destA * invSrcA)) / outAlpha;
u8 fAlpha = outAlpha * 255;
*destPixel = COLOR_FROM_RGBA(fRed, fGreen, fBlue, fAlpha);
}
}
}
}
示例7: hippo_cairo_set_source_rgba32
void
hippo_cairo_set_source_rgba32(cairo_t *cr,
guint32 color)
{
/* trying to avoid alpha 255 becoming a double alpha that isn't quite opaque ?
* not sure this is needed.
*/
if ((color & 0xff) == 0xff) {
cairo_set_source_rgb(cr, RED(color), GREEN(color), BLUE(color));
} else {
cairo_set_source_rgba(cr, RED(color), GREEN(color), BLUE(color), ALPHA(color));
}
}
示例8: getBilinearInterpolatedPixel
uint32_t getBilinearInterpolatedPixel(const void *pixels, int width, int height, int stride, float x, float y) {
int x1 = (int) x;
int x2 = x1+1;
int y1 = (int) y;
int y2 = y1+1;
uint32_t pixel1 = getPixelRGBA(pixels, stride, x1%width, y1%height);
uint32_t pixel2 = getPixelRGBA(pixels, stride, x2%width, y1%height);
uint32_t pixel3 = getPixelRGBA(pixels, stride ,x1%width, y2%height);
uint32_t pixel4 = getPixelRGBA(pixels, stride, x2%width, y2%height);
int red1 = RED(pixel1);
int green1 = GREEN(pixel1);
int blue1 = BLUE(pixel1);
int red2 = RED(pixel2);
int green2 = GREEN(pixel2);
int blue2 = BLUE(pixel2);
int red3 = RED(pixel3);
int green3 = GREEN(pixel3);
int blue3 = BLUE(pixel3);
int red4 = RED(pixel4);
int green4 = GREEN(pixel4);
int blue4 = BLUE(pixel4);
float w1 = x2-x;
float w2 = x-x1;
float red1_2 = w1*red1 + w2*red2;
float red2_3 = w1*red3 + w2*red4;
float green1_2 = w1*green1 + w2*green2;
float green2_3 = w1*green3 + w2*green4;
float blue1_2 = w1*blue1 + w2*blue2;
float blue2_3 = w1*blue3 + w2*blue4;
w1 = y2-y;
w2 = y-y1;
int red = (int) (w1*red1_2 + w2*red2_3 + 0.5);
int green = (int) (w1*green1_2 + w2*green2_3 + 0.5);
int blue = (int) (w1*blue1_2 + w2*blue2_3 + 0.5);
return createRGBAPixel(red, green, blue, 0);
}
示例9: sprintf
void TermCMD::help(cTerm & t,int argc,char *argv[])
{
t<<(GREEN("TermCMD commands:\n"));
cmd_table_t* t_ptr = NULL;
char txt[16];
int k = 0;
do
{
t_ptr = &mCmdTable[k++];
if(!t_ptr->cmd)
break;
if(t_ptr->f)
{
sprintf(txt,"%s %s", t_ptr->cmd, t_ptr->argDesc);
t<<" "<<t.format("%-10s - ",txt)<<t.format("%s\n",t_ptr->desc);
}
else
{
//this is a caption
t<<t.format(BLUE("%s\n"), t_ptr->cmd);
}
}while(t_ptr->cmd);
}
示例10: draw2DBox
/*
void draw2DBox(int top, int left, int right, int bottom, DWORD colour[4])
{
CONTROLVERTEX Vertices[4] = {
// x, y, z, rhw, colour, tu,tv
{ left, bottom, 0.0f, 1.0f, colour[0], 0.0f, 1.0f }, // BL
{ right, bottom, 0.0f, 1.0f, colour[2], 1.0f, 1.0f }, // BR
{ left, top, 0.0f, 1.0f, colour[1], 0.0f, 0.0f }, // TL
{ right, top, 0.0f, 1.0f, colour[3], 1.0f, 0.0f }, // TR
};
glBegin(GL_TRIANGLE_STRIP);
for (int i = 0; i < 4; )
{
DWORD &c = Vertices[i].diffuse;
float c1[4] ={
((float)RED(c)) / 255.0,
((float)GREEN(c)) / 255.0,
((float)BLUE(c)) / 255.0,
((float)ALPHA(c)) / 255.0
};
glColor4fv(c1);
glTexCoord2d(Vertices[i].tu0,Vertices[i].tv0);
glVertex3f(Vertices[i].x, Vertices[i].y, Vertices[i].z);
i++;
}
glEnd();
}
*/
void draw2DBox(float top, float left, float right, float bottom, DWORD colour[4])
{
CONTROLVERTEX Vertices[4] = {
// x, y, z, rhw, colour, tu,tv
{ left, bottom, 0.0f, 1.0f, colour[0], 0.0f, 1.0f }, // BL
{ right, bottom, 0.0f, 1.0f, colour[2], 1.0f, 1.0f }, // BR
{ left, top, 0.0f, 1.0f, colour[1], 0.0f, 0.0f }, // TL
{ right, top, 0.0f, 1.0f, colour[3], 1.0f, 0.0f }, // TR
};
glBegin(GL_TRIANGLE_STRIP);
for (int i = 0; i < 4; )
{
DWORD &c = Vertices[i].diffuse;
float c1[4] ={
((float)RED(c)) / 255.0f,
((float)GREEN(c)) / 255.0f,
((float)BLUE(c)) / 255.0f,
((float)ALPHA(c)) / 255.0f
};
glColor4fv(c1);
glTexCoord2d(Vertices[i].tu0,Vertices[i].tv0);
glVertex3f(Vertices[i].x, Vertices[i].y, Vertices[i].z);
i++;
}
glEnd();
}
示例11: malloc
char *region_of_interest (NEURON_LAYER *nl_input, int x_center, int y_center, int width, int height)
{
int xi, yi, wi, hi, xo, yo, wo, ho;
NEURON_OUTPUT value;
char * output = malloc(width * height * 3 * sizeof(char));
wi = nl_input->dimentions.x;
hi = nl_input->dimentions.y;
wo = width;
ho = height;
for (yo = 0; yo < ho; yo++)
{
for (xo = 0; xo < wo; xo++)
{
xi = (int) ((double) xo + .5) + x_center - wo/2;
yi = (int) ((double) yo + .5) + y_center - ho/2;
if (xi >= 0 && xi < wi && yi >= 0 && yi < hi)
value = nl_input->neuron_vector[xi + wi * yi].output;
else
value.ival = 0;
output[3 * (yo * wo + xo) + 0] = RED(value.ival);
output[3 * (yo * wo + xo) + 1] = GREEN(value.ival);
output[3 * (yo * wo + xo) + 2] = BLUE(value.ival);
}
}
return output;
}
示例12: RGB
bool RGBLinearQuantizationFilter::Apply(til::Image &image) const
{
if (image.GetBitDepth() != til::Image::BPP_32B_R8G8B8) return false;
til::uint32 *image_pixels = reinterpret_cast<til::uint32*>(image.GetPixels());
std::vector<til::byte> palette[3] = {
std::vector<til::byte>(max(((til::byte)(_palette_quants)), 1), 0x00),
std::vector<til::byte>(max(((til::byte)(_palette_quants >> 8)), 1), 0x00),
std::vector<til::byte>(max(((til::byte)(_palette_quants >> 16)), 1), 0x00)
};
til::byte index[] = {
static_cast<til::byte>(0x100 / palette[0].size()) + (palette[0].size() % 2 * static_cast<til::byte>(palette[0].size() > 1)),
static_cast<til::byte>(0x100 / palette[1].size()) + (palette[1].size() % 2 * static_cast<til::byte>(palette[1].size() > 1)),
static_cast<til::byte>(0x100 / palette[2].size()) + (palette[2].size() % 2 * static_cast<til::byte>(palette[2].size() > 1))
};
for(std::vector<til::byte>::size_type i = 0, max = palette[0].size(); i < max; ++i) palette[0][i] = static_cast<til::byte>(i * index[0]);
for(std::vector<til::byte>::size_type i = 0, max = palette[1].size(); i < max; ++i) palette[1][i] = static_cast<til::byte>(i * index[1]);
for(std::vector<til::byte>::size_type i = 0, max = palette[2].size(); i < max; ++i) palette[2][i] = static_cast<til::byte>(i * index[2]);
for (til::uint64 i = 0, max = image.GetWidth() * image.GetHeight(); i < max; ++i)
{
image_pixels[i] = RGB(
palette[0][index[0] == 0x00 ? 0 : RED(image_pixels[i]) / index[0]],
palette[1][index[1] == 0x00 ? 0 : GREEN(image_pixels[i]) / index[1]],
palette[2][index[2] == 0x00 ? 0 : BLUE(image_pixels[i]) / index[2]]
);
}
return true;
}
示例13: draw3DLine
void draw3DLine(float sx, float sy, float sz, float ex, float ey, float ez, DWORD colour)
{
glLoadIdentity();
/*D3DXMATRIX mat;
D3DXMatrixIdentity(&mat);
g_pd3dDevice->SetTransform( D3DTS_WORLD, &mat ); // Move object
*/
DWORD &c = colour;
float c1[4] ={
((float)RED(c)) / 255.0f,
((float)GREEN(c)) / 255.0f,
((float)BLUE(c)) / 255.0f,
((float)ALPHA(c)) / 255.0f
};
glColor4fv(c1);
glBegin(GL_LINES);
// glColor4f(RED(colour), GREEN(colour), BLUE(colour), ALPHA(colour));
glVertex3f(sx, sy, sz);
glVertex3f(ex, ey, ez);
glEnd();
/*
#define D3DFVF_LVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE)
struct LVERTEX { float x, y, z; DWORD diffuse; };
LVERTEX line[2] = {
{ sx, sy, sz, colour },
{ ex, ey, ez, colour }
};
SetVertexShader( D3DFVF_LVERTEX );
g_pd3dDevice->DrawPrimitiveUP(D3DPT_LINELIST, 2, line, sizeof(LVERTEX));
*/
}
示例14: glBegin
void GEQuad::drawVisual(vector_t unit_size)
{
float hx, hy, hz;
hx = (this->dimensions.x * unit_size.x) / 2;
hy = (this->dimensions.y * unit_size.y) / 2;
hz = (this->dimensions.z * unit_size.z) / 2;
glBegin(GL_QUADS);
glColor3ub(RED(bg_color), GREEN(bg_color), BLUE(bg_color));
glVertex3f( hx, hy,-hz);
glVertex3f(-hx, hy,-hz);
glVertex3f(-hx, hy, hz);
glVertex3f( hx, hy, hz);
glVertex3f( hx,-hy, hz);
glVertex3f(-hx,-hy, hz);
glVertex3f(-hx,-hy,-hz);
glVertex3f( hx,-hy,-hz);
glVertex3f( hx, hy, hz);
glVertex3f(-hx, hy, hz);
glVertex3f(-hx,-hy, hz);
glVertex3f( hx,-hy, hz);
glVertex3f( hx,-hy,-hz);
glVertex3f(-hx,-hy,-hz);
glVertex3f(-hx, hy,-hz);
glVertex3f( hx, hy,-hz);
glEnd();
}
示例15: compute_gray
/*
* Enforces all pixels to grayscale.
*/
void compute_gray(struct jpeg_data *jpeg)
{
if (jpeg == NULL || jpeg->raw_data == NULL)
return;
uint32_t nb_pixels, pixel;
uint32_t *image = jpeg->raw_data;
uint32_t R, G, B, gray;
/* Compute the buffer size */
if (jpeg->is_plain_image)
nb_pixels = jpeg->width * jpeg->height;
else
nb_pixels = jpeg->mcu.size * jpeg->mcu.nb;
/* Convert each pixel */
for (uint32_t i = 0; i < nb_pixels; i++) {
pixel = image[i];
R = RED(pixel);
G = GREEN(pixel);
B = BLUE(pixel);
gray = (R + G + B) / 3;
image[i] = gray << 16 | gray << 8 | gray;
}
}