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.NSImageMBSDim n AsNew NSImageMBS(p)
Dim tiff AsString = n.TIFFRepresentation
Dim file1 As FolderItem = SpecialFolder.Desktop.Child("test1.tif")
Dim b As BinaryStream = BinaryStream.Create(file1)
//2.CGImageDestinationMBSDim 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)
If dest.Finalize Then//MsgBox"Saved"Else
MsgBox "Failedtosave."EndIf//3.GMImageMBSDim gmimage AsNew GMImageMBS(p)
Dim file3 As FolderItem = SpecialFolder.Desktop.Child("test3.tif")
//4.TiffPictureMBSDim t AsNew TiffPictureMBS
Dim file4 As FolderItem = SpecialFolder.Desktop.Child("test4.tif")
t.Pict = p
If t.Create(file4) ThenIf t.WriteRGB Then
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.
As you may know, we use TagLib, an open source library to read metadata from audio files, e.g. ID3 tags.
With our TagLibFileRefMBS class you can read properties of an audio file including all the common values like artist, title, album or comment. We now got a setProperties method to update the properties and add/change/delete a few. Just pass in the dictionary with changes. Keys with nil values remove an entry and otherwise add or replace it:
Dim file As FolderItem = SpecialFolder.Desktop.Child("test.mp3")
Dim tag AsNew TagLibFileRefMBS(file)
Dim dic As Dictionary = tag.Properties
dic.Value("ARTIST") = "JohnDoe"
dic.Value("ALBUM") = Nil//clearthisone
If tag.Save Then
Currently TagLib supports both ID3v1 and ID3v2 for MP3 files, Ogg Vorbis comments and ID3 tags and Vorbis comments in FLAC, MPC, Speex, WavPack, TrueAudio, WAV, AIFF, MP4 and ASF files.
If you use WIA classes in MBS Xojo Win Plugin or WIA functions in MBS FileMaker Plugin, you may run into some Windows specific error codes. They all start with hex 8021 and below is a list of Windows Image Acquisition (WIA) error codes.
The device is busy. Close any apps that are using this device or wait for it to finish and then try again.
One or more of the device’s cover is open.
Communication with the WIA device failed. Make sure that the device is powered on and connected to the PC. If the problem persists, disconnect and reconnect the device.
The device is locked. Close any apps that are using this device or wait for it to finish and then try again.
The device driver threw an exception.
An unknown error has occurred with the WIA device.
There is an incorrect setting on the WIA device.
The device doesn't support this command.
The response from the driver is invalid.
The WIA device was deleted. It's no longer available.
The scanner's lamp is off.
A scan job was interrupted because an Imprinter/Endorser item reached the maximum valid value for WIA_IPS_PRINTER_ENDORSER_COUNTER, and was reset to 0. This feature is available with Windows 8 and later versions of Windows.
A scan error occurred because of a multiple page feed condition. This feature is available with Windows 8 and later versions of Windows.
The device is offline. Make sure the device is powered on and connected to the PC.
There are no documents in the document feeder.
Paper is jammed in the scanner's document feeder.
An unspecified problem occurred with the scanner's document feeder.
The device is warming up.
There is a problem with the WIA device. Make sure that the device is turned on, online, and any cables are properly connected.
No scanner device was found. Make sure the device is online, connected to the PC, and has the correct driver installed on the PC.
For next MBS Xojo Plugin, we add a LZ4 compression module called LZ4MBS. LZ4 is a lossless compression algorithm with high performance.
We have Compress and Decompress methods for handling data in string and MemoryBlocks in Xojo:
Dim m AsString = "Loremipsumdolorsitamet,consecteturadipiscingelit.Loremipsumdolorsiteamat."//makesureencodingisset
m = ConvertEncoding(m, encodings.UTF8)
//compressDim c AsString = LZ4MBS.Compress(m)
//decompressDim d AsString = LZ4MBS.Decompress(c)
d = DefineEncoding(d, encodings.UTF8)
//andcheckIf d = m Then
You can download 19.4pr6 in the next days and try it. Please contact us if you have questions.
With MBS Plugin 19.4 we will include newer Java methods to make your live easier when working with Java classes in Xojo. Instead of passing arguments as memoryblock or checking which of the various methods to use, we simply use variants.
For fields, you can now use Field() or StaticField() methods to get or set the values. Values are passed as variant and we check which type is needed and do required conversions. All the normal data types should work fine this way like integers, floats, booleans or strings. You can pass/receive JavaObjectMBS and subclasses of course. And for arrays please use the JavaArrayMBS subclasses. As a convenience you can pass in Java string with a Xojo string and we create the java string for you.
For method calls, we got CallMethod, CallNonvirtualMethod and CallStaticMethod to call methods and pass arguments as array of variants. Same for NewObject method to create a new object by calling the constructor.
The September/October (17.5) issue of xDev Magazine is now available. Here's a quick preview of what's inside:
Numbers Please! Part 4 by Markus Winter
What is a number? And just how do you tell a program to detect a number? It's much more complicated than you'd think -- hope you like Regex formulas!
What's New in the MBS Plugins by Stefanie Juchmes
Based on Christian's talk at the Miami Xojo Conference, Stefanie covers many new aspects of the Monkeybread Plugins you might have missed.
Maps (Part 1) by Markus Winter
Would you like to include maps in your application? Be careful, as what used to be free now costs a fortune. Markus sets the stage for saving money by switching to Apple Maps.
Your First Web App -- Part 2 by Paul Budd
Paul continues to build his Web app, this time incorporating the functionality of adding records, searching, and using SQL prepared statements.
PLUS: Shared properties, power user features, standard operating procedures, Best of the Web, and more!
Xojo features a data type called currency. It is used for storing currency values and uses internally a 64bit value. As 4 digits are reserved for right of the dot, the 1.0 value is stored internally as 10000. When converting between double and integer, values are divided/multiplied by 10000.
There is a problem:
Double values are only precise for 15 digits, so having a big value like 123456789012345.1234 in a currency will not work correctly, as this can't be stored in a double. You get 123456789012345.1136. There are rounding issues.
But some of use need to work with huge numbers and functions like val() internally use double, so there are rounding issues with parsing.
For next plugin we'll add a function CurrencyValueMBS to fix that. Our CurrencyValueMBS function will return currency values parsed up to "+922337203685477.5807" just fine. If value is out of range, we raise an exception, so you can track down errors.
About 12 years ago we started the development of our DynaPDF Plugin.
After a year of development, the plugin was released to the public on 1st Sep 2007 with MBS Plugin 7.6pr1.
This plugin has been a big success for us and provides the PDF engine to thousands of Xojo applications around the world. Based on user feedback we got a lot of functions over the years like the raster engine, PDF/A conversion and ZUGFeRD support.
Please make sure you try the plugin, make it part of your toolbox and start to enjoy all the PDF features you can add to your application.