本文整理汇总了C++中Pixmap::const_data方法的典型用法代码示例。如果您正苦于以下问题:C++ Pixmap::const_data方法的具体用法?C++ Pixmap::const_data怎么用?C++ Pixmap::const_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pixmap
的用法示例。
在下文中一共展示了Pixmap::const_data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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);
}
示例2: 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);
}
示例3: 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;
}