本文整理汇总了C++中wxBitmap::ConvertToImage方法的典型用法代码示例。如果您正苦于以下问题:C++ wxBitmap::ConvertToImage方法的具体用法?C++ wxBitmap::ConvertToImage怎么用?C++ wxBitmap::ConvertToImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxBitmap
的用法示例。
在下文中一共展示了wxBitmap::ConvertToImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BlendBitmaps
wxBitmap BlendBitmaps(const wxBitmap& background, const wxBitmap& overlay, const int /*dim*/)
{
wxImage back = background.ConvertToImage();
wxImage front = overlay.ConvertToImage();
wxImage ret = BlendImage(front, back);
return wxBitmap(ret);
}
示例2: 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;
}
示例3: ReplaceChannelStatusColour
wxImage ReplaceChannelStatusColour( wxBitmap img, const wxColour& colour )
{
wxImage ret = img.ConvertToImage();
wxImage::HSVValue origcolour = wxImage::RGBtoHSV( wxImage::RGBValue( colour.Red(), colour.Green(), colour.Blue() ) );
double bright = origcolour.value - 0.1*origcolour.value;
bright = LSL::Util::Clamp( bright, 0.0, 1.0 );
wxImage::HSVValue hsvdarker1( origcolour.hue, origcolour.saturation, bright );
bright = origcolour.value - 0.5*origcolour.value;
bright = LSL::Util::Clamp( bright, 0.0, 1.0 );
wxImage::HSVValue hsvdarker2( origcolour.hue, origcolour.saturation, bright );
wxImage::RGBValue rgbdarker1 = wxImage::HSVtoRGB( hsvdarker1 );
wxImage::RGBValue rgbdarker2 = wxImage::HSVtoRGB( hsvdarker2 );
ret.Replace( 164, 147, 0, rgbdarker2.red, rgbdarker2.green, rgbdarker2.blue );
ret.Replace( 255, 228, 0, rgbdarker1.red, rgbdarker1.green, rgbdarker1.blue );
ret.Replace( 255, 253, 234, colour.Red(), colour.Green(), colour.Blue() );
return ret;
}
示例4: CreateBitmapDisabled
wxBitmap wxCustomButton::CreateBitmapDisabled(const wxBitmap &bitmap) const
{
wxCHECK_MSG(bitmap.Ok(), wxNullBitmap, wxT("invalid bitmap"));
unsigned char br = GetBackgroundColour().Red();
unsigned char bg = GetBackgroundColour().Green();
unsigned char bb = GetBackgroundColour().Blue();
wxImage image = bitmap.ConvertToImage();
int pos, width = image.GetWidth(), height = image.GetHeight();
unsigned char *img_data = image.GetData();
for (int j=0; j<height; j++)
{
for (int i=j%2; i<width; i+=2)
{
pos = (j*width+i)*3;
img_data[pos ] = br;
img_data[pos+1] = bg;
img_data[pos+2] = bb;
}
}
return wxBitmap(image);
}
示例5: Add
// Adds a bitmap, using the specified colour to create the mask bitmap
// Note that wxImageList creates new bitmaps, so you may delete
// 'bitmap'.
int wxImageList::Add(const wxBitmap& bitmap, const wxColour& maskColour)
{
HBITMAP hbmp;
#if wxUSE_WXDIB && wxUSE_IMAGE
// See the comment in overloaded Add() above.
AutoHBITMAP hbmpRelease;
if ( bitmap.HasAlpha() )
{
hbmp = wxDIB(bitmap.ConvertToImage(),
wxDIB::PixelFormat_NotPreMultiplied).Detach();
hbmpRelease.Init(hbmp);
}
else
#endif // wxUSE_WXDIB && wxUSE_IMAGE
hbmp = GetHbitmapOf(bitmap);
int index = ImageList_AddMasked(GetHImageList(),
hbmp,
wxColourToRGB(maskColour));
if ( index == -1 )
{
wxLogError(_("Couldn't add an image to the image list."));
}
return index;
}
示例6: Add
int wxImageList::Add( const wxBitmap& bitmap, const wxColour& maskColour )
{
wxImage img = bitmap.ConvertToImage();
img.SetMaskColour( maskColour.Red(), maskColour.Green(), maskColour.Blue() );
return Add( wxBitmap( img ) );
}
示例7: OverlaySymlink
static void OverlaySymlink(wxBitmap& bmp)
{
// This is ugly, but apparently needed so that the data is _really_ in the right internal format
bmp = bmp.ConvertToImage();
wxBitmap symlink = wxArtProvider::GetBitmap(_T("ART_SYMLINK"), wxART_OTHER, wxSize(bmp.GetWidth(), bmp.GetHeight())).ConvertToImage();
wxAlphaPixelData target(bmp);
wxAlphaPixelData source(symlink);
int sx = bmp.GetWidth();
if (symlink.GetWidth() < sx)
sx = symlink.GetWidth();
int sy = bmp.GetHeight();
if (symlink.GetHeight() < sy)
sy = symlink.GetHeight();
// Do some rudimentary alpha copying
wxAlphaPixelData::Iterator t(target);
wxAlphaPixelData::Iterator s(source);
for (int y = 0; y < sy; y++)
{
s.MoveTo(source, 0, y);
t.MoveTo(target, 0, y);
for (int x = 0; x < sx; x++, s++, t++)
AlphaComposite_Over_Inplace(t, s);
}
}
示例8: Replace
// Replaces a bitmap, optionally passing a mask bitmap.
// Note that wxImageList creates new bitmaps, so you may delete
// 'bitmap' and 'mask'.
bool wxImageList::Replace(int index,
const wxBitmap& bitmap,
const wxBitmap& mask)
{
HBITMAP hbmp;
#if wxUSE_WXDIB && wxUSE_IMAGE
// See the comment in Add() above.
AutoHBITMAP hbmpRelease;
if ( bitmap.HasAlpha() )
{
hbmp = wxDIB(bitmap.ConvertToImage(),
wxDIB::PixelFormat_NotPreMultiplied).Detach();
hbmpRelease.Init(hbmp);
}
else
#endif // wxUSE_WXDIB && wxUSE_IMAGE
hbmp = GetHbitmapOf(bitmap);
AutoHBITMAP hbmpMask(GetMaskForImage(bitmap, mask));
if ( !ImageList_Replace(GetHImageList(), index, hbmp, hbmpMask) )
{
wxLogLastError(wxT("ImageList_Replace()"));
return false;
}
return true;
}
示例9: setImage
void setImage(wxString path)
{
m_image_path = path;
if(path.EndsWith(wxT(".icns"))) {
wxExecute(wxT("sips -s format png '") + path + wxT("' --out /tmp/tmpicon.png"), wxEXEC_SYNC);
path = wxT("/tmp/tmpicon.png");
}
m_image.LoadFile(path, wxBITMAP_TYPE_ANY);
if(m_image.IsOk()) {
if(m_image.GetWidth() > 50 or m_image.GetHeight() > 50) {
wxImage tmp = m_image.ConvertToImage();
tmp.Rescale(50, 50, wxIMAGE_QUALITY_HIGH);
m_image = wxBitmap(tmp);
}
const int w = m_image.GetWidth();
const int h = m_image.GetHeight();
SetMinSize(wxSize(w + 20, h + 20));
SetMaxSize(wxSize(w + 20, h + 20));
Refresh(); // repaint needed to see change
} else {
wxMessageBox(_("Failed to load image"));
}
}
示例10: MakeTransparent
void wxSpeedButton::MakeTransparent(wxBitmap &inBitmap) {
int h;
int r,g,b;
wxImage img;
wxBitmap *bmp;
// not a good image?
if (! inBitmap.IsOk()) return;
// already have a mask?
img = inBitmap.ConvertToImage();
if (img.HasMask()) return;
// get the colors of the lower-left corner of the image
h = img.GetHeight();
r = img.GetRed(0, h-1);
b = img.GetBlue(0, h-1);
g = img.GetGreen(0, h-1);
// make a mask from those colors
img.SetMaskColour(r, g, b);
// store it back in the bitmap
bmp = new wxBitmap(img);
inBitmap = *bmp;
}
示例11: AddFile
/*static*/ void
wxMemoryFSHandler::AddFile(const wxString& filename,
const wxBitmap& bitmap,
wxBitmapType type)
{
wxImage img = bitmap.ConvertToImage();
AddFile(filename, img, type);
}
示例12: CreateBitmapDisabled
wxBitmap wxCustomButton::CreateBitmapDisabled(const wxBitmap &bitmap) const
{
wxCHECK_MSG(bitmap.Ok(), wxNullBitmap, wxT("invalid bitmap"));
unsigned char br = GetBackgroundColour().Red();
unsigned char bg = GetBackgroundColour().Green();
unsigned char bb = GetBackgroundColour().Blue();
wxImage image = bitmap.ConvertToImage();
int pos, width = image.GetWidth(), height = image.GetHeight();
unsigned char *img_data = image.GetData();
for (int j=0; j<height; j++)
{
for (int i=j%2; i<width; i+=2)
{
pos = (j*width+i)*3;
img_data[pos ] = br;
img_data[pos+1] = bg;
img_data[pos+2] = bb;
}
}
return wxBitmap(image);
/* // FIXME why bother creating focused wxCustomButton's bitmap
wxImage imgFoc = bitmap.ConvertToImage();
bool mask = false;
unsigned char mr=0, mg=0, mb=0;
if (img.HasMask())
{
mask = true;
mr = imgDis.GetMaskRed();
mg = imgDis.GetMaskGreen();
mb = imgDis.GetMaskBlue();
}
unsigned char *r, *g, *b;
unsigned char *focData = imgFoc.GetData();
r = imgFoc.GetData();
g = imgFoc.GetData() + 1;
b = imgFoc.GetData() + 2;
for (int j=0; j<h; j++)
{
for (int i=0; i<w; i++)
{
if ((!mask || ((*r!=mr)&&(*b!=mb)&&(*g!=mg))) &&
((*r<236)&&(*b<236)&&(*g<236)))
{
*r += 20; *g += 20; *b += 20;
}
r += 3; g += 3; b += 3;
}
}
m_bmpFocus = wxBitmap(imgFoc);
*/
}
示例13: CreateOrUpdateTexture
void DrawGLUtils::CreateOrUpdateTexture(const wxBitmap &bmp48,
const wxBitmap &bmp32,
const wxBitmap &bmp16,
GLuint* texture)
{
int level = 0;
glGenTextures(1,texture);
glBindTexture(GL_TEXTURE_2D, *texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
addMipMap(texture, bmp48.ConvertToImage().Rescale(64, 64, wxIMAGE_QUALITY_HIGH), level);
addMipMap(texture, bmp32.ConvertToImage(), level);
addMipMap(texture, bmp16.ConvertToImage(), level);
addMipMap(texture, bmp16.ConvertToImage().Rescale(8, 8, wxIMAGE_QUALITY_HIGH), level);
addMipMap(texture, bmp16.ConvertToImage().Rescale(4, 4, wxIMAGE_QUALITY_HIGH), level);
addMipMap(texture, bmp16.ConvertToImage().Rescale(2, 2, wxIMAGE_QUALITY_HIGH), level);
addMipMap(texture, bmp16.ConvertToImage().Rescale(1, 1, wxIMAGE_QUALITY_HIGH), level);
}
示例14: SetBitmap
// See also: wxButton::DoSetBitmap and wxBitmapButton::DoSetBitmap
void DynamicBitmap::SetBitmap( const wxBitmap& bitmap, wxButtonBase::State state )
{
if ( bitmap.IsOk() )
{
DoSetBitmap( bitmap, state );
switch ( state )
{
default:
// nothing special to do but include the default clause to
// suppress gcc warnings
//HELIUM_ASSERT();
break;
case wxButtonBase::State_Normal:
m_WasStateSetByUser[wxButtonBase::State_Normal] = true;
#if wxUSE_IMAGE
if ( !m_WasStateSetByUser[wxButtonBase::State_Disabled] )
{
wxImage disabledImage( bitmap.ConvertToImage().ConvertToGreyscale() );
DoSetBitmap( disabledImage, wxButtonBase::State_Disabled );
}
#endif // wxUSE_IMAGE
break;
case wxButtonBase::State_Current:
m_WasStateSetByUser[wxButtonBase::State_Current] = true;
break;
case wxButtonBase::State_Pressed:
m_WasStateSetByUser[wxButtonBase::State_Pressed] = true;
break;
case wxButtonBase::State_Disabled:
m_WasStateSetByUser[wxButtonBase::State_Disabled] = true;
break;
case wxButtonBase::State_Focused:
m_WasStateSetByUser[wxButtonBase::State_Focused] = true;
// if the focus bitmap is specified but current one isn't, use
// the focus bitmap for hovering as well if this is consistent
// with the current Windows version look and feel
//
// rationale: this is compatible with the old wxGTK behaviour
// and also makes it much easier to do "the right thing" for
// all platforms (some of them, such as Windows XP, have "hot"
// buttons while others don't)
if ( !m_WasStateSetByUser[wxButtonBase::State_Current] )
{
DoSetBitmap( bitmap, wxButtonBase::State_Current );
}
break;
}
}
}
示例15: OnPaint
// ----------------------------------------------------------------------------
void BitmapWidget::OnPaint(wxPaintEvent &event)
{
wxAutoBufferedPaintDC dc(this);
dc.SetBackground(*wxBLACK_BRUSH);
dc.Clear();
wxImage img(m_bmp->ConvertToImage());
dc.DrawBitmap(wxBitmap(img.Scale(m_w, m_h)), m_x, m_y, false);
}