Platforms to show: All Mac Windows Linux Cross-Platform

/Images/Tiff/Custom Tiff Tags


Required plugins for this example: MBS Images Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Images/Tiff/Custom Tiff Tags

This example is the version from Sun, 17th Mar 2012.

Project "Custom Tiff Tags.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
EventHandler Sub Open() const TIFFTAG_ASCIITAG = 40666 const TIFFTAG_LONGTAG = 40667 const TIFFTAG_SHORTTAG = 40668 const TIFFTAG_RATIONALTAG = 40669 const TIFFTAG_FLOATTAG = 40670 const TIFFTAG_DOUBLETAG = 40671 const TIFFTAG_BYTE = 40672 const TIFFTAG_SOFTWARE=305 const TIFF_BYTE=1 const TIFF_ASCII=2 const TIFF_SHORT=3 // integer 16 bit signed const TIFF_LONG=4 // integer 32 bit const TIFF_FLOAT=11 const TIFF_DOUBLE=12 const FIELD_CUSTOM = 65 dim ofile,file as FolderItem dim value as string dim m as MemoryBlock dim count as integer // you can destroy your tiff much too easy, so we copy it from a template file=SpecialFolder.Desktop.Child("test.tif") file.Delete file=SpecialFolder.Desktop.Child("test.tif") ofile=SpecialFolder.Desktop.Child("testTemplate.tif") ofile.CopyFileTo file file=SpecialFolder.Desktop.Child("test.tif") dim t as new TiffPictureMBS if t.Open(file, "r+") then if t.GetFieldString(TIFFTAG_SOFTWARE, value) then MsgBox value else MsgBox "Failed to read string." end if // register fields if not t.AddCustomTag(TIFFTAG_ASCIITAG, -1, -1, TIFF_ASCII, FIELD_CUSTOM, 1, 0, "MyString") then MsgBox "AddCustomTag failed1." end if if not t.AddCustomTag(TIFFTAG_LONGTAG, 1, 1, TIFF_LONG, FIELD_CUSTOM, 0, 1, "MyInteger") then MsgBox "AddCustomTag failed2." end if // set fields if t.SetFieldString(TIFFTAG_ASCIITAG, "Tag contents")=false then MsgBox "SetFieldString failed." end if m=NewMemoryBlock(4) m.Long(0)=2008 if t.SetFieldMemory(TIFFTAG_LONGTAG,1, m)=false then MsgBox "SetFieldInteger failed." end if call t.RewriteDirectory t.Close else MsgBox "Failed to open tiff 1" end if t = new TiffPictureMBS if t.Open(file, "r") then // read generic field (unknown to tiff lib) m=t.GetFieldMemory(TIFFTAG_ASCIITAG, count) MsgBox str(count)+" bytes in string" if m=nil then MsgBox "Failed to read data" else MsgBox m.cstring(0) end if // read generic field (unknown to tiff lib) m=t.GetFieldMemory(TIFFTAG_LONGTAG, count) MsgBox str(count)+" integer value found." if m=nil or count=0 then MsgBox "Failed to read data" else MsgBox str(m.long(0)) end if t.Close else MsgBox "Failed to open tiff 2" end if End EventHandler
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project

The items on this page are in the following plugins: MBS Images Plugin.


The biggest plugin in space...