本文整理汇总了C++中ImageView类的典型用法代码示例。如果您正苦于以下问题:C++ ImageView类的具体用法?C++ ImageView怎么用?C++ ImageView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ImageView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Page
Page *CascadesCookbookApp::createRecipePage()
{
Page *recipeListPage = new Page();
// Create the main app Container and set a DockLayout which is used to align children
Container *recipeListContainer = new Container();
DockLayout *recipeListLayout = new DockLayout();
recipeListContainer->setLayout(recipeListLayout);
// A nine-sliced book image is used as background of the cookbook.
ImageView *backgroundImage = ImageView::create("asset:///images/Book_background.amd");
backgroundImage->setVerticalAlignment(VerticalAlignment::Fill);
backgroundImage->setHorizontalAlignment(HorizontalAlignment::Fill);
// Create and set up a Container for the list
Container *cookbookContainer = new Container();
cookbookContainer->setTopPadding(15.0f);
cookbookContainer->setBottomPadding(15.0f);
cookbookContainer->setLayout(new DockLayout());
cookbookContainer->setHorizontalAlignment(HorizontalAlignment::Fill);
// Set up and create the ListView for the recipe list
mRecipeListView = createRecipeListView();
mRecipeListView->setHorizontalAlignment(HorizontalAlignment::Fill);
// Add the controls
cookbookContainer->add(mRecipeListView);
recipeListContainer->add(backgroundImage);
recipeListContainer->add(cookbookContainer);
recipeListPage->setContent(recipeListContainer);
return recipeListPage;
}
示例2:
bool UIImageViewTest_Scale9::init()
{
if (UIScene::init())
{
Size widgetSize = _widget->getContentSize();
Text* alert = Text::create("ImageView scale9 render", "fonts/Marker Felt.ttf", 26);
alert->setColor(Color3B(159, 168, 176));
alert->setPosition(Vec2(widgetSize.width / 2.0f,
widgetSize.height / 2.0f - alert->getContentSize().height * 2.125f));
_uiLayer->addChild(alert);
// Create the imageview
ImageView* imageView = ImageView::create("cocosui/buttonHighlighted.png");
imageView->setScale9Enabled(true);
imageView->setContentSize(Size(200, 115));
imageView->setPosition(Vec2(widgetSize.width / 2.0f - 100,
widgetSize.height / 2.0f));
_uiLayer->addChild(imageView);
auto imageCopy = imageView->clone();
imageCopy->setPosition(Vec2(widgetSize.width / 2.0f + 100,
widgetSize.height / 2.0f));
_uiLayer->addChild(imageCopy);
return true;
}
return false;
}
示例3: isSolidSync
Handle<Value> ImageView::isSolid(const Arguments& args)
{
HandleScope scope;
ImageView* im = node::ObjectWrap::Unwrap<ImageView>(args.This());
if (args.Length() == 0) {
return isSolidSync(args);
}
// ensure callback is a function
Local<Value> callback = args[args.Length()-1];
if (!args[args.Length()-1]->IsFunction())
return ThrowException(Exception::TypeError(
String::New("last argument must be a callback function")));
is_solid_image_view_baton_t *closure = new is_solid_image_view_baton_t();
closure->request.data = closure;
closure->im = im;
closure->result = true;
closure->pixel = 0;
closure->error = false;
closure->cb = Persistent<Function>::New(Handle<Function>::Cast(callback));
uv_queue_work(uv_default_loop(), &closure->request, EIO_IsSolid, (uv_after_work_cb)EIO_AfterIsSolid);
im->Ref();
return Undefined();
}
示例4: x
Handle<Value> ImageView::getPixel(const Arguments& args)
{
HandleScope scope;
unsigned x(0);
unsigned y(0);
if (args.Length() >= 2) {
if (!args[0]->IsNumber())
return ThrowException(Exception::TypeError(
String::New("first arg, 'x' must be an integer")));
if (!args[1]->IsNumber())
return ThrowException(Exception::TypeError(
String::New("second arg, 'y' must be an integer")));
x = args[0]->IntegerValue();
y = args[1]->IntegerValue();
} else {
return ThrowException(Exception::TypeError(
String::New("must supply x,y to query pixel color")));
}
ImageView* im = ObjectWrap::Unwrap<ImageView>(args.This());
image_view_ptr view = im->get();
if (x < view->width() && y < view->height())
{
mapnik::image_view<mapnik::image_data_32>::pixel_type const * row = view->getRow(y);
mapnik::image_view<mapnik::image_data_32>::pixel_type const pixel = row[x];
unsigned r = pixel & 0xff;
unsigned g = (pixel >> 8) & 0xff;
unsigned b = (pixel >> 16) & 0xff;
unsigned a = (pixel >> 24) & 0xff;
return Color::New(mapnik::color(r,g,b,a));
}
示例5: init
bool UIImageViewTest::init()
{
if (UIScene::init())
{
Size widgetSize = _widget->getContentSize();
Text* alert = Text::create("ImageView", "fonts/Marker Felt.ttf", 30);
alert->setColor(Color3B(159, 168, 176));
alert->setPosition(Vec2(widgetSize.width / 2.0f,
widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
_uiLayer->addChild(alert);
// Create the imageview
ImageView* imageView = ImageView::create("cocosui/ccicon.png");
imageView->setPosition(Vec2(widgetSize.width / 2.0f,
widgetSize.height / 2.0f));
_uiLayer->addChild(imageView);
return true;
}
return false;
}
示例6: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
ImageView w;
w.show();
a.exec();
}
示例7: init
bool UIPageViewTest::init()
{
if (UIScene::init())
{
Size widgetSize = _widget->getSize();
// Add a label in which the dragpanel events will be displayed
_displayValueLabel = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32);
_displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
_displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f,
widgetSize.height / 2.0f +
_displayValueLabel->getContentSize().height * 1.5));
_uiLayer->addChild(_displayValueLabel);
// Add the black background
Text* alert = Text::create("PageView", "fonts/Marker Felt.ttf", 30);
alert->setColor(Color3B(159, 168, 176));
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
_uiLayer->addChild(alert);
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel"));
// Create the page view
PageView* pageView = PageView::create();
pageView->setSize(Size(240.0f, 130.0f));
Size backgroundSize = background->getContentSize();
pageView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
(backgroundSize.width - pageView->getSize().width) / 2.0f,
(widgetSize.height - backgroundSize.height) / 2.0f +
(backgroundSize.height - pageView->getSize().height) / 2.0f));
for (int i = 0; i < 3; ++i)
{
Layout* layout = Layout::create();
layout->setSize(Size(240.0f, 130.0f));
ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png");
imageView->setScale9Enabled(true);
imageView->setSize(Size(240, 130));
imageView->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
layout->addChild(imageView);
Text* label = Text::create(StringUtils::format("page %d",(i+1)), "fonts/Marker Felt.ttf", 30);
label->setColor(Color3B(192, 192, 192));
label->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
layout->addChild(label);
pageView->addPage(layout);
}
pageView->addEventListener(CC_CALLBACK_2(UIPageViewTest::pageViewEvent, this));
_uiLayer->addChild(pageView);
return true;
}
return false;
}
示例8: gaussian_pyramid
ImagePyramid<T>
gaussian_pyramid(const ImageView<T>& image,
const ImagePyramidParams& params = ImagePyramidParams())
{
using Scalar = typename ImagePyramid<T>::scalar_type;
// Resize the image with the appropriate factor.
auto resize_factor = pow(2.f, -params.first_octave_index());
auto I = enlarge(image, resize_factor);
// Deduce the new camera sigma with respect to the dilated image.
auto camera_sigma = Scalar(params.scale_camera())*resize_factor;
// Blur the image so that its new sigma is equal to the initial sigma.
auto init_sigma = Scalar(params.scale_initial());
if (camera_sigma < init_sigma)
{
Scalar sigma = sqrt(init_sigma*init_sigma - camera_sigma*camera_sigma);
I = gaussian(I, sigma);
}
// Deduce the maximum number of octaves.
auto l = std::min(image.width(), image.height());
auto b = params.image_padding_size();
// l/2^k > 2b
// 2^k < l/(2b)
// k < log(l/(2b))/log(2)
auto num_octaves = static_cast<int>(log(l/(2.f*b))/log(2.f));
// Shorten names.
auto k = Scalar(params.scale_geometric_factor());
auto num_scales = params.num_scales_per_octave();
auto downscale_index = int( floor( log(Scalar(2))/log(k)) );
// Create the image pyramid
auto G = ImagePyramid<T>{};
G.reset(num_octaves, num_scales, init_sigma, k);
for (auto o = 0; o < num_octaves; ++o)
{
// Compute the octave scaling factor
G.octave_scaling_factor(o) =
(o == 0) ? 1.f/resize_factor : G.octave_scaling_factor(o-1)*2;
// Compute the gaussians in octave \f$o\f$
Scalar sigma_s_1 = init_sigma;
G(0, o) = o == 0 ? I : downscale(G(downscale_index, o - 1), 2);
for (auto s = 1; s < num_scales; ++s)
{
auto sigma = sqrt(k*k*sigma_s_1*sigma_s_1 - sigma_s_1*sigma_s_1);
G(s,o) = gaussian(G(s-1,o), sigma);
sigma_s_1 *= k;
}
}
// Done!
return G;
}
示例9: init
bool UIImageViewTest::init()
{
if (UIScene::init())
{
Size widgetSize = _widget->getSize();
Text* alert = Text::create();
alert->setText("ImageView");
alert->setFontName("Marker Felt");
alert->setFontSize(30);
alert->setColor(Color3B(159, 168, 176));
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
_uiLayer->addChild(alert);
// Create the imageview
ImageView* imageView = ImageView::create();
imageView->loadTexture("cocosgui/ccicon.png");
imageView->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + imageView->getSize().height / 4.0f));
// imageView->setOpacity(64);
_uiLayer->addChild(imageView);
/*
NodeRGBA* root = NodeRGBA::create();
root->setCascadeOpacityEnabled(true);
NodeRGBA* render = Sprite::create();
static_cast<Sprite*>(render)->setTexture("cocosgui/ccicon.png");
root->addChild(render);
// root->setOpacity(64);
root->setPosition(Point(200, 180));
_uiLayer->addChild(root);
*/
/*
NodeRGBA* nodergba = NodeRGBA::create();
Sprite* child = Sprite::create();
child->setTexture("cocosgui/ccicon.png");
nodergba->addChild(child);
nodergba->setPosition(Point(120, 80));
nodergba->setOpacity(64);
_uiLayer->addChild(nodergba);
*/
/*
Sprite* sprite = Sprite::create();
sprite->setTexture("cocosgui/ccicon.png");
sprite->setPosition(Point(200, 180));
// sprite->setOpacity(64);
_uiLayer->addChild(sprite);
*/
// imageView->setLocalZOrder(20);
return true;
}
return false;
}
示例10: intiData
void intiData(){
people = loadPUBModel("resources/456.BINARY",m_pd3dDevice,m_pImmediateContext);
// Initialize the world matrix
m_World = XMMatrixIdentity();
// Initialize the view matrix
XMVECTOR Eye = XMVectorSet( 0, 1.1, -2.0, 0.0f );
XMVECTOR At = XMVectorSet( 0.0f, 1.1, 0.0f, 0.0f );
XMVECTOR Up = XMVectorSet( 0.0f, 1.0f, 0.0f, 0.0f );
m_View = XMMatrixLookAtLH( Eye, At, Up );
// Initialize the projection matrix
m_Projection = XMMatrixPerspectiveFovLH( XM_PIDIV4, getWindowWidth() / (FLOAT)getWindowHeight(), 0.01f, 1000.0f );
m_Projection = XMMatrixOrthographicLH(4,4*getWindowHeight()/(FLOAT)getWindowWidth(),0,100);
bone_shader =new ShaderProgram(m_pd3dDevice);
bone_shader->setLayout(CUSTOM_LAYOUT_PUB,CUSTOM_LAYOUT_PUB_NUM);
bone_shader->requestConstantBuffer(192,0);
bone_shader->requestConstantBuffer(sizeof(XMMATRIX)*BONE_MAX_NUM,1);
bone_shader->loadShader(L"FX/boneAnime.fx");
people->useShader(bone_shader);
Sampler* samp=new Sampler(m_pd3dDevice);
samp->createSampleState(D3D11_FILTER_MIN_MAG_MIP_LINEAR,D3D11_TEXTURE_ADDRESS_WRAP,-1);
samp->useSamplerAt(m_pImmediateContext,0);
// MyLuaManager::getInstance()->registerFun(ConsleGlue);
/***********************************************************************/
view_shader= new ShaderProgram(m_pd3dDevice);
view_shader->setLayout(CUSTOM_LAYOUT_PU,CUSTOM_LAYOUT_PU_NUM);
view_shader->requestConstantBuffer(192,0);
view_shader->loadShader(L"FX/Tutorial04.fx");
quard=new ImageView(m_pd3dDevice);
quard->setBorder(getWindowWidth(),getWindowHeight());
quard->setSize(200,150);
quard->setShader(view_shader);
backTarget=RenderTarget::generateRenderTarget(m_pd3dDevice,getWindowWidth(),getWindowHeight());
quard->setTexture(*backTarget->getShaderResource());
/**********************************************************************/
setDrawMode(Triangle);
/*********************************************************************/
controller=new ObjectController(m_pd3dDevice);
controller->addObject(quard);
}
示例11: setItemData
//设置单个模版的数据显示
void Gate::setItemData(Widget*item,PGateItem gateItem)
{
Text*desTxt=static_cast<Text*>(item->getChildByName("desTxt"));
Label* desLabel = static_cast<Label*>(desTxt->getVirtualRenderer());
desLabel->enableOutline(Color4B::BLACK,1);
//此处需要判断是否有倒计时,没有倒计时就隐藏此文本,否则具体显示倒计时(策划说以后会有个事件表,从里面读取时间)
ImageView* items = static_cast<ImageView*>(item);
items->loadTexture("Level Select_Book_A"+Value(this->currentType).asString()+".png");
}
示例12: ImageView
ImageView* ImageView::create()
{
ImageView* widget = new ImageView();
if (widget && widget->init())
{
widget->autorelease();
return widget;
}
CC_SAFE_DELETE(widget);
return NULL;
}
示例13: connect
/**
* App::onImageLoaded(QString url, bool success, QString response)
*
* Handle the result of a loading image request.
*
* Basing on the result, we will update UI accordingly.
*
* --url, the url of the previous url
* --success, the flag to indicate if the request was successful.
* --response, this will carry some error information if the operation was not successful.
*
*/
void App::onImageLoaded(QString url, bool success, QString response)
{
//get the LoadImage object
LoadImage* img = qobject_cast<LoadImage*>(sender());
if (!img)
{
return;
}
connect(this, SIGNAL(finishUpdateImage()), img, SIGNAL(finishThread()));
qDebug() << "Download complete: " << url;
//find the url to photo index mapping
QMap<QString, int>::iterator it = m_imageMap.find(url);
if (it != m_imageMap.end())
{
//stop indicator
ActivityIndicator* activityId = m_root->findChild<ActivityIndicator*>(QString("image%1Indicator").arg(it.value()));
if (activityId)
{
activityId->stop();
activityId->setVisible(false);
}
if (success)
{
//show the image
ImageView* imageView = m_root->findChild<ImageView*>(QString("image%1").arg(it.value()));
if (imageView)
{
QImage qm = img->getImage().rgbSwapped().scaled(768, 500, Qt::KeepAspectRatioByExpanding); //resize image to fit container
bb::cascades::PixelBufferData pb = bb::cascades::PixelBufferData(PixelBufferData::RGBX, qm.width(), qm.height(), qm.width(), qm.bits());
bb::cascades::Image image(pb);
imageView->setImage(image);
imageView->setVisible(true);
}
}
else
{
//show the label with the error from the retrieval
Label* imageLabel = m_root->findChild<Label*>(QString("image%1Label").arg(it.value()));
if (imageLabel)
{
imageLabel->setText(response);
imageLabel->setVisible(true);
}
}
m_imageMap.erase(it);
}
emit finishUpdateImage();
// no need to explicitly delete img, it has been destroyed when receiving the "finishThread" signal
}
示例14: new
ImageView* ImageView::create()
{
ImageView* widget = new (std::nothrow) ImageView();
if (widget && widget->init())
{
widget->autorelease();
return widget;
}
CC_SAFE_DELETE(widget);
return nullptr;
}
示例15: init
bool UIScrollViewTest_Both::init()
{
if (UIScene::init())
{
Size widgetSize = _widget->getContentSize();;
// Add a label in which the dragpanel events will be displayed
_displayValueLabel = Text::create("Move by any direction","fonts/Marker Felt.ttf",32);
_displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
_displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
_uiLayer->addChild(_displayValueLabel);
// Add the alert
Text* alert = Text::create("ScrollView both","fonts/Marker Felt.ttf",30);
alert->setColor(Color3B(159, 168, 176));
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
_uiLayer->addChild(alert);
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
Layout* background = static_cast<Layout*>(root->getChildByName("background_Panel"));
// Create the dragpanel
ui::ScrollView* scrollView = ui::ScrollView::create();
scrollView->setDirection(ui::ScrollView::Direction::BOTH);
scrollView->setTouchEnabled(true);
scrollView->setBounceEnabled(true);
scrollView->setBackGroundImageScale9Enabled(true);
scrollView->setBackGroundImage("cocosui/green_edit.png");
scrollView->setContentSize(Size(210, 122.5));
scrollView->setScrollBarWidth(4);
scrollView->setScrollBarPositionFromCorner(Vec2(6, 6));
Size backgroundSize = background->getContentSize();
scrollView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
(backgroundSize.width - scrollView->getContentSize().width) / 2.0f,
(widgetSize.height - backgroundSize.height) / 2.0f +
(backgroundSize.height - scrollView->getContentSize().height) / 2.0f));
ImageView* imageView = ImageView::create("Hello.png");
scrollView->addChild(imageView);
scrollView->setInnerContainerSize(imageView->getContentSize());
Size innerSize = scrollView->getInnerContainerSize();
imageView->setPosition(Vec2(innerSize.width / 2.0f, innerSize.height / 2.0f));
_uiLayer->addChild(scrollView);
// Jump to right bottom
scrollView->jumpToBottomRight();
return true;
}
return false;
}