本文整理汇总了C++中Pixmap::height方法的典型用法代码示例。如果您正苦于以下问题:C++ Pixmap::height方法的具体用法?C++ Pixmap::height怎么用?C++ Pixmap::height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pixmap
的用法示例。
在下文中一共展示了Pixmap::height方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2:
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);
}
示例3: normal
Icon::Icon(const Pixmap &pm, SpritesHolder &h) : normal(h.load(pm)) {
Pixmap d = Pixmap(pm.width(),pm.height(),pm.hasAlpha());
const uint8_t* p = pm.const_data();
if(pm.hasAlpha()){
for(int r=0; r<pm.height(); ++r)
for(int i=0; i<pm.width(); ++i){
//0.299, 0.587, 0.114
uint8_t cl = uint8_t(p[0]*0.299 + p[1]*0.587 + p[2]*0.114);
d.set(i,r,Pixmap::Pixel{cl,cl,cl,p[3]});
p += 4;
}
} else {
for(int r=0; r<pm.height(); ++r)
for(int i=0; i<pm.width(); ++i){
//0.299, 0.587, 0.114
uint8_t cl = uint8_t(p[0]*0.299 + p[1]*0.587 + p[2]*0.114);
d.set(i,r,Pixmap::Pixel{cl,cl,cl,255});
p += 3;
}
}
disabled = h.load(d);
}
示例4: 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;
}
示例5: 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;
}