本文整理汇总了C++中wxBitmap::GetDepth方法的典型用法代码示例。如果您正苦于以下问题:C++ wxBitmap::GetDepth方法的具体用法?C++ wxBitmap::GetDepth怎么用?C++ wxBitmap::GetDepth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxBitmap
的用法示例。
在下文中一共展示了wxBitmap::GetDepth方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: DoDrawBitmap
void wxGCDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y,
bool useMask )
{
wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid DC") );
wxCHECK_RET( bmp.IsOk(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid bitmap") );
int w = bmp.GetScaledWidth();
int h = bmp.GetScaledHeight();
if ( bmp.GetDepth() == 1 )
{
m_graphicContext->SetPen(*wxTRANSPARENT_PEN);
m_graphicContext->SetBrush(m_textBackgroundColour);
m_graphicContext->DrawRectangle( x, y, w, h );
m_graphicContext->SetBrush(m_textForegroundColour);
m_graphicContext->DrawBitmap( bmp, x, y, w, h );
m_graphicContext->SetBrush( m_graphicContext->CreateBrush(m_brush));
m_graphicContext->SetPen( m_graphicContext->CreatePen(m_pen));
}
else // not a monochrome bitmap, handle it normally
{
// make a copy in case we need to remove its mask, if we don't modify
// it the copy is cheap as bitmaps are reference-counted
wxBitmap bmpCopy(bmp);
if ( !useMask && bmp.GetMask() )
bmpCopy.SetMask(NULL);
m_graphicContext->DrawBitmap( bmpCopy, x, y, w, h );
}
CalcBoundingBox(x, y);
CalcBoundingBox(x + w, y + h);
}
示例3: DoDrawSubBitmap
void wxDC::DoDrawSubBitmap(const wxBitmap &bmp,
wxCoord x, wxCoord y, wxCoord w, wxCoord h,
wxCoord destx, wxCoord desty, int rop, bool useMask)
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( bmp.Ok(), wxT("invalid bitmap") );
// NB: we could also support XOR here (via DSBLIT_XOR)
// and possibly others via SetSrc/DstBlendFunction()
wxCHECK_RET( rop == wxCOPY, _T("only wxCOPY function supported") );
if ( bmp.GetDepth() == 1 )
{
// Mono bitmaps are handled in special way -- all 1s are drawn in
// foreground colours, all 0s in background colour.
wxFAIL_MSG( _T("drawing mono bitmaps not implemented") );
return;
}
if ( useMask && bmp.GetMask() )
{
// FIXME_DFB: see MGL sources for a way to do it, but it's not directly
// applicable because DirectFB doesn't implement ROPs; OTOH,
// it has blitting modes that can be useful; finally, see
// DFB's SetSrcBlendFunction() and SetSrcColorKey()
wxFAIL_MSG( _T("drawing bitmaps with masks not implemented") );
return;
}
DoBlitFromSurface(bmp.GetDirectFBSurface(),
x, y,
w, h,
destx, desty);
}
示例4: ConvertTo24Bit
wxBitmap ConvertTo24Bit( wxColor bgColor, wxBitmap front ) {
if( front.GetDepth() == 24 ) return front;
wxBitmap result( front.GetWidth(), front.GetHeight(), 24 );
front.UseAlpha();
wxImage im_front = front.ConvertToImage();
wxImage im_result = result.ConvertToImage();
unsigned char *presult = im_result.GetData();
unsigned char *pfront = im_front.GetData();
unsigned char *afront = NULL;
if( im_front.HasAlpha() )
afront = im_front.GetAlpha();
for( int i = 0; i < result.GetWidth(); i++ ) {
for( int j = 0; j < result.GetHeight(); j++ ) {
double alphaF = (double) ( *afront++ ) / 256.0;
unsigned char r = *pfront++ * alphaF + bgColor.Red() * ( 1.0 - alphaF );
*presult++ = r;
unsigned char g = *pfront++ * alphaF + bgColor.Green() * ( 1.0 - alphaF );
*presult++ = g;
unsigned char b = *pfront++ * alphaF + bgColor.Blue() * ( 1.0 - alphaF );
*presult++ = b;
}
}
result = wxBitmap( im_result );
return result;
}
示例5: InitFromMonoBitmap
bool wxMask::InitFromMonoBitmap(const wxBitmap& bitmap)
{
wxCHECK_MSG( bitmap.IsOk(), false, wxT("Invalid bitmap") );
wxCHECK_MSG( bitmap.GetDepth() == 1, false, wxT("Cannot create mask from colour bitmap") );
m_bitmap = bitmap;
return true;
}
示例6: Create
bool wxMask::Create(const wxBitmap& bitmap)
{
//Only for mono bitmaps
if (!bitmap.IsOk() || bitmap.GetDepth() != 1)
return false;
if (m_qtBitmap)
delete m_qtBitmap;
m_qtBitmap = new QBitmap(*bitmap.GetHandle());
return true;
}
示例7: wxT
void BM2CMP_FRAME::updateImageInfo()
{
// Note: the image resolution text controls are not modified
// here, to avoid a race between text change when entered by user and
// a text change if it is modifed here.
int h = m_Pict_Bitmap.GetHeight();
int w = m_Pict_Bitmap.GetWidth();
int nb = m_Pict_Bitmap.GetDepth();
m_SizeXValue->SetLabel( wxString::Format( wxT( "%d" ), w ) );
m_SizeYValue->SetLabel( wxString::Format( wxT( "%d" ), h ) );
m_BPPValue->SetLabel( wxString::Format( wxT( "%d" ), nb ) );
m_SizeXValue_mm->SetLabel( wxString::Format( wxT( "%.1f" ),
(double) w / m_imageDPI.x * 25.4 ) );
m_SizeYValue_mm->SetLabel( wxString::Format( wxT( "%.1f" ),
(double) h / m_imageDPI.y * 25.4 ) );
}
示例8: DoDrawBitmap
void wxGCDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool WXUNUSED(useMask) )
{
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid DC") );
wxCHECK_RET( bmp.Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid bitmap") );
if ( bmp.GetDepth() == 1 )
{
m_graphicContext->SetPen(*wxTRANSPARENT_PEN);
m_graphicContext->SetBrush( wxBrush( m_textBackgroundColour , wxSOLID ) );
m_graphicContext->DrawRectangle( x , y , bmp.GetWidth() , bmp.GetHeight() );
m_graphicContext->SetBrush( wxBrush( m_textForegroundColour , wxSOLID ) );
m_graphicContext->DrawBitmap( bmp, x , y , bmp.GetWidth() , bmp.GetHeight() );
m_graphicContext->SetBrush( m_graphicContext->CreateBrush(m_brush));
m_graphicContext->SetPen( m_graphicContext->CreatePen(m_pen));
}
else
m_graphicContext->DrawBitmap( bmp, x , y , bmp.GetWidth() , bmp.GetHeight() );
}
示例9: wxCreateMaskedBitmap
// Creates a bitmap with transparent areas drawn in
// the given colour.
wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, wxColour& colour)
{
wxBitmap newBitmap(bitmap.GetWidth(),
bitmap.GetHeight(),
bitmap.GetDepth());
wxMemoryDC destDC;
wxMemoryDC srcDC;
srcDC.SelectObject(bitmap);
destDC.SelectObject(newBitmap);
wxBrush brush(colour, wxSOLID);
destDC.SetBackground(brush);
destDC.Clear();
destDC.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(),
&srcDC, 0, 0, wxCOPY, true);
return newBitmap;
}
示例10: MergeBitmaps
wxBitmap MergeBitmaps( wxBitmap back, wxBitmap front, wxSize offset )
{
wxBitmap merged( back.GetWidth(), back.GetHeight(), back.GetDepth() );
// If the front bitmap has no alpha channel, then merging will accomplish nothing
// So, simply return the bitmap intact
wxImage im_front = front.ConvertToImage();
if(!im_front.HasAlpha())
return front;
#if !wxCHECK_VERSION(2,9,4)
// Manual alpha blending for broken wxWidgets alpha bitmap support, pervasive in wx2.8.
merged.UseAlpha();
back.UseAlpha();
front.UseAlpha();
// wxImage im_front = front.ConvertToImage();
wxImage im_back = back.ConvertToImage();
wxImage im_result = back.ConvertToImage();// Only way to make result have alpha channel in wxW 2.8.
unsigned char *presult = im_result.GetData();
unsigned char *pback = im_back.GetData();
unsigned char *pfront = im_front.GetData();
unsigned char *afront = NULL;
if( im_front.HasAlpha() )
afront = im_front.GetAlpha();
unsigned char *aback = NULL;
if( im_back.HasAlpha() )
aback = im_back.GetAlpha();
unsigned char *aresult = NULL;
if( im_result.HasAlpha() )
aresult = im_result.GetAlpha();
// Do alpha blending, associative version of "over" operator.
if(presult && pback && pfront){
for( int i = 0; i < back.GetHeight(); i++ ) {
for( int j = 0; j < back.GetWidth(); j++ ) {
int fX = j - offset.x;
int fY = i - offset.y;
bool inFront = true;
if( fX < 0 || fY < 0 ) inFront = false;
if( fX >= front.GetWidth() ) inFront = false;
if( fY >= front.GetHeight() ) inFront = false;
if( inFront ) {
double alphaF = (double) ( *afront++ ) / 256.0;
double alphaB = (double) ( *aback++ ) / 256.0;
double alphaRes = alphaF + alphaB * ( 1.0 - alphaF );
unsigned char a = alphaRes * 256;
*aresult++ = a;
unsigned char r = (*pfront++ * alphaF + *pback++ * alphaB * ( 1.0 - alphaF )) / alphaRes;
*presult++ = r;
unsigned char g = (*pfront++ * alphaF + *pback++ * alphaB * ( 1.0 - alphaF )) / alphaRes;
*presult++ = g;
unsigned char b = (*pfront++ * alphaF + *pback++ * alphaB * ( 1.0 - alphaF )) / alphaRes;
*presult++ = b;
} else {
*aresult++ = *aback++;
*presult++ = *pback++;
*presult++ = *pback++;
*presult++ = *pback++;
}
}
}
}
merged = wxBitmap( im_result );
#else
wxMemoryDC mdc( merged );
mdc.DrawBitmap( back, 0, 0, true );
mdc.DrawBitmap( front, offset.x, offset.y, true );
mdc.SelectObject( wxNullBitmap );
#endif
return merged;
}
示例11: MergeBitmaps
wxBitmap MergeBitmaps( wxBitmap back, wxBitmap front, wxSize offset )
{
wxBitmap merged( back.GetWidth(), back.GetHeight(), back.GetDepth() );
#if (defined(__WXGTK__) || defined(__WXMAC__))
// Manual alpha blending for broken wxWidgets platforms.
merged.UseAlpha();
back.UseAlpha();
front.UseAlpha();
wxImage im_front = front.ConvertToImage();
wxImage im_back = back.ConvertToImage();
wxImage im_result = back.ConvertToImage();// Only way to make result have alpha channel in wxW 2.8.
unsigned char *presult = im_result.GetData();
unsigned char *pback = im_back.GetData();
unsigned char *pfront = im_front.GetData();
unsigned char *afront = NULL;
if( im_front.HasAlpha() )
afront = im_front.GetAlpha();
unsigned char *aback = NULL;
if( im_back.HasAlpha() )
aback = im_back.GetAlpha();
unsigned char *aresult = NULL;
if( im_result.HasAlpha() )
aresult = im_result.GetAlpha();
// Do alpha blending, associative version of "over" operator.
for( int i = 0; i < back.GetHeight(); i++ ) {
for( int j = 0; j < back.GetWidth(); j++ ) {
int fX = j - offset.x;
int fY = i - offset.y;
bool inFront = true;
if( fX < 0 || fY < 0 ) inFront = false;
if( fX >= front.GetWidth() ) inFront = false;
if( fY >= front.GetHeight() ) inFront = false;
if( inFront ) {
double alphaF = (double) ( *afront++ ) / 256.0;
double alphaB = (double) ( *aback++ ) / 256.0;
double alphaRes = alphaF + alphaB * ( 1.0 - alphaF );
unsigned char a = alphaRes * 256;
*aresult++ = a;
unsigned char r = (*pfront++ * alphaF + *pback++ * alphaB * ( 1.0 - alphaF )) / alphaRes;
*presult++ = r;
unsigned char g = (*pfront++ * alphaF + *pback++ * alphaB * ( 1.0 - alphaF )) / alphaRes;
*presult++ = g;
unsigned char b = (*pfront++ * alphaF + *pback++ * alphaB * ( 1.0 - alphaF )) / alphaRes;
*presult++ = b;
} else {
*aresult++ = *aback++;
*presult++ = *pback++;
*presult++ = *pback++;
*presult++ = *pback++;
}
}
}
merged = wxBitmap( im_result );
#else
wxMemoryDC mdc( merged );
mdc.DrawBitmap( back, 0, 0, true );
mdc.DrawBitmap( front, offset.x, offset.y, true );
mdc.SelectObject( wxNullBitmap );
#endif
return merged;
}