本文整理汇总了C++中PixelBuffer::setPixel方法的典型用法代码示例。如果您正苦于以下问题:C++ PixelBuffer::setPixel方法的具体用法?C++ PixelBuffer::setPixel怎么用?C++ PixelBuffer::setPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PixelBuffer
的用法示例。
在下文中一共展示了PixelBuffer::setPixel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawGridGradientCircle
void drawGridGradientCircle(PixelBuffer& buf) {
float midX = buf.width() / 2.f;
float midY = buf.height() / 2.f;
float maxDistSquared = midX * midX + midY * midY;
for (int i=0; i < buf.width(); i++) {
for (int j=0; j < buf.height(); j++) {
float distX = (midX - i);
float distY = (midY - j);
float distSquared = distX * distX + distY * distY;
float t = 1 - distSquared / maxDistSquared;
if ( t < 0.90) {
if ( (i + j) % 2 == 0 ) {
buf.setPixel(i,j, t * .75, t * .75, t * .75);
} else {
buf.setPixel(i,j, t * .25, t * .25, t * .25);
}
} else {
if (fmod(t * 1000.f, 1.f) < .5) {
buf.setPixel(i,j, 0.8f,0.3f,0.1f);
} else {
buf.setPixel(i,j, 0.9,.51,.22);
}
}
}
}
}
示例2: applyToBuffer
void Filter::applyToBuffer(PixelBuffer* buffer, float newStrength[])
{
PixelBuffer* tempB;
tempB = new PixelBuffer(buffer->getWidth(), buffer->getHeight(), buffer->getBackgroundColor());
for (int h = 0; h < buffer->getHeight(); h++)
{
for (int w = 0; w < buffer->getWidth(); w++)
{
ColorData c = buffer->getPixel(w, h);
for (int mw = 0; mw < maskWidth; mw++)
{
for (int mh = 0; mh < maskHeight; mh++)
{
trans = mask[mw][mh];
ColorData maskC = buffer->getPixel((w - maskWidth/2 + mw), (h - maskHeight/2 + mh));
maskC = maskC * trans;
c = c + maskC;
}
}
c = c - buffer->getPixel(w, h);
tempB->setPixel(w, h, c);
}
}
buffer->copyPixelBuffer(tempB, buffer);
delete tempB;
}
示例3: loadImage
PixelBuffer* IPNGHandler::loadImage(const std::string fileName)
{
cout << "IPNGHandler LOAD IMAGE" << endl;
printf("IPNGHandler -> loadImage\n");
PixelBuffer* loadedImageBuffer = NULL;
png_image image;
memset(&image, 0, (sizeof image));
image.version = PNG_IMAGE_VERSION;
if (png_image_begin_read_from_file(&image, fileName.c_str())) {
loadedImageBuffer = new PixelBuffer(image.width, image.height, ColorData(0.0,0.0,0.0));
png_bytep buffer;
image.format = PNG_FORMAT_RGBA;
buffer = new png_byte[PNG_IMAGE_SIZE(image)];
if (buffer && png_image_finish_read(&image, NULL, buffer, 0, NULL)) {
cout << "Finished buffer read" << endl;
for (int y = 0; y < image.height; y++) {
for (int x = 0; x < image.width; x++) {
int r, g, b, a = 0;
r = (int)buffer[(y*image.width*4)+(x*4)];
g = (int)buffer[(y*image.width*4)+(x*4)+1];
b = (int)buffer[(y*image.width*4)+(x*4)+2];
a = (int)buffer[(y*image.width*4)+(x*4)+3];
loadedImageBuffer->setPixel(x, image.height-(y+1), ColorData(r/255.0f,g/255.0f,b/255.0f,a/255.0f));
}
}
}
delete[] buffer;
}
cout << "returning loaded image buffer" << endl;
return loadedImageBuffer;
}