本文整理汇总了C++中Pixmap类的典型用法代码示例。如果您正苦于以下问题:C++ Pixmap类的具体用法?C++ Pixmap怎么用?C++ Pixmap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pixmap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: snapshot
bool RGLView::snapshot(PixmapFileFormatID formatID, const char* filename)
{
bool success = false;
if ( (formatID < PIXMAP_FILEFORMAT_LAST) && (pixmapFormat[formatID])
&& windowImpl->beginGL() ) {
// alloc pixmap memory
Pixmap snapshot;
snapshot.init(RGB24, width, height, 8);
// read front buffer
glPushAttrib(GL_PIXEL_MODE_BIT);
glReadBuffer(GL_FRONT);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0,0,width,height,GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*) snapshot.data);
glPopAttrib();
success = snapshot.save( pixmapFormat[formatID], filename );
windowImpl->endGL();
}
return success;
}
示例2: gtprintf
void gtprintf(const Font& fnt, const Pixmap& texture, char *fmt, ...)
{
va_list ap;
uint32 x, y;
int len;
char ch;
Pixmap *glyph;
va_start(ap, fmt);
vsprintf(gtBuffer, fmt, ap);
va_end(ap);
len = strlen(gtBuffer);
for(int i = 0; i < len; i++)
{
ch = gtBuffer[i];
if(ch == '\n') gtY += fnt.nl_height;
else if(ch == '\r') gtX = 0;
else
{
glyph = fnt.find_glyph(ch);
glyph->draw(gtX, gtY);
gtX += glyph->width();
if(gtX > 799)
{
gtX = 0;
gtY += fnt.nl_height;
}
}
}
}
示例3:
Pixmap::Pixmap(const Pixmap& other)
{
m_width= other.width();
m_height = other.height();
m_depth = other.depth();
m_bitmap = new U8[m_width * m_height * m_depth];
memcpy(m_bitmap, other.const_data(), m_width * m_height * m_depth);
}
示例4: draw
void Texture::draw (Pixmap& pixmap,int x,int y) {
if (data->isManaged()) {
gdx_cpp::Gdx::app->error(__FILE__ , "can't draw to a managed texture");
}
Gdx::gl->glBindTexture(GL_TEXTURE_2D, glHandle);
Gdx::gl->glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, pixmap.getWidth(), pixmap.getHeight(), pixmap.getGLFormat(),
pixmap.getGLType(), (const unsigned char*) pixmap.getPixels());
}
示例5: sp_draw
void Sprite::sp_draw()
{
Pixmap *pix = this->_sprite_pixmap;
if (pix)
{
int sx, sy;
pix->getframe(this->_sprite_frame, sx, sy);
pix->blit(this->_sprite_x, this->_sprite_y, this->_sprite_w, this->_sprite_h, sx, sy);
}
}
示例6: copy_rect_to
void Pixmap::copy_rect_to( const Rect& p_src_rect,Pixmap &p_pixmap,const Point& p_dst_pos ) const {
if (!_pp || !_pp->pixmap->is_valid())
return;
if (!p_pixmap._pp || !p_pixmap._pp->pixmap->is_valid())
return;
p_pixmap.copy_on_write();
_pp->pixmap->copy_rect_to( p_src_rect, p_pixmap.get_platform_pixmap(), p_dst_pos );
}
示例7: loadImage
void ImageLoader::loadImage(Texture *texture, Pixmap &image)
{
std::string ext = texture->getFile()->getExt();
ByteBufferPtr buf = texture->getFile()->read();
if (ext == "png") {
image.loadPNG(buf->getData(), buf->getSize());
} else {
image.loadJPEG(buf->getData(), buf->getSize());
}
}
示例8: applyAnimation
slideShowEngine::AnimationState slideShowEngine::applyAnimation()
{
effect e;
QEasingCurve curve;
qreal currentValue;
Pixmap *item;
if(m_currentStep==EnterAnimation)
e=m_currentNode.enterEffect();
else
if(m_currentStep==DisplayAnimation)
e=m_currentNode.displayEffect();
else
if(m_currentStep==ExitAnimation)
e=m_currentNode.exitEffect();
int duration=e.duration();
//int elapsed=m_stepCurrentTime;
curve.setPeriod(duration);
qreal startVal=qreal(e.startValue());
qreal endVal=qreal(e.endValue());
curve.setType(e.easingCurve());
//qreal valore=qreal(m_stepCurrentTime*TIMER_ANIMATION);
qreal valore=qreal(m_stepCurrentTime);
//qreal valore=qreal(m_stepCurrentTime*10);
valore=valore/(qreal(duration));
//valore=valore/10;
//currentValue=curve.valueForProgress(valore);
currentValue=endVal+(1.0-curve.valueForProgress(valore))*(startVal-endVal);
item=m_PixmapList[m_currentSlideIndex];
if(e.effectType()=="pos")
item->setProperty(e.effectType().toLatin1(),QVariant(QPointF(currentValue,0)));
else
item->setProperty(e.effectType().toLatin1(),QVariant(currentValue));
//if(m_stepCurrentTime*TIMER_ANIMATION < e.duration()/**10*/)
if(m_stepCurrentTime < duration)
//if(m_stepCurrentTime*10 < e.duration()/**10*/)
return RunningAnimation;
else
return EndAnimation;
}
示例9: loadTextures
void TextureManager::loadTextures()
{
for (auto pair : this->registeredTextures) {
Texture::ptr& texture = pair.second;
if (texture->getGlID() != 0) {
continue;
}
Pixmap image;
this->loader->loadImage(texture.get(), image);
texture->setSize(image.getWidth(), image.getHeight());
textureUtil.UploadTextureToHardware(image, *texture);
}
}
示例10: Pixmap
Pixmap* FileTextureData::ensurePot(Pixmap* pixmap)
{
if(!Gdx.isGL20Available() && copyToPOT)
{
int pixmapWidth = pixmap->getWidth();
int pixmapHeight = pixmap->getHeight();
int potWidth = MathUtils::nextPowerOfTwo(pixmapWidth);
int potHeight = MathUtils::nextPowerOfTwo(pixmapHeight);
if(pixmapWidth != potWidth || pixmapHeight != potHeight)
{
Pixmap* tmp = new Pixmap(potWidth, potHeight, pixmap->getFormat());
tmp->drawPixmap(pixmap, 0, 0, 0, 0, pixmapWidth, pixmapHeight);
pixmap->dispose();
delete pixmap;
return tmp;
}
}
return pixmap;
}
示例11: xortex
int xortex(Pixmap &map, const unsigned int width, const unsigned int height)
{
if (!width || !height)
return 1;
if(map.init(width, height))
return 2;
for(unsigned int j = 0; j < map.height(); j++) {
for(unsigned int i = 0; i < map.width(); i++) {
scalar_t val = (scalar_t)(i ^ j) / 255.0f;
ColorRGBAf &pixel = map.pixel(i, j);
pixel.r(val);
pixel.g(val);
pixel.b(val);
pixel.a(1.0f);
}
}
return 0;
}
示例12: ppm_raw
int ppm_raw(const char *filename, const Pixmap &fb)
{
if (!filename)
return 1;
if (!fb.width() || !fb.height())
return 3;
FILE *fp = fopen(filename, "wb");
if (fp == NULL)
return 2;
// Write the header.
fprintf(fp, "P6\n%d %d\n255\n", fb.width(), fb.height());
// Write the pixel data.
for (unsigned int j = 0; j < fb.height(); j++) {
for (unsigned int i = 0; i < fb.width(); i++) {
const ColorRGBAf &pixel = fb.pixel_ro(i, j);
// Do some basic tone mapping.
scalar_t fmax = 0.0f;
fmax = pixel.r() > fmax ? pixel.r() : fmax;
fmax = pixel.g() > fmax ? pixel.g() : fmax;
fmax = pixel.b() > fmax ? pixel.b() : fmax;
scalar_t scale = 1.f;
if (fmax > 1.f) {
scale = 1.f / fmax;
}
// Write the pixel.
fputc((char)(pixel.r() * scale * 255.0f), fp);
fputc((char)(pixel.g() * scale * 255.0f), fp);
fputc((char)(pixel.b() * scale * 255.0f), fp);
// Check for errors
if (ferror(fp)) {
fclose(fp);
return 2;
}
}
}
fclose(fp);
return 0;
}
示例13: applyIFS
void CompressedPixmap::applyIFS(Pixmap& pixmap, float ratio)
{
std::vector<Pixmap*> domainRegions;
for (unsigned int i = 0; i < m_domainRegions.size(); ++i)
domainRegions.push_back(pixmap.extract((int)(m_domainRegions[i].x * ratio), (int)(m_domainRegions[i].y * ratio), (int)(m_domainRegions[i].size * ratio)));
//We store each transformation
std::map<unsigned short, std::map<unsigned char, Pixmap*>> transformations;
for (const RangeRegionDescriptor& rangeRegion : m_rangeRegions)
{
int newSize = (int)(rangeRegion.size * ratio);
int newX = (int)(rangeRegion.x * ratio);
int newY = (int)(rangeRegion.y * ratio);
Pixmap* domainInUse;
//If this domainRegion has not been used already
if (!transformations.count(rangeRegion.domainRegionIndex))
{
domainInUse = domainRegions[rangeRegion.domainRegionIndex]->downscale(newSize);
transformations[rangeRegion.domainRegionIndex][0] = domainInUse;
}
else
domainInUse = transformations[rangeRegion.domainRegionIndex][0];
//If it is a true transformation
if (rangeRegion.transformation != NO_ROTATION)
{
//If it hasn't already been done
if (!transformations[rangeRegion.domainRegionIndex].count(rangeRegion.transformation))
{
domainInUse = domainInUse->applyTransformation(rangeRegion.transformation);
transformations[rangeRegion.domainRegionIndex][rangeRegion.transformation] = domainInUse;
}
else
domainInUse = transformations[rangeRegion.domainRegionIndex][rangeRegion.transformation];
}
//Then copy to range region
for (int x = 0; x < newSize; ++x)
{
for (int y = 0; y < newSize; ++y)
{
pixmap.set(newX + x, newY + y, domainInUse->get(x, y));
}
}
//Set first pixel value
if (rangeRegion.x % 4 == 0 && rangeRegion.y % 4 == 0)
pixmap.set(newX, newY, rangeRegion.firstPixelValue);
}
std::cout << transformations.size() * 100 / domainRegions.size() << std::endl;
for (const Pixmap* domainRegion : domainRegions)
delete domainRegion;
for (const std::pair<unsigned short, std::map<unsigned char, Pixmap*>>& transformedDomain : transformations)
{
for (const std::pair<unsigned char, Pixmap*>& transformationResult : transformedDomain.second)
delete transformationResult.second;
}
}
示例14: pixmapToCursor
static
HCURSOR pixmapToCursor( const Pixmap& pinput,
int hotSpotX,
int hotSpotY ) {
if( pinput.isEmpty() ) {
return 0;
}
Pixmap pm = pinput;
pm.setFormat( Pixmap::Format_RGBA );
ICONINFO iconInfo;
ZeroMemory(&iconInfo, sizeof(iconInfo));
iconInfo.fIcon = false;
iconInfo.xHotspot = hotSpotX;
iconInfo.yHotspot = hotSpotY;
HBITMAP hBitmap = 0;
HBITMAP hMonoBitmap = CreateBitmap( pm.width(), pm.height(), 1,1, NULL);
iconInfo.hbmMask = hMonoBitmap;
{
BITMAPV5HEADER bi;
ZeroMemory(&bi,sizeof(BITMAPV5HEADER));
bi.bV5Size = sizeof(BITMAPV5HEADER);
bi.bV5Width = pm.width();
bi.bV5Height = pm.height();
bi.bV5Planes = 1;
bi.bV5BitCount = 32;
bi.bV5Compression = BI_BITFIELDS;
// The following mask specification specifies a supported 32 BPP
// alpha format for Windows XP.
bi.bV5RedMask = 0x00FF0000;
bi.bV5GreenMask = 0x0000FF00;
bi.bV5BlueMask = 0x000000FF;
bi.bV5AlphaMask = 0xFF000000;
HDC hdc = GetDC(NULL);
uint8_t *lpBits;
const uint8_t* input = pm.const_data();
hBitmap = CreateDIBSection( hdc, (BITMAPINFO *)&bi, DIB_RGB_COLORS,
(void **)&lpBits, NULL, (DWORD)0 );
size_t bperRow = pm.width()*4;
for( int i=0; i<pm.height(); ++i ){
memcpy( lpBits + bperRow*i,
input + bperRow*(pm.height()-i-1),
bperRow );
}
size_t bsz = pm.width()*pm.height()*4;
for( size_t i=0; i<bsz; i+=4 ){
uint8_t a = *(lpBits+i);
*(lpBits+i) = *(lpBits+i+2);
*(lpBits+i+2) = a;
}
iconInfo.hbmColor = hBitmap;
}
HICON hicon = CreateIconIndirect(&iconInfo);
DeleteObject(hBitmap);
DeleteObject(hMonoBitmap);
return (HCURSOR)hicon;
}
示例15:
Texture2D::Texture2D(const Pixmap &pixmap)
: Texture2D(pixmap.getData().data(), pixmap.getInformation())
{}