本文整理汇总了C++中wxBitmap::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ wxBitmap::GetSize方法的具体用法?C++ wxBitmap::GetSize怎么用?C++ wxBitmap::GetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxBitmap
的用法示例。
在下文中一共展示了wxBitmap::GetSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawCursorDataToBmp
void CGradientCtrl::DrawCursorDataToBmp(std::vector<CGradientCursor*>& list, wxBitmap& bmp)
{
CGradientCursor* pPreCursor = *list.begin();
CGradientCursor* pLastCursor = *list.rbegin();
wxSize size = bmp.GetSize();
BEATS_ASSERT(pPreCursor != nullptr);
BEATS_ASSERT(pLastCursor != nullptr);
{
wxMemoryDC dc(bmp);
int nWidth = INVALID_DATA;
for (auto itr : list)
{
if (pPreCursor == itr)
{
nWidth = itr->GetPosPercent() * size.x;
dc.SetBrush(wxBrush(itr->GetColor()));
dc.SetPen(wxPen(itr->GetColor()));
dc.DrawRectangle(wxRect(0, 0, nWidth + 1 , size.y));
}
else if (pLastCursor == itr)
{
nWidth = (1.0 - itr->GetPosPercent()) * size.x;
dc.SetBrush(wxBrush(itr->GetColor()));
dc.SetPen(wxPen(itr->GetColor()));
dc.DrawRectangle(wxRect(itr->GetPosPercent() * size.x, 0, nWidth + 1 , size.y));
}
nWidth = (itr->GetPosPercent() - pPreCursor->GetPosPercent()) * size.x;
wxRect rect = wxRect(pPreCursor->GetPosPercent() * size.x, 0, nWidth + 1 , size.y);
dc.GradientFillLinear(rect, pPreCursor->GetColor(), itr->GetColor());
pPreCursor = itr;
}
}
}
示例2: DoSetBitmap
void wxAnyButton::DoSetBitmap(const wxBitmap& bitmap, State which)
{
if ( !bitmap.IsOk() )
{
if ( m_imageData )
{
// Normal image is special: setting it enables images for the
// button and resetting it to nothing disables all of them.
if ( which == State_Normal )
{
delete m_imageData;
m_imageData = NULL;
}
else
{
// Replace the removed bitmap with the normal one.
wxBitmap bmpNormal = m_imageData->GetBitmap(State_Normal);
m_imageData->SetBitmap(which == State_Disabled
? bmpNormal.ConvertToDisabled()
: bmpNormal,
which);
}
}
return;
}
#if wxUSE_UXTHEME
wxXPButtonImageData *oldData = NULL;
#endif // wxUSE_UXTHEME
// Check if we already had bitmaps of different size.
if ( m_imageData &&
bitmap.GetSize() != m_imageData->GetBitmap(State_Normal).GetSize() )
{
wxASSERT_MSG( (which == State_Normal) || bitmap.IsNull(),
"Must set normal bitmap with the new size first" );
#if wxUSE_UXTHEME
if ( ShowsLabel() && wxUxThemeEngine::GetIfActive() )
{
// We can't change the size of the images stored in wxImageList
// in wxXPButtonImageData::m_iml so force recreating it below but
// keep the current data to copy its values into the new one.
oldData = static_cast<wxXPButtonImageData *>(m_imageData);
m_imageData = NULL;
}
#endif // wxUSE_UXTHEME
//else: wxODButtonImageData doesn't require anything special
}
// allocate the image data when the first bitmap is set
if ( !m_imageData )
{
#if wxUSE_UXTHEME
// using image list doesn't work correctly if we don't have any label
// (even if we use BUTTON_IMAGELIST_ALIGN_CENTER alignment and
// BS_BITMAP style), at least under Windows 2003 so use owner drawn
// strategy for bitmap-only buttons
if ( ShowsLabel() && wxUxThemeEngine::GetIfActive() )
{
m_imageData = new wxXPButtonImageData(this, bitmap);
if ( oldData )
{
// Preserve the old values in case the user changed them.
m_imageData->SetBitmapPosition(oldData->GetBitmapPosition());
const wxSize oldMargins = oldData->GetBitmapMargins();
m_imageData->SetBitmapMargins(oldMargins.x, oldMargins.y);
// No need to preserve the bitmaps though as they were of wrong
// size anyhow.
delete oldData;
}
}
else
#endif // wxUSE_UXTHEME
{
m_imageData = new wxODButtonImageData(this, bitmap);
MakeOwnerDrawn();
}
}
else
{
m_imageData->SetBitmap(bitmap, which);
}
// it should be enough to only invalidate the best size when the normal
// bitmap changes as all bitmaps assigned to the button should be of the
// same size anyhow
if ( which == State_Normal )
InvalidateBestSize();
Refresh();
}
示例3: Render
void AudioWaveformRenderer::Render(wxBitmap &bmp, int start, AudioRenderingStyle style)
{
wxMemoryDC dc(bmp);
wxRect rect(wxPoint(0, 0), bmp.GetSize());
int midpoint = rect.height / 2;
const AudioColorScheme *pal = &colors[style];
double pixel_samples = pixel_ms * provider->GetSampleRate() / 1000.0;
// Fill the background
dc.SetBrush(wxBrush(pal->get(0.0f)));
dc.SetPen(*wxTRANSPARENT_PEN);
dc.DrawRectangle(rect);
// Make sure we've got a buffer to fill with audio data
if (!audio_buffer)
{
// Buffer for one pixel strip of audio
size_t buffer_needed = pixel_samples * provider->GetChannels() * provider->GetBytesPerSample();
audio_buffer = new char[buffer_needed];
}
double cur_sample = start * pixel_samples;
assert(provider->GetBytesPerSample() == 2);
assert(provider->GetChannels() == 1);
wxPen pen_peaks(wxPen(pal->get(0.4f)));
wxPen pen_avgs(wxPen(pal->get(0.7f)));
for (int x = 0; x < rect.width; ++x)
{
provider->GetAudio(audio_buffer, (int64_t)cur_sample, (int64_t)pixel_samples);
cur_sample += pixel_samples;
int peak_min = 0, peak_max = 0;
int64_t avg_min_accum = 0, avg_max_accum = 0;
const int16_t *aud = (const int16_t *)audio_buffer;
for (int si = pixel_samples; si > 0; --si, ++aud)
{
if (*aud > 0)
{
peak_max = std::max(peak_max, (int)*aud);
avg_max_accum += *aud;
}
else
{
peak_min = std::min(peak_min, (int)*aud);
avg_min_accum += *aud;
}
}
// midpoint is half height
peak_min = std::max((int)(peak_min * amplitude_scale * midpoint) / 0x8000, -midpoint);
peak_max = std::min((int)(peak_max * amplitude_scale * midpoint) / 0x8000, midpoint);
int avg_min = std::max((int)(avg_min_accum * amplitude_scale * midpoint / pixel_samples) / 0x8000, -midpoint);
int avg_max = std::min((int)(avg_max_accum * amplitude_scale * midpoint / pixel_samples) / 0x8000, midpoint);
dc.SetPen(pen_peaks);
dc.DrawLine(x, midpoint - peak_max, x, midpoint - peak_min);
if (render_averages) {
dc.SetPen(pen_avgs);
dc.DrawLine(x, midpoint - avg_max, x, midpoint - avg_min);
}
}
// Horizontal zero-point line
if (render_averages)
dc.SetPen(wxPen(pal->get(1.0f)));
else
dc.SetPen(pen_peaks);
dc.DrawLine(0, midpoint, rect.width, midpoint);
}
示例4: DoPreviewBitmap
void wxGenericColourDialog::DoPreviewBitmap(wxBitmap& bmp, const wxColour& colour)
{
if ( bmp.HasAlpha() && colour.Alpha() != wxALPHA_OPAQUE )
{
// For real ARGB draw a chessboard grid
// with actual ARGB fields and reference RGB fields.
const int w = bmp.GetWidth();
const int h = bmp.GetHeight();
// Calculate field size: 4 fields per row/column,
// with size in range [2..10]
int dx = wxMax(wxMin(w / 4, 10), 2);
int dy = wxMax(wxMin(h / 4, 10), 2);
// We want a square field
dx = wxMax(dx, dy);
dy = dx;
// Prepare opaque colour
wxColour colourRGB(colour.Red(), colour.Green(), colour.Blue(), wxALPHA_OPAQUE);
{
wxBrush brushARGB(colour);
wxBrush brushRGB(colourRGB);
wxMemoryDC mdc(bmp);
{
wxGCDC gdc(mdc);
gdc.SetPen(*wxTRANSPARENT_PEN);
for (int x = 0, ix = 0; x < w; x += dx, ix++)
{
for (int y = 0, iy = 0; y < h; y += dy, iy++)
{
if ( (ix+iy) % 2 == 0 )
{
gdc.SetBrush(brushARGB);
}
else
{
gdc.SetBrush(brushRGB);
}
gdc.DrawRectangle(x, y, dx, dy);
}
}
// Draw a frame
gdc.SetPen(*wxBLACK_PEN);
gdc.SetBrush(*wxTRANSPARENT_BRUSH);
gdc.DrawRectangle(0, 0, w, h);
}
}
}
else
{
wxMemoryDC mdc(bmp);
// Fill with custom colour
wxBrush brush(colour);
mdc.SetPen(*wxBLACK_PEN);
mdc.SetBrush(brush);
mdc.DrawRectangle(wxPoint(0, 0), bmp.GetSize());
}
}