Hi,
I use wxFreeChart to display graph. Recently, I've got a warning with the following message :
"warning: ../../src/msw/bitmap.cpp(741): assert ""w > 0 && h > 0"" failed in DoCreate(): invalid bitmap size". I found that this warning comes from the following function :
"void AxisPlot::DrawDataAreaBackground(wxDC &dc, wxRect rc)" at this line :
" m_plotBackgroundBitmap.Create(m_drawRect.GetWidth(), m_drawRect.GetHeight());".
How can figure out this warning ?Thanks you in advance
S.T.
Bitmap creation failed in wxFreeChart
Re: Bitmap creation failed in wxFreeChart
viewtopic.php?t=42067
I wish people used search before posting and created their thread in the proper forums sections, but I guess both are things of a distant past. [/rant]
I wish people used search before posting and created their thread in the proper forums sections, but I guess both are things of a distant past. [/rant]
Re: Bitmap creation failed in wxFreeChart
Thanks you for your answer. In fact I've already seen that topic. I've downloaded the recent version of wxFreeChart which already contains the solution. Unfortunately, I still have the same warning but now in the function "void AxisPlot::DrawDataAreaBackground(wxDC &dc, wxRect rc)". Please help me
S.T.
S.T.
Re: Bitmap creation failed in wxFreeChart
Where did you download your version of wxFreeChart from? I can't even find AxisPlot::DrawDataAreaBackground() in the wxFreeChart source I have.
Nevertheless, the solution should be still the same as in the post I referenced earlier: Make sure the bitmap dimensions are correct, i.e. neither is smaller than 1, using e.g. the posted fix.
Edit
You must be using iwbnwif's version of wxFreeChart, where the method was added
I believe the code is missing a check for m_drawRect and/or rc being empty or invalid. If either of these two is empty no drawing including bitmap creation should be even necessary...
Nevertheless, the solution should be still the same as in the post I referenced earlier: Make sure the bitmap dimensions are correct, i.e. neither is smaller than 1, using e.g. the posted fix.
Edit
You must be using iwbnwif's version of wxFreeChart, where the method was added
Code: Select all
// Draw the background of the data area, basically everything except the data.
void AxisPlot::DrawDataAreaBackground(wxDC &dc, wxRect rc)
{
wxRect rcData;
wxRect rcLegend;
// Hackish test to see if the background needs to be redrawn
// due to a size change.
if (rc.GetSize() != m_drawRect)
{
m_redrawDataArea = true;
m_drawRect.SetSize(rc.GetSize());
m_drawRect.SetTopLeft(wxPoint(0, 0));
}
// Calculate the rectangle where the actual data is plotted.
CalcDataArea(dc, m_drawRect, rcData, rcLegend);
// The plot area has changed (size change, axis change).
if (m_redrawDataArea) {
.....
Re: Bitmap creation failed in wxFreeChart
I've downloaded wxFreechart from "https://github.com/iwbnwif/wxFreeChart". So I've the same code that you wrote.
S.T.
S.T.
Re: Bitmap creation failed in wxFreeChart
Hi,
Sorry that you are having this problem. I will try to create a fix within the next few days, but in the meantime if someone likes to make a pull request that is also very welcome
Sorry that you are having this problem. I will try to create a fix within the next few days, but in the meantime if someone likes to make a pull request that is also very welcome
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.