當前位置: 首頁>>代碼示例>>C++>>正文


C++ shared_ptr::rows方法代碼示例

本文整理匯總了C++中tr1::shared_ptr::rows方法的典型用法代碼示例。如果您正苦於以下問題:C++ shared_ptr::rows方法的具體用法?C++ shared_ptr::rows怎麽用?C++ shared_ptr::rows使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tr1::shared_ptr的用法示例。


在下文中一共展示了shared_ptr::rows方法的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();
}
開發者ID:mengqwang2,項目名稱:libopenshot,代碼行數:31,代碼來源:Frame.cpp


注:本文中的tr1::shared_ptr::rows方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。