GdiPlusX issue on GetPictureValfromHBitmap

Jul 23, 2008 at 9:32 PM
I've received the following error report for FoxCharts:

When the object is resized to a large size (eg. 1280x1024) an error is raised by the GDI+ system :
xfcbitmap.GetPictureValFromHBitmap, line 12949, "string is too long too fit".

Seems like somewhere in there the bitmap data is being assigned to a string and the data is too large.
Is there a known limitation on the size of the image?

I've tested in the same resolution with many kinds of charts, but could not reproduce this...
Do you have any ideas about what may be happening there ?
Jul 25, 2008 at 2:38 AM
The error does not occur if the image is large to begin with, it only occurs if resizing from a smaller to larger size, eg. maximise the form.
Jul 25, 2008 at 4:26 PM

Thanks, but I still could not reproduce this error.

Can you provide more details ?

Like: Chart Type, OS

Are you using VFP9 SP2 ?

Does it always happen ?
Jul 29, 2008 at 6:07 AM
You can't reproduce the error because it stems from our own peculiar class code!
Our forms have an object on them that resizes all form controls when the form is resized (this pre-dates VFP's new Anchor property) - when the FoxCharts object has its default Anchor setting of 30, this somehow tangles with our code that changes the height and width of the FoxCharts object when the form is resized, resulting in the error and subsequent hanging of Foxpro.
If I set Anchor = 0 then the problem disappears.

So, probably not something you need to look into.  I'll look into it further when I get the chance, out of academic interest.

Jul 29, 2008 at 8:48 AM
When you change the position or size of an object, you need to remember the Anchor value, set it to 0, change the size and/or position and finally restore Anchor.
Jul 29, 2008 at 11:24 PM
Edited Jul 29, 2008 at 11:56 PM
Thanks Christof !

I'd like you to make another test
Please adapt the code below to your form, and try to reproduce the error, using your original codes and classes.

 Thisform.FoxCharts1.ChartCanvas.RenderMode = 4



Note that it needs to be run brfore the "DrawChart()" command !

This will make the image rendering to be made using the PNG encoder.
It also uses a different technique to obtain the PictureVal.
The PNG encoder, although a little bit slower in some cases, will consume up to 10 times less memory than the original configuration, that uses BMP.

I'm looking forward to hearing from you !

Aug 7, 2008 at 1:05 AM
Hi Cesar,

Setting RenderMode to 4 does prevent the error, but the chart then takes a very long time to resize (up to 1 minute), so long that it is unusable in this mode.

Aug 7, 2008 at 3:46 AM
Hi Paul,

It seems that there is something wrong in your form during the resize.
I've tested here, using Render mode 0 (default BMP), 1 (Using a temp BMP file) or 4 (using a PNG saved in a memory stream), and the three modes work nice, with almost no performance difference between modes 0 and 4 - (using 1 is just a bit slower).
Form resizing is very fast too.
Are you using any kind of a resizer class in your forms ?

Probably the best solution for your case is to follow Christof's suggestion, setting the Anchor property to 0 before resizing, and doing the FoxCharts resizing manually, if you don't want to adjust your classes.

Hope this helps !