ExportPicture on Windows is Seriously Limited

One solution : use ImageMagick from http://www.imagemagick.org/

Create a bmp in specialfolder.temporary and convert it to whatever of the over 100 formats ImageMagick supports and save where the user has decided.

Sure, it is a shell, but with a beautiful output.

Alternatively, MBS has an ImageMagick plugin.

You can also revert to 2013R3.3 which still supported Quicktime, if I remember right. Or wait wait wait and cry cry cry…

Does such workaround work for people like me who never had Quicktime in my Windows system? I expect a crash in such systems. Compiled app loads and don’t find quicktime installed, dependent DLLs and such things.

We discussed this theme before, the suggestion was adding a xplat graphic lib IN Xojo. Allowing proper xplat formats as expected and even adding vector graphics (we discussed about SVG if I do recall the talks).

I just tried 2013R3.3 on Windows 10 Tech Preview where there were never any Quicktime installed, and it saves gracefully in all sorts of formats. No crash at all. So I guess the Quicktime stuff is inside Xojo.

If one does not need the new framework, I am inclined to think this is the solution.

Try now with the latest Xojo. If you can’t, it’s not a solution at all. :slight_smile:

We need xplat consistency, at least PNG and SVG on all.

[quote=157559:@Rick Araujo]Try now with the latest Xojo. If you can’t, it’s not a solution at all. :slight_smile:

We need xplat consistency, at least PNG and SVG on all.[/quote]

I am not interested in an ideal world. I am only interested in the results I can get with the tools at hand. That is called pragmatism.

Yes, it would be nice to have exactly the same features on Windows that Mac OS X provides. Unfortunately, Windows does not provide them. So if Xojo wanted to support other file format they would have to distract their precious development time from 64 bit to code the saveasJPG and other things I can survive without.

If I were in Robert shoes, who has been around for long enough to have used 2013R3.3, I would not hesitate an instant and come back to it to have my project built in no time. But that is just me.

If I absolutely needed features found only in 2014R3.1 for Windows (wonder which ones given the little love that platform gets), then I would look into ImageMagick.

I could even have my cake and it it too by creating a helper app in 2013R3.3 dedicated to generating all the formats it supports, that I call with 2014R3.1.

About SVG, Norman posted some code somewhere that seemed fairly easy to use.

Gimme 64 bit first. Then, if you have some spare time, look into the gazillion bug reports that need fixing for yesterday. Then if you really have nothing else to do…

Maybe its my ignorance on the subject of image formats, but what is the difference between Picture.Save and ExportPicture? On my Windows install (W7) Picture.Save allows to save in different formats even though ExportPicture only does BMP. Wouldn’t this be a “workaround”?

Until this thread I wasn’t even aware of ExportPicture. It looks like a combination of SaveAsDialog and Picture.Save.

Here is a quick replacement. You will need to create a FileType set for the image formats you wish to support.

[code]Function myExportPicture(p As Picture) As Boolean
#If TargetWin32
Dim dlg As New SaveAsDialog
Dim f as FolderItem

dlg.InitialDirectory = SpecialFolder.Desktop
dlg.PromptText = “Save your image”
dlg.SuggestedFileName = “My Image”
dlg.Title = “Save your image”
dlg.Filter = ImageTypes.All

f = dlg.ShowModal()

If f <> Nil Then
If f.Name.Right(3) = “png” Then
p.Save(f, Picture.SaveAsPNG)
ElseIf f.Name.Right(3) = “jpg” Then
p.Save(f, Picture.SaveAsJPEG, Picture.QualityHigh)
ElseIf f.Name.Right(3) = “gif” Then
p.Save(f, Picture.SaveAsGIF)
ElseIf f.Name.Right(3) = “tif” Then
p.Save(f, Picture.SaveAsTIFF)
ElseIf f.Name.Right(3) = “bmp” Then
p.Save(f, Picture.SaveAsWindowsBMP)
Else
Return False
end if
Else
Return False
end if

Return True
#ElseIf TargetMacOS
Return ExportPicture§
#EndIf
End Function[/code]

Bob,

thank you for sharing the code (above).

But, in Windows 8.1, you do not need to place file type(s) in the save name dialog and so your code (like Xojo own code) will not work at all since there is no file extension in the file name.

Nota: this is allowed by WIndows 8.1, not the loom of my magination.

And because file extensions are invisible by default, one may ask why the application does not works.

Windows 8.1
Xojo 2014r3.1

I have switched to using picture.save and generated a window which provides options for the user to select. It is not as user friendly as exportpicture, but it works well on Windows. But then when I try to use the same code for a Mac OSX version, I find jpeg, png and bmp saves work, but even though I validate capability, I get an error of UnsupportedFormatException with the following statement for Tiff files:

SaveAsPicture doesn’t support format 403 on the Macintosh. I get the same error (though different format integers) for gifs.
Here is the code I am using. buffer1 is a 32 bit picture. color_text is a text field.

Dim f as FolderItem
f=GetSaveFolderItem( "","mypic.gif")

if f<>nil and buffer1.IsExportFormatSupported(Picture.FormatGIF) then
  buffer1.Save(f, Picture.SaveAsGIF)
  color_text.text =  "The picture was saved as a GIF to "+f.absolutepath
else
  color_text.text = "Your picture was not saved"
end

This same code works fine in Windows 7 and 8 with GDI+. I must be doing something wrong since this is the accepted way to save pictures now.

Can someone provide me with some sample code based on picture.save that works on OSX for tiffs and gifs?

or use export picture on OS X and Picture.Save on Windows

Are you confirming that picture.save only works properly on Windows?

That appears to be the case. What I am trying to do is provide an identical experience for my users whether they are Mac or Windows users. Having to use two different methods, one with a nice user interface (exportPicture) and one without (picture.save) is a unfortunate.

To make matters worse, the Language Reference for both methods is badly out of date, and in many cases, wrong. But I do appreciate all the time and insights you have put into this discussion.

They work differently and one may meet your needs on one platform and the other on another.

There are always areas where things can’t be 100% x-platform.
COM is not supported on anything but Windows.
And Apple Script only works on OS X.
Even where there is a similar API x-platform it may NOT be identical x-platform.
On Windows most controls CAN get focus but not so on OS X even when you have full keyboard access on.

Thats the nature of being a x-platform tool.
We try to make things as similar as we can but there are spots where that’s not possible (or simply hasn’t happened).
OS X happens to natively handle & provide a lot of image I/O mechanisms and formats.
Windows doesn’t.

This is one of those areas.

While I appreciate you want to provide an identical experience Xojo doesn’t natively make that possible. We use native OS routines & so whats possible is limited by that choice.
So you may need to look at a plugin or other options to extend whats possible.

Is Xojo supporting WindowsScript on Windows ?

Or Xojo can do that by itself.

Emile- I agree 100%. Xojo has the talent to provide a working version of ExportPicture with at least a subset of options on Windows, but when I asked for that, I was told it was not possible. And yet we both know it is possible by using internal Xojo routines based on picture.save. I am a relatively poor programmer and compared to the programmers at Xojo, a hack. But I am left trying to do this on my own.

I am sure Norman feels it would be a good exercise for me to do this on my own, and that I should be ashamed for not having the necessary talent. But given the price of Xojo, I think a greater effort could be made to provide genuine cross-platform set of statements that handle pictures. But that is no longer the case.

Simply put, Xojo is becoming less cross-platform with every release. That is not a good trend and may ultimately chase some potential clients away. I love Xojo and will simply hang in there. But I will not go gently into that night.