本文整理汇总了C++中Pixel::getColor方法的典型用法代码示例。如果您正苦于以下问题:C++ Pixel::getColor方法的具体用法?C++ Pixel::getColor怎么用?C++ Pixel::getColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pixel
的用法示例。
在下文中一共展示了Pixel::getColor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ip_composite
/*
* use a mask image for a per-pixel alpha value to perform
* interpolation with a second image
*/
void ip_composite(Image* dest, Image* strokeImage, int x, int y)
{
static const double whiteThreshold = 1;
for (int i = 1; i < strokeImage->getWidth()-1; ++i) {
for (int j = 1; j < strokeImage->getHeight()-1; ++j) {
// if((x+i)<dest->getWidth() && (y+j)<dest->getHeight() && (x + i) >= 0 && (y+j)>=0) {
Pixel strokePixel = strokeImage->getPixel(i, j);
Pixel imagePixel = dest->getPixel((x+i)%dest->getWidth(), (y+j)%dest->getWidth());
if(strokePixel.getColor(0)<imagePixel.getColor(0)){
dest->setPixel((x+i)%dest->getWidth(), (y+j)%dest->getWidth(), strokePixel);
}
}
}
}
示例2: drawPixel
void Screen::drawPixel(Pixel pixel) {
Point position = (pixel.getPosition());
if (position.x>= width || position.x < 0 || position.y >=height || position.y <0 )
return;
int location = (position.x+vinfo.xoffset) * (vinfo.bits_per_pixel/8)
+ (position.y+vinfo.yoffset) * finfo.line_length;
Color color = (pixel.getColor());
*(pseudoFrame+location) = color.blue;
*(pseudoFrame+location+1) = color.green;
*(pseudoFrame+location+2) = color.red;
*(pseudoFrame+location+3) = color.alpha;
}
示例3: getColor
int PixelBinder::getColor(lua_State* L)
{
Binder binder(L);
Pixel* bitmap = static_cast<Pixel*>(binder.getInstance("Pixel", 1));
float r,g,b,a;
bitmap->getColor(r,g,b,a);
unsigned int color = ((((int)(r*255))&0xFF)<<16)|((((int)(g*255))&0xFF)<<8)|((((int)(b*255))&0xFF)<<0);
lua_pushnumber(L,color);
lua_pushnumber(L,a);
return 2;
}
示例4: sg_jBilateral
Image* sg_jBilateral (Image* src, Image* src2, Image* mask){
float id = 48.0;
float cd = 0.1;
int width = src->getWidth();
int height = src->getHeight();
Image* tempImage = new Image(width, height);
int kernelDim = 9;
int kernelHalf = 4;
for (int y = 0; y < width; ++y) {
for (int x = 0; x < height; ++x) {
float sumWeight = 0;
float sum[3];
sum[0] = 0;
sum[1] = 0;
sum[2] = 0;
int ctrIdx = y*width+x;
Pixel* ctrPix = new Pixel();
Pixel* ctrPix2 = new Pixel();
ctrPix->setColor(0, src->getPixel_(y, x, 0));
ctrPix->setColor(1, src->getPixel_(y, x, 1));
ctrPix->setColor(2, src->getPixel_(y, x, 2));
ctrPix2->setColor(0, src2->getPixel_(y, x, 0));
ctrPix2->setColor(1, src2->getPixel_(y, x, 1));
ctrPix2->setColor(2, src2->getPixel_(y, x, 2));
for (int m = 0; m < kernelDim; ++m) {
for (int n = 0; n < kernelDim; ++n) {
Pixel* curPix = new Pixel();
Pixel* curPix2 = new Pixel();
curPix->setColor(0, src->getPixel_(y-((kernelDim-1)/2)+m, x-((kernelDim-1)/2)+n, RED));
curPix->setColor(1, src->getPixel_(y-((kernelDim-1)/2)+m, x-((kernelDim-1)/2)+n, GREEN));
curPix->setColor(2, src->getPixel_(y-((kernelDim-1)/2)+m, x-((kernelDim-1)/2)+n, BLUE));
curPix2->setColor(0, src2->getPixel_(y-((kernelDim-1)/2)+m, x-((kernelDim-1)/2)+n, RED));
curPix2->setColor(1, src2->getPixel_(y-((kernelDim-1)/2)+m, x-((kernelDim-1)/2)+n, GREEN));
curPix2->setColor(2, src2->getPixel_(y-((kernelDim-1)/2)+m, x-((kernelDim-1)/2)+n, BLUE));
float currWeight;
float imageDist = sqrt( (float)((m-x)*(m-x) + (n-y)*(n-y)) );
float colorDist = sqrt( (float)( (curPix2->getColor(0) - ctrPix2->getColor(0))*(curPix2->getColor(0) - ctrPix2->getColor(0)) +
(curPix2->getColor(1) - ctrPix2->getColor(1))*(curPix2->getColor(1) - ctrPix2->getColor(1)) +
(curPix2->getColor(2) - ctrPix2->getColor(2))*(curPix2->getColor(2) - ctrPix2->getColor(2)) ) );
currWeight = 1.0f/(exp((imageDist/id)*(imageDist/id)*0.5)*exp((colorDist/cd)*(colorDist/cd)*0.5));
sumWeight += currWeight;
sum[0] += currWeight*curPix->getColor(0);
sum[1] += currWeight*curPix->getColor(1);
sum[2] += currWeight*curPix->getColor(2);
}
}
if(sumWeight> 0){
sum[0] /= sumWeight;
sum[1] /= sumWeight;
sum[2] /= sumWeight;
}
tempImage->setPixel_(y, x, 0, sum[0]);
tempImage->setPixel_(y, x, 1, sum[1]);
tempImage->setPixel_(y, x, 2, sum[2]);
}
}
return tempImage;
}