diff --git a/src/audio_renderer.cpp b/src/audio_renderer.cpp index e90586b02..d396cd221 100644 --- a/src/audio_renderer.cpp +++ b/src/audio_renderer.cpp @@ -50,19 +50,22 @@ namespace { } AudioRendererBitmapCacheBitmapFactory::AudioRendererBitmapCacheBitmapFactory(AudioRenderer *renderer) -: renderer(renderer) +: renderer(renderer), block_size(0) { assert(renderer); } std::unique_ptr AudioRendererBitmapCacheBitmapFactory::ProduceBlock(int /* i */) { - return agi::make_unique(renderer->cache_bitmap_width, renderer->pixel_height, 24); + std::unique_ptr ret = agi::make_unique(renderer->cache_bitmap_width, renderer->pixel_height); + block_size = sizeof(wxBitmap) + static_cast(ret->GetWidth()) * ret->GetHeight() * ((ret->GetDepth() + 7) / 8); + return ret; } size_t AudioRendererBitmapCacheBitmapFactory::GetBlockSize() const { - return sizeof(wxBitmap) + renderer->cache_bitmap_width * renderer->pixel_height * 3; + assert(block_size); + return block_size; } AudioRenderer::AudioRenderer() diff --git a/src/audio_renderer.h b/src/audio_renderer.h index 1d88be3cb..386705790 100644 --- a/src/audio_renderer.h +++ b/src/audio_renderer.h @@ -61,6 +61,7 @@ struct AudioRendererBitmapCacheBitmapFactory { /// Produces a wxBitmap with dimensions pulled from our master AudioRenderer. std::unique_ptr ProduceBlock(int i); + size_t block_size; /// @brief Calculate the size of bitmaps /// @return The size of bitmaps created size_t GetBlockSize() const; diff --git a/src/audio_renderer_spectrum.cpp b/src/audio_renderer_spectrum.cpp index b496414ea..57c2dc3c3 100644 --- a/src/audio_renderer_spectrum.cpp +++ b/src/audio_renderer_spectrum.cpp @@ -215,7 +215,6 @@ void AudioSpectrumRenderer::Render(wxBitmap &bmp, int start, AudioRenderingStyle return; assert(bmp.IsOk()); - assert(bmp.GetDepth() == 24); int end = start + bmp.GetWidth();