本文整理汇总了C++中ofFloatImage::getColor方法的典型用法代码示例。如果您正苦于以下问题:C++ ofFloatImage::getColor方法的具体用法?C++ ofFloatImage::getColor怎么用?C++ ofFloatImage::getColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofFloatImage
的用法示例。
在下文中一共展示了ofFloatImage::getColor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ofNoise
void
testApp::renderNoise(ofFloatImage &img)
{
double maxval = 0.0;
double minval = 10.0;
for (int i = 0; i < img.getWidth(); i++) {
for (int j = 0; j < img.getHeight(); j++) {
double sum = 0;
double scale = 1.0;
double p[2];
p[0] = i /(float)img.getWidth() + offset;
p[1] = j /(float)img.getHeight();
for (int k = 0; k < images.size(); k++) {
double val = ofNoise(p[0], p[1]);
images[k].setColor(i, j, val);
sum += val / scale;
scale *= alpha;
p[0] *= beta;
p[1] *= beta;
}
img.setColor(i, j, sum);
if (sum > maxval)
maxval = sum;
if (sum < minval)
minval = sum;
}
}
if (norm) {
for (int i = 0; i < img.getWidth(); i++) {
for (int j = 0; j < img.getHeight(); j++) {
float v = img.getColor(i, j).r;
img.setColor(i, j, v/maxval);
// img.setColor(i, j, ofMap(v, 0.0, maxval, 0.0, 1.0));
// img.setColor(i, j, ofMap(v, minval, maxval, 0.0, 1.0));
}
}
}
img.update();
for (ofFloatImage &i : images)
i.update();
dirty = false;
}
示例2: floor
ofFloatColor DNS::Image::Sample(const ofFloatImage & image, ofVec2f pixelCoordinate)
{
/*
(0,0)--(1,0)--(2,0)--(3,0)--(4,0)-
| | | | |
| | | | |
| | | | |
(0,1)--(1,1)--(2,1)--(3,1)--(4,1)-
| | | | |
| | | | |
| | | | |
(0,2)--(1,2)--(2,2)--(3,2)--(4,2)-
| | | | |
*/
int col1 = floor(pixelCoordinate.x - 0.5);
int col2 = col1 + 1;
col1 = MAX(0, col1);
col2 = MIN(image.width-1, col2);
int row1 = floor(pixelCoordinate.y - 0.5);
int row2 = row1 + 1;
row1 = MAX(0, row1);
row2 = MIN(image.height-1, row2);
float intPart;
float xAmount = modf(pixelCoordinate.x - 0.5, &intPart);
float yAmount = modf(pixelCoordinate.y - 0.5, &intPart);
ofFloatColor row1Color = DNS::Color::InterpolateLinear( image.getColor(col1, row1), image.getColor(col2, row1), xAmount );
ofFloatColor row2Color = DNS::Color::InterpolateLinear( image.getColor(col1, row2), image.getColor(col2, row2), xAmount );
ofFloatColor finalColor = DNS::Color::InterpolateLinear( row1Color, row2Color, yAmount );
return finalColor;
}
示例3: getValueFromImagePos
float ofxShadowedTerrain::getValueFromImagePos(ofFloatImage& img, int x, int y){
return zstretchfact * img.getColor(x,y).getBrightness();
}