Strange myPict.Save(f,Picture.SaveAsPNG)

Hi,

in an unfinished but working project, I use the followinf code to save the Picture contents to a png file:

myPict.Image.Save(f, Picture.SaveAsPNG)

I needed to use the project yesterday to generate a bunch of file and get… a UnsupportedFormatException, only at the second generated file, time to save it.

After some files, I decided to search what happens, and add an if block as below:

If myPicte.IsExportFormatSupported(Picture.FormatPNG) Then myPict.Image.Save(f, Picture.SaveAsPNG) End If

And now I can generate and save as many PNG files as I need…

Strange, did I say that it is Strange ?

Thank you ! I was thinking about a black cat :frowning:

After reading that 4 years old Bug Report (br), I am not sure about what I wrote.

If myPicte.IsExportFormatSupported(Picture.FormatPNG) Then myPict.Image.Save(f, Picture.SaveAsPNG) End If

And I think (understand) the br is about the If line is erroneously returning True (and so do not work).

All in all, it is very suspicious to have a method that works the first time it is called and not on a second attempt; also, all of a sudden, after adding the code in the above If End If Block it works (10 times or so, then I powered off and left home).

Does your program turn GDI+ on in code anywhere?

It could have been.

But, yes, OS X.

I just checked: Use GDI+ is ON. I do not checked that on Windows 10 recently.

Same problem. It seems that if you use an image object (with 1x, 2x and 3x) for retina, instead of a link to the file, as before, this error occurred (in fact, you should have a IllegalOperationException error…

Thank you all.