本文整理汇总了C++中wxBitmap::GetHBITMAP方法的典型用法代码示例。如果您正苦于以下问题:C++ wxBitmap::GetHBITMAP方法的具体用法?C++ wxBitmap::GetHBITMAP怎么用?C++ wxBitmap::GetHBITMAP使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxBitmap
的用法示例。
在下文中一共展示了wxBitmap::GetHBITMAP方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Create
// Create a drag image from a bitmap and optional cursor
bool wxDragImage::Create(const wxBitmap& image, const wxCursor& cursor)
{
if ( m_hImageList )
ImageList_Destroy(GetHimageList());
m_hImageList = 0;
#ifdef __WXWINCE__
UINT flags = ILC_COLOR;
#else
UINT flags wxDUMMY_INITIALIZE(0) ;
if (image.GetDepth() <= 4)
flags = ILC_COLOR4;
else if (image.GetDepth() <= 8)
flags = ILC_COLOR8;
else if (image.GetDepth() <= 16)
flags = ILC_COLOR16;
else if (image.GetDepth() <= 24)
flags = ILC_COLOR24;
else
flags = ILC_COLOR32;
#endif
bool mask = (image.GetMask() != 0);
// Curiously, even if the image doesn't have a mask,
// we still have to use ILC_MASK or the image won't show
// up when dragged.
// if ( mask )
flags |= ILC_MASK;
m_hImageList = (WXHIMAGELIST) ImageList_Create(image.GetWidth(), image.GetHeight(), flags, 1, 1);
int index;
if (!mask)
{
HBITMAP hBitmap1 = (HBITMAP) image.GetHBITMAP();
index = ImageList_Add(GetHimageList(), hBitmap1, 0);
}
else
{
HBITMAP hBitmap1 = (HBITMAP) image.GetHBITMAP();
HBITMAP hBitmap2 = (HBITMAP) image.GetMask()->GetMaskBitmap();
HBITMAP hbmpMask = wxInvertMask(hBitmap2);
index = ImageList_Add(GetHimageList(), hBitmap1, hbmpMask);
::DeleteObject(hbmpMask);
}
if ( index == -1 )
{
wxLogError(_("Couldn't add an image to the image list."));
}
m_cursor = cursor; // Can only combine with drag image after calling BeginDrag.
return (index != -1) ;
}
示例2: TempCreateXpm
void TempCreateXpm( wxBitmap &bmp, const char *name )
{
static char codes[] = " .-,`~{}=+&$*@#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
static int reds[1000];
static int greens[1000];
static int blues[1000];
int nbr_of=0;
static char filename[100];
sprintf( filename, "%s.xpm", name );
// Get dimensions of the wxBitmap
//bmp.GetBitmap( &info );
BITMAP info;
::GetObject( bmp.GetHBITMAP(), sizeof(BITMAP), &info ); //@@
int width_bytes = info.bmWidthBytes; // bytes
int width = info.bmWidth; // pixels
assert( (info.bmWidthBytes%info.bmWidth) == 0 );
int density = info.bmWidthBytes/info.bmWidth;
int height = info.bmHeight;
byte *buf_bmp;
buf_bmp = new byte[width_bytes*height];
memset( buf_bmp, 0, width_bytes*height);
::GetBitmapBits((HBITMAP)(bmp.GetHBITMAP()), width_bytes*height, buf_bmp );
FILE *f;
f = fopen(filename,"wt");
if( f )
{
byte r,g,b, *p;
int row,col;
for( row=0; row<height; row++ )
{
p = buf_bmp + row*width_bytes;
for( col=0; col<width; col++ )
{
byte *q = p;
b = *p++;
g = *p++;
r = *p++;
p = q+density;
bool found = false;
for( int i=0; !found && i<nbr_of; i++ )
{
if( reds[i]==r && greens[i]==g && blues[i]==b )
found = true;
}
if( !found )
{
reds [nbr_of] = r;
greens[nbr_of] = g;
blues [nbr_of] = b;
if( nbr_of+1 < nbrof(codes)-1 )
nbr_of++;
}
}
}
/* for( int i=0; i<nbr_of; i++ )
{
double d1 = ((double)reds[i]);
double d2 = ((double)greens[i]);
double d3 = ((double)blues[i]);
double d = d1*d1 + d2*d2 + d3*d3;
double max_so_far = 0.0;
int max_so_far_idx = 0;
for( int j=i+1; j<nbr_of; j++ )
{
double e1 = ((double)reds[j]);
double e2 = ((double)greens[j]);
double e3 = ((double)blues[j]);
double e = e1*e1 + e2*e2 + e3*e3;
if( e > max_so_far )
{
max_so_far = e;
max_so_far_idx = j;
}
}
if( max_so_far > d )
{
int j = max_so_far_idx;
int temp = reds[i];
reds[i] = reds[j];
reds[j] = temp;
temp = greens[i];
greens[i] = greens[j];
greens[j] = temp;
temp = blues[i];
blues[i] = blues[j];
blues[j] = temp;
}
static char specials[] = " .-,`~{}=+&$*@#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
if( reds[i]==0xff && blues[i]==0 && greens[i]==0 )
codes[i] = 'R';
else if( reds[i]==0 && blues[i]==0 && greens[i]==0xff )
codes[i] = 'G';
else if( reds[i]==0 && blues[i]==0xff && greens[i]==0 )
codes[i] = 'B';
else if( i >= strlen(specials) )
codes[i] = 'a' + (i-strlen(specials));
else
codes[i] = specials[i];
} */
//.........这里部分代码省略.........
示例3: DoSelect
void wxMemoryDCImpl::DoSelect(
const wxBitmap& rBitmap
)
{
//
// Select old bitmap out of the device context
//
if (m_hOldBitmap)
{
::GpiSetBitmap(m_hPS, NULLHANDLE);
if (m_vSelectedBitmap.IsOk())
{
m_vSelectedBitmap.SetSelectedInto(NULL);
m_vSelectedBitmap = wxNullBitmap;
}
}
//
// Check for whether the bitmap is already selected into a device context
//
wxCHECK_RET( !rBitmap.GetSelectedInto() ||
(rBitmap.GetSelectedInto() == GetOwner()),
wxT("Bitmap is selected in another wxMemoryDC, delete the first wxMemoryDC or use SelectObject(NULL)") );
WXHBITMAP hBmp = rBitmap.GetHBITMAP();
if (!hBmp)
{
//
// Bmps drawn to are upside down, so flip it before committing
//
POINTL vPoint[4] = { {0, m_vSelectedBitmap.GetHeight()}
,{m_vSelectedBitmap.GetWidth(), 0}
,{0, 0}
,{m_vSelectedBitmap.GetWidth(), m_vSelectedBitmap.GetHeight()}
};
::GpiBitBlt( m_hPS
,m_hPS
,4
,vPoint
,ROP_SRCCOPY
,BBO_IGNORE
);
m_vSelectedBitmap.SetSelectedInto(NULL);
}
m_vSelectedBitmap = rBitmap;
if (!hBmp)
{
m_hOldBitmap = (WXHBITMAP)::GpiSetBitmap(m_hPS, NULLHANDLE);
return;
}
m_vSelectedBitmap.SetSelectedInto(GetOwner());
m_hOldBitmap = (WXHBITMAP)::GpiSetBitmap(m_hPS, (HBITMAP)hBmp);
if (m_hOldBitmap == HBM_ERROR)
{
wxLogLastError(wxT("SelectObject(memDC, bitmap)"));
wxFAIL_MSG(wxT("Couldn't select a bitmap into wxMemoryDC"));
}
} // end of wxMemoryDC::SelectObject
示例4: CopyFromBitmap
void wxIcon::CopyFromBitmap(
const wxBitmap& rBmp
)
{
wxMask* pMask = rBmp.GetMask();
HBITMAP hBmp = NULLHANDLE;
HBITMAP hBmpMask = NULLHANDLE;
HBITMAP hOldBitmap = NULLHANDLE;
ERRORID vError;
wxString sError;
LONG lHits;
if (!pMask)
{
//
// We must have a mask for an icon, so even if it's probably incorrect,
// do create it (grey is the "standard" transparent colour)
//
pMask = new wxMask( rBmp
,*wxLIGHT_GREY
);
}
BITMAPINFOHEADER2 vHeader;
SIZEL vSize = {0, 0};
DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
HDC hDCSrc = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDop, NULLHANDLE);
HDC hDCDst = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDop, NULLHANDLE);
HPS hPSSrc = ::GpiCreatePS(vHabmain, hDCSrc, &vSize, PU_PELS | GPIA_ASSOC);
HPS hPSDst = ::GpiCreatePS(vHabmain, hDCDst, &vSize, PU_PELS | GPIA_ASSOC);
POINTL vPoint[4] = { {0, 0}, {rBmp.GetWidth(), rBmp.GetHeight()},
{0, 0}, {rBmp.GetWidth(), rBmp.GetHeight()}
};
POINTL vPointMask[4] = { {0, 0}, {rBmp.GetWidth(), rBmp.GetHeight() * 2},
{0, 0}, {rBmp.GetWidth(), rBmp.GetHeight()}
};
POINTERINFO vIconInfo;
memset(&vIconInfo, '\0', sizeof(POINTERINFO));
vIconInfo.fPointer = FALSE; // we want an icon, not a pointer
memset(&vHeader, '\0', 16);
vHeader.cbFix = 16;
vHeader.cx = (ULONG)rBmp.GetWidth();
vHeader.cy = (ULONG)rBmp.GetHeight();
vHeader.cPlanes = 1L;
vHeader.cBitCount = 24;
hBmp = ::GpiCreateBitmap( hPSDst
,&vHeader
,0L
,NULL
,NULL
);
if ((hOldBitmap = ::GpiSetBitmap(hPSDst, hBmp)) == HBM_ERROR)
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
}
if ((hOldBitmap = ::GpiSetBitmap(hPSSrc, (HBITMAP)rBmp.GetHBITMAP())) == HBM_ERROR)
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
}
if ((lHits = ::GpiBitBlt( hPSDst
,hPSSrc
,4L
,vPoint
,ROP_SRCCOPY
,BBO_IGNORE
)) == GPI_ERROR)
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
}
if ((hOldBitmap = ::GpiSetBitmap(hPSDst, NULLHANDLE)) == HBM_ERROR)
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
}
if ((hOldBitmap = ::GpiSetBitmap(hPSSrc, NULLHANDLE)) == HBM_ERROR)
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
}
vIconInfo.hbmColor = hBmp;
vHeader.cy = (ULONG)rBmp.GetHeight() * 2;
hBmpMask = ::GpiCreateBitmap( hPSDst
,&vHeader
,0L
,NULL
,NULL
);
if ((hOldBitmap = ::GpiSetBitmap(hPSDst, hBmpMask)) == HBM_ERROR)
{
vError = ::WinGetLastError(vHabmain);
//.........这里部分代码省略.........