本文整理汇总了C++中ImagePtr函数的典型用法代码示例。如果您正苦于以下问题:C++ ImagePtr函数的具体用法?C++ ImagePtr怎么用?C++ ImagePtr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ImagePtr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: imageSize
TexturePtr TextureManager::loadTexture(std::stringstream& file)
{
TexturePtr texture;
apng_data apng;
if(load_apng(file, &apng) == 0) {
Size imageSize(apng.width, apng.height);
if(apng.num_frames > 1) { // animated texture
std::vector<ImagePtr> frames;
std::vector<int> framesDelay;
for(uint i=0;i<apng.num_frames;++i) {
uchar *frameData = apng.pdata + ((apng.first_frame+i) * imageSize.area() * apng.bpp);
int frameDelay = apng.frames_delay[i];
framesDelay.push_back(frameDelay);
frames.push_back(ImagePtr(new Image(imageSize, apng.bpp, frameData)));
}
AnimatedTexturePtr animatedTexture = new AnimatedTexture(imageSize, frames, framesDelay);
m_animatedTextures.push_back(animatedTexture);
texture = animatedTexture;
} else {
ImagePtr image = ImagePtr(new Image(imageSize, apng.bpp, apng.pdata));
texture = TexturePtr(new Texture(image));
}
free_apng(&apng);
}
return texture;
}
示例2: assert
std::pair<ImagePtr, RectD>
TrackMarker::getMarkerImage(TimeValue time,
const RectD& roi) const
{
assert( !roi.isNull() );
NodePtr node = getModel()->getNode();
NodePtr input = node->getInput(0);
if (!input) {
return std::make_pair(ImagePtr(), roi);
}
TreeRender::CtorArgsPtr args(new TreeRender::CtorArgs);
{
args->treeRootEffect = input->getEffectInstance();
args->time = time;
args->view = ViewIdx(0);
// Render default plane
args->plane = 0;
args->mipMapLevel = 0;
args->proxyScale = RenderScale(1.);
args->canonicalRoI = &roi;
args->draftMode = false;
args->playback = false;
args->byPassCache = false;
}
TreeRenderPtr render = TreeRender::create(args);
FrameViewRequestPtr outputRequest;
ActionRetCodeEnum stat = render->launchRender(&outputRequest);
if (isFailureRetCode(stat)) {
return std::make_pair(ImagePtr(), roi);
}
ImagePtr sourceImage = outputRequest->getRequestedScaleImagePlane();
// Make sure the Natron image rendered is RGBA full rect and on CPU, we don't support other formats
if (sourceImage->getStorageMode() != eStorageModeRAM) {
Image::InitStorageArgs initArgs;
initArgs.bounds = sourceImage->getBounds();
initArgs.plane = sourceImage->getLayer();
initArgs.bufferFormat = eImageBufferLayoutRGBAPackedFullRect;
initArgs.storage = eStorageModeRAM;
initArgs.bitdepth = sourceImage->getBitDepth();
ImagePtr tmpImage = Image::create(initArgs);
if (!tmpImage) {
return std::make_pair(ImagePtr(), roi);
}
Image::CopyPixelsArgs cpyArgs;
cpyArgs.roi = initArgs.bounds;
tmpImage->copyPixels(*sourceImage, cpyArgs);
sourceImage = tmpImage;
}
return std::make_pair(sourceImage, roi);
} // TrackMarker::getMarkerImage
示例3: ImagePtr
void PeerData::updateUserpic(
PhotoId photoId,
const MTPFileLocation &location) {
const auto size = kUserpicSize;
const auto loc = StorageImageLocation::FromMTP(size, size, location);
const auto photo = loc.isNull() ? ImagePtr() : ImagePtr(loc);
setUserpicChecked(photoId, loc, photo);
}
示例4: ImagePtr
ImagePtr TrackedStream::getChangingImage()
{
if(!mVideoSource)
return ImagePtr();
if (!mImage)
mImage = ImagePtr(new Image(this->getUid()+"_TrackedStreamHelper", mVideoSource->getVtkImageData(), this->getName()+"_TrackedStreamHelper"));
return mImage;
}
示例5: ImagePtr
void BackgroundInner::gotWallpapers(const MTPVector<MTPWallPaper> &result) {
App::WallPapers wallpapers;
wallpapers.push_back(App::WallPaper(0, ImagePtr(st::msgBG0), ImagePtr(st::msgBG0)));
const QVector<MTPWallPaper> &v(result.c_vector().v);
for (int i = 0, l = v.size(); i < l; ++i) {
const MTPWallPaper w(v.at(i));
switch (w.type()) {
case mtpc_wallPaper: {
const MTPDwallPaper &d(w.c_wallPaper());
const QVector<MTPPhotoSize> &sizes(d.vsizes.c_vector().v);
const MTPPhotoSize *thumb = 0, *full = 0;
int32 thumbLevel = -1, fullLevel = -1;
for (QVector<MTPPhotoSize>::const_iterator j = sizes.cbegin(), e = sizes.cend(); j != e; ++j) {
char size = 0;
int32 w = 0, h = 0;
switch (j->type()) {
case mtpc_photoSize: {
const string &s(j->c_photoSize().vtype.c_string().v);
if (s.size()) size = s[0];
w = j->c_photoSize().vw.v;
h = j->c_photoSize().vh.v;
} break;
case mtpc_photoCachedSize: {
const string &s(j->c_photoCachedSize().vtype.c_string().v);
if (s.size()) size = s[0];
w = j->c_photoCachedSize().vw.v;
h = j->c_photoCachedSize().vh.v;
} break;
}
if (!size || !w || !h) continue;
int32 newThumbLevel = qAbs((st::backgroundSize.width() * cIntRetinaFactor()) - w), newFullLevel = qAbs(2560 - w);
if (thumbLevel < 0 || newThumbLevel < thumbLevel) {
thumbLevel = newThumbLevel;
thumb = &(*j);
}
if (fullLevel < 0 || newFullLevel < fullLevel) {
fullLevel = newFullLevel;
full = &(*j);
}
}
if (thumb && full && full->type() != mtpc_photoSizeEmpty) {
wallpapers.push_back(App::WallPaper(d.vid.v ? d.vid.v : INT_MAX, App::image(*thumb), App::image(*full)));
}
} break;
case mtpc_wallPaperSolid: {
const MTPDwallPaperSolid &d(w.c_wallPaperSolid());
} break;
}
}
App::cSetServerBackgrounds(wallpapers);
updateWallpapers();
}
示例6: glTexImage2D
void Texture::upload() {
if (!_img)
return;
if (_img->isLoaded()) {
const GLenum mode = _img->hasAlpha() ? GL_RGBA : GL_RGB;
glTexImage2D(GL_TEXTURE_2D, 0, mode, _img->width(), _img->height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, _img->data());
_img = ImagePtr();
_state = io::IOSTATE_LOADED;
} else if (_img->isFailed()) {
_state = io::IOSTATE_FAILED;
_img = ImagePtr();
}
}
示例7: img
ImagePtr Client::nextImage() {
if (shared_mem_client_.initialized())
{
ImagePtr img(new Image); // TODO
if (shared_mem_client_.nextImage(*img))
return img;
else
return ImagePtr();
}
image_ptr_ = 0;
cb_queue_.callAvailable();
return ImagePtr(image_ptr_);
}
示例8: r
void StickerSetInner::paintEvent(QPaintEvent *e) {
QRect r(e->rect());
Painter p(this);
if (_pack.isEmpty()) return;
int32 rows = _pack.size() / StickerPanPerRow + ((_pack.size() % StickerPanPerRow) ? 1 : 0);
int32 from = qFloor(e->rect().top() / st::stickersSize.height()), to = qFloor(e->rect().bottom() / st::stickersSize.height()) + 1;
for (int32 i = from; i < to; ++i) {
for (int32 j = 0; j < StickerPanPerRow; ++j) {
int32 index = i * StickerPanPerRow + j;
if (index >= _pack.size()) break;
DocumentData *doc = _pack.at(index);
QPoint pos(st::stickerPanPadding + j * st::stickersSize.width(), i * st::stickersSize.height());
bool goodThumb = !doc->thumb->isNull() && ((doc->thumb->width() >= 128) || (doc->thumb->height() >= 128));
if (goodThumb) {
doc->thumb->load();
} else {
bool already = !doc->already().isEmpty(), hasdata = !doc->data.isEmpty();
if (!doc->loader && doc->status != FileFailed && !already && !hasdata) {
doc->save(QString());
}
if (doc->sticker->img->isNull() && (already || hasdata)) {
if (already) {
doc->sticker->img = ImagePtr(doc->already());
} else {
doc->sticker->img = ImagePtr(doc->data);
}
}
}
float64 coef = qMin((st::stickersSize.width() - st::msgRadius * 2) / float64(doc->dimensions.width()), (st::stickersSize.height() - st::msgRadius * 2) / float64(doc->dimensions.height()));
if (coef > 1) coef = 1;
int32 w = qRound(coef * doc->dimensions.width()), h = qRound(coef * doc->dimensions.height());
if (w < 1) w = 1;
if (h < 1) h = 1;
QPoint ppos = pos + QPoint((st::stickersSize.width() - w) / 2, (st::stickersSize.height() - h) / 2);
if (goodThumb) {
p.drawPixmapLeft(ppos, width(), doc->thumb->pix(w, h));
} else if (!doc->sticker->img->isNull()) {
p.drawPixmapLeft(ppos, width(), doc->sticker->img->pix(w, h));
}
}
}
p.fillRect(0, _bottom - st::stickersAddOrShare, width(), st::stickersAddOrShare, st::emojiPanHeaderBg->b);
}
示例9: D3DXCreateTexture
ImagePtr D3D9VideoBufferManager::CreateImage(int iWidth, int iHeight, FORMAT Format)
{
IDirect3DTexture9 * texture;
HRESULT hr = D3DXCreateTexture(mD3D9Device,
iWidth,
iHeight,
1,
0,
D3D9Mapping::GetD3DFormat(Format),
D3DPOOL_SYSTEMMEM,
&texture);
D3DErrorExceptionFunction(D3DXCreateTexture, hr);
IDirect3DSurface9 * surface;
texture->GetSurfaceLevel(0, &surface);
D3DSURFACE_DESC desc;
surface->GetDesc(&desc);
D3D9Image * image = new D3D9Image();
image->mWidth = desc.Width;
image->mHeight = desc.Height;
image->mSrcWidth = iWidth;
image->mSrcHeight = iHeight;
image->mFormat = D3D9Mapping::GetFormat(desc.Format);
image->mMipmapLevel = texture->GetLevelCount();
image->mD3D9Texture = texture;
surface->Release();
return ImagePtr(image);
}
示例10: greenptr
/**
* \brief Combine image, mask and center into a color image
*/
ImagePtr VCurveFocusWork::combine(ImagePtr image, FWHMInfo& fwhminfo) {
// first build the red channel from the mask
Image<unsigned char> *red
= dynamic_cast<Image<unsigned char> *>(&*fwhminfo.mask);
if (NULL == red) {
throw std::logic_error("internal error, mask has not 8bit pixel type");
}
// then build the green channel from the original image
Image<unsigned char> *green = FocusWork::green(image);
ImagePtr greenptr(green);
// create the blue image
CrosshairAdapter<unsigned char> crosshair(image->size(), fwhminfo.maxpoint, 20);
CircleAdapter<unsigned char> circle(image->size(), fwhminfo.center,
fwhminfo.radius);
MaxAdapter<unsigned char> blue(crosshair, circle);
// now use a combination adapter to put all these images together
// into a single color image
CombinationAdapter<unsigned char> combinator(*red, *green, blue);
Image<RGB<unsigned char> > *result
= new Image<RGB<unsigned char> >(combinator);
return ImagePtr(result);
}
示例11: setImage
void VolumetricRep::setImage(ImagePtr image)
{
if (image==mImage)
{
return;
}
if (mImage)
{
mVolumeProperty->setImage(ImagePtr());
disconnect(mImage.get(), &Image::vtkImageDataChanged, this, &VolumetricRep::vtkImageDataChangedSlot);
disconnect(mImage.get(), &Image::transformChanged, this, &VolumetricRep::transformChangedSlot);
mMonitor.reset();
mMapper->SetInputData( (vtkImageData*)NULL );
}
mImage = image;
if (mImage)
{
connect(mImage.get(), &Image::vtkImageDataChanged, this, &VolumetricRep::vtkImageDataChangedSlot);
connect(mImage.get(), &Image::transformChanged, this, &VolumetricRep::transformChangedSlot);
mVolumeProperty->setImage(mImage);
this->vtkImageDataChangedSlot();
mMonitor = ImageMapperMonitor::create(mVolume, mImage);
}
}
示例12: ImagePtr
ImagePtr PixelStreamSynchronizer::getTileImage( const uint tileIndex ) const
{
if( !_updater )
return ImagePtr();
return _updater->getTileImage( tileIndex );
}
示例13: ImagePtr
ImagePtr Image::copy()
{
vtkImageDataPtr baseImageDataCopy;
if(mBaseImageData)
{
baseImageDataCopy = vtkImageDataPtr::New();
baseImageDataCopy->DeepCopy(mBaseImageData);
}
ImagePtr retval = ImagePtr(new Image(mUid, baseImageDataCopy, mName));
retval->mUnsigned = mUnsigned;
retval->mModality = mModality;
retval->mImageType = mImageType;
retval->mMaxRGBIntensity = mMaxRGBIntensity;
retval->mInterpolationType = mInterpolationType;
retval->mImageLookupTable2D = mImageLookupTable2D;
retval->mImageTransferFunctions3D = mImageTransferFunctions3D;
retval->mInitialWindowWidth = mInitialWindowWidth;
retval->mInitialWindowLevel = mInitialWindowLevel;
//From cx::Data
retval->mRegistrationStatus = mRegistrationStatus;
retval->m_rMd_History = m_rMd_History;
return retval;
}
示例14: ImagePtr
TexturePtr LightView::generateLightBubble(float centerFactor)
{
int bubbleRadius = 256;
int centerRadius = bubbleRadius * centerFactor;
int bubbleDiameter = bubbleRadius * 2;
ImagePtr lightImage = ImagePtr(new Image(Size(bubbleDiameter, bubbleDiameter)));
for(int x = 0; x < bubbleDiameter; x++) {
for(int y = 0; y < bubbleDiameter; y++) {
float radius = std::sqrt((bubbleRadius - x)*(bubbleRadius - x) + (bubbleRadius - y)*(bubbleRadius - y));
float intensity = stdext::clamp<float>((bubbleRadius - radius) / (float)(bubbleRadius - centerRadius), 0.0f, 1.0f);
// light intensity varies inversely with the square of the distance
intensity = intensity * intensity;
uint8_t colorByte = intensity * 0xff;
uint8_t pixel[4] = {colorByte,colorByte,colorByte,0xff};
lightImage->setPixel(x, y, pixel);
}
}
TexturePtr tex = TexturePtr(new Texture(lightImage, true));
tex->setSmooth(true);
return tex;
}
示例15: info
/** Create object from file.
* If file or file+.mhd exists, use this,
* Otherwise assume input is split over several
* files and try to load all mhdFile + i + ".mhd".
* forall i.
*/
USFrameDataPtr USFrameData::create(QString inputFilename)
{
QFileInfo info(inputFilename);
TimeKeeper timer;
QString mhdSingleFile = info.absolutePath()+"/"+info.completeBaseName()+".mhd";
if (QFileInfo(mhdSingleFile).exists())
{
vtkImageDataPtr image = MetaImageReader().loadVtkImageData(mhdSingleFile);
// load from single file
USFrameDataPtr retval = USFrameData::create(ImagePtr(new Image(mhdSingleFile, image)));
retval->mName = QFileInfo(mhdSingleFile).completeBaseName();
timer.printElapsedms(QString("Loading single %1").arg(inputFilename));
return retval;
}
else
{
USFrameDataPtr retval(new USFrameData());
retval->mName = QFileInfo(inputFilename).completeBaseName();
retval->mImageContainer.reset(new cx::CachedImageDataContainer(inputFilename, -1));
retval->resetRemovedFrames();
return retval;
}
}