Xojo Conferences
MBSOct2019CologneDE
XDCMarch2020NashvilleUS

« FileMaker Marketplace… | Home | Neues vom MBS Plugin … »

Four ways to save picture as Tiff in Xojo


Depending on your needs, we can offer four different ways to save a picture in tiff (and other) formats.

NSImageMBS is a high level class for handling images on MacOS and it can save in various formats. CGImageDestinationMBS offers a way to export in something like 20 formats on MacOS and iOS (public.jpeg, public.png, com.compuserve.gif, public.tiff, public.jpeg-2000, com.apple.atx, org.khronos.ktx, org.khronos.astc, public.heic, com.microsoft.ico, com.microsoft.bmp, com.apple.icns, com.adobe.photoshop-image, com.adobe.pdf, com.truevision.tga-image, com.ilm.openexr-image, public.pbm, public.pvr).

For cross platform projects, you can for example try GMImageMBS class, which can write in over 100 formats. If you need tiff specific details, you may want to check our dedicated TiffPictureMBS class, which allows you to control all details and lets you set individual header fields.

Dim p As Picture = LogoMBS(500) // 1. NSImageMBS Dim n As New NSImageMBS(p) Dim tiff As String = n.TIFFRepresentation Dim file1 As FolderItem = SpecialFolder.Desktop.Child("test1.tif") Dim b As BinaryStream = BinaryStream.Create(file1) b.Write tiff b.Close // 2. CGImageDestinationMBS Dim image As CGImageMBS = CGImageMBS.CreateImage(p) Dim file2 As FolderItem = SpecialFolder.Desktop.Child("test2.tif") Dim dest As CGImageDestinationMBS = CGImageDestinationMBS.CreateWithFile(file2, "public.tiff", 1) dest.AddImage(image, Nil) If dest.Finalize Then // MsgBox "Saved" Else MsgBox "Failed to save." End If // 3. GMImageMBS Dim gmimage As New GMImageMBS(p) Dim file3 As FolderItem = SpecialFolder.Desktop.Child("test3.tif") gmimage.write(file3) // 4. TiffPictureMBS Dim t As New TiffPictureMBS Dim file4 As FolderItem = SpecialFolder.Desktop.Child("test4.tif") t.Pict = p If t.Create(file4) Then If t.WriteRGB Then t.Close // ok Else Break End If Else Break End If
Please do not hesitate to contact us with questions. And bring your projects with questions to the Xojo conferences to talk directly to us or Xojo engineers.
13 09 19 - 09:31