本文整理汇总了C++中CAImage::getPixelsWide方法的典型用法代码示例。如果您正苦于以下问题:C++ CAImage::getPixelsWide方法的具体用法?C++ CAImage::getPixelsWide怎么用?C++ CAImage::getPixelsWide使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAImage
的用法示例。
在下文中一共展示了CAImage::getPixelsWide方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dumpCachedImageInfo
void CAImageCache::dumpCachedImageInfo()
{
unsigned int count = 0;
unsigned int totalBytes = 0;
CAMap<std::string, CAImage*>::iterator itr;
for (itr=m_mImages.begin(); itr!=m_mImages.end(); itr++)
{
CAImage* image = itr->second;
unsigned int bpp = image->bitsPerPixelForFormat();
// Each texture takes up width * height * bytesPerPixel bytes.
unsigned int bytes = image->getPixelsWide() * image->getPixelsHigh() * bpp / 8;
totalBytes += bytes;
count++;
CCLog("CrossApp: \"%s\" rc=%lu id=%lu %lu x %lu @ %ld bpp => %lu KB",
itr->first.c_str(),
(long)image->retainCount(),
(long)image->getName(),
(long)image->getPixelsWide(),
(long)image->getPixelsHigh(),
(long)bpp,
(long)bytes / 1024);
}
CCLog("CrossApp: CAImageCache dumpDebugInfo: %ld images, for %lu KB (%.2f MB)", (long)count, (long)totalBytes / 1024, totalBytes / (1024.0f*1024.0f));
}
示例2: init
bool CATextView::init()
{
if (!CAView::init())
{
return false;
}
this->setColor(CAColor_clear);
CAImage* image = CAImage::create("source_material/textField_bg.png");
DRect capInsets = DRect(image->getPixelsWide()/2 ,image->getPixelsHigh()/2 , 1, 1);
m_pBackgroundView = CAScale9ImageView::createWithImage(image);
m_pBackgroundView->setCapInsets(capInsets);
m_pBackgroundView->setImage(image);
this->insertSubview(m_pBackgroundView, -1);
m_pShowImageView = CAImageView::createWithFrame(DRect(0, 0, 1, 1));
m_pShowImageView->setTextTag("textView");
this->addSubview(m_pShowImageView);
CATextViewWin32 *text = new CATextViewWin32(this);
text->initWithFrame(DRect(0, 0, 1, 1));
text->autorelease();
this->addSubview(text);
m_pTextView = (CATextViewWin32*)text;
return true;
}
示例3: init
bool CATextField::init()
{
if (!CAView::init())
{
return false;
}
this->setColor(CAColor_clear);
CAImage* image = CAImage::create("source_material/textField_bg.png");
m_pBackgroundView = CAScale9ImageView::createWithFrame(DRect(0, 0, 1, 1));
m_pBackgroundView->setLayout(DLayoutFill);
m_pBackgroundView->setCapInsets(DRect(image->getPixelsWide() / 2, image->getPixelsHigh() / 2, 1, 1));
m_pBackgroundView->setImage(image);
this->addSubview(m_pBackgroundView);
CATextFieldWin32 *text = new CATextFieldWin32(this);
text->initWithFrame(DRect(0, 0, 1, 1));
this->addSubview(text);
text->release();
m_pTextField = (CATextFieldWin32*)text;
return true;
}
示例4: setImageCoords
void CAView::setImageCoords(DRect rect)
{
CAImage* image = m_pobBatchView ? m_pobImageAtlas->getImage() : m_pobImage;
CC_RETURN_IF(! image);
float atlasWidth = (float)image->getPixelsWide();
float atlasHeight = (float)image->getPixelsHigh();
float left, right, top, bottom;
if (m_bRectRotated)
{
#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
left = (2 * rect.origin.x + 1) / (2 * atlasWidth);
right = left + (rect.size.height * 2 - 2) / (2 * atlasWidth);
top = (2 * rect.origin.y + 1) / (2 * atlasHeight);
bottom = top + (rect.size.width * 2 - 2) / (2 * atlasHeight);
#else
left = rect.origin.x / atlasWidth;
right = (rect.origin.x + rect.size.height) / atlasWidth;
top = rect.origin.y / atlasHeight;
bottom = (rect.origin.y + rect.size.width) / atlasHeight;
#endif // CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
if (m_bFlipX)
{
CC_SWAP(top, bottom, float);
}
if (m_bFlipY)
{
CC_SWAP(left, right, float);
}
m_sQuad.bl.texCoords.u = left;
m_sQuad.bl.texCoords.v = top;
m_sQuad.br.texCoords.u = left;
m_sQuad.br.texCoords.v = bottom;
m_sQuad.tl.texCoords.u = right;
m_sQuad.tl.texCoords.v = top;
m_sQuad.tr.texCoords.u = right;
m_sQuad.tr.texCoords.v = bottom;
}
else
{
#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
left = (2 * rect.origin.x + 1) / (2 * atlasWidth);
right = left + (rect.size.width * 2 - 2) / (2 * atlasWidth);
top = (2 * rect.origin.y + 1) / (2 * atlasHeight);
bottom = top + (rect.size.height * 2 - 2) / (2 * atlasHeight);
#else
left = rect.origin.x / atlasWidth;
right = (rect.origin.x + rect.size.width) / atlasWidth;
top = rect.origin.y / atlasHeight;
bottom = (rect.origin.y + rect.size.height) / atlasHeight;
#endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
if(m_bFlipX)
{
CC_SWAP(left, right, float);
}
if(m_bFlipY)
{
CC_SWAP(top, bottom, float);
}
m_sQuad.bl.texCoords.u = left;
m_sQuad.bl.texCoords.v = bottom;
m_sQuad.br.texCoords.u = right;
m_sQuad.br.texCoords.v = bottom;
m_sQuad.tl.texCoords.u = left;
m_sQuad.tl.texCoords.v = top;
m_sQuad.tr.texCoords.u = right;
m_sQuad.tr.texCoords.v = top;
}
}