本文整理汇总了C++中tr1::shared_ptr::getPixels方法的典型用法代码示例。如果您正苦于以下问题:C++ shared_ptr::getPixels方法的具体用法?C++ shared_ptr::getPixels怎么用?C++ shared_ptr::getPixels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tr1::shared_ptr
的用法示例。
在下文中一共展示了shared_ptr::getPixels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddMagickImage
// Get pointer to QImage of frame
void Frame::AddMagickImage(tr1::shared_ptr<Magick::Image> new_image)
{
const int BPP = 4;
const std::size_t bufferSize = new_image->columns() * new_image->rows() * BPP;
/// Use realloc for fast memory allocation.
/// TODO: consider locking the buffer for mt safety
//qbuffer = reinterpret_cast<unsigned char*>(realloc(qbuffer, bufferSize));
qbuffer = new unsigned char[bufferSize]();
unsigned char *buffer = (unsigned char*)qbuffer;
// Iterate through the pixel packets, and load our own buffer
// Each color needs to be scaled to 8 bit (using the ImageMagick built-in ScaleQuantumToChar function)
int numcopied = 0;
Magick::PixelPacket *pixels = new_image->getPixels(0,0, new_image->columns(), new_image->rows());
for (int n = 0, i = 0; n < new_image->columns() * new_image->rows(); n += 1, i += 4) {
buffer[i+0] = MagickCore::ScaleQuantumToChar((Magick::Quantum) pixels[n].red);
buffer[i+1] = MagickCore::ScaleQuantumToChar((Magick::Quantum) pixels[n].green);
buffer[i+2] = MagickCore::ScaleQuantumToChar((Magick::Quantum) pixels[n].blue);
buffer[i+3] = 255 - MagickCore::ScaleQuantumToChar((Magick::Quantum) pixels[n].opacity);
numcopied+=4;
}
// Create QImage of frame data
image = tr1::shared_ptr<QImage>(new QImage(qbuffer, width, height, width * BPP, QImage::Format_RGBA8888, (QImageCleanupFunction) &cleanUpBuffer, (void*) qbuffer));
// Update height and width
width = image->width();
height = image->height();
}