Platforms to show: All Mac Windows Linux Cross-Platform

Back to TiffPictureMBS class.

Next items

TiffPictureMBS.AddCustomTag(Tag as Integer, FieldReadCount as Integer, FieldWriteCount as Integer, FieldType as Integer, FieldBit as Integer, OkToChange as Integer, PassCount as Integer, FieldName as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 8.7 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Adds a custom tag.
Example
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

Var t as new TiffPictureMBS

// open tiff

if not t.AddCustomTag(TIFFTAG_ASCIITAG, -1, -1, TIFF_ASCII, FIELD_CUSTOM, 1, 0, "MyString") then
MsgBox "AddCustomTag failed1."
end if

See tiff documentation for details.

Some examples using this method:

TiffPictureMBS.AddImage as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 5.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Writes existing picture and header information to file and starts a new one.
Example
Var t as TiffPictureMBS
Var f as FolderItem
Var p as Picture

f=SpecialFolder.Desktop.Child("test.tif")
t=new TiffPictureMBS
if t.Create(f) then

p=New Picture(100,100,32)
p.Graphics.ForeColor=rgb(255,0,0)
p.Graphics.FillOval 0,0,100,100
t.Pict=p
if t.WriteRGB then
if t.AddImage then
p=New Picture(100,100,32)
p.Graphics.ForeColor=rgb(0,0,255)
p.Graphics.FillOval 0,0,100,100
t.Pict=p
if t.WriteRGB then
MsgBox "Written multi picture tiff."
end if
end if
end if
end if

Returns true on success and false on any error.

Calls TIFFWriteDirectory internally.

TiffPictureMBS.close

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 3.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Closes the Tiff handle.

In 5.1 and older the destructor.
In 5.2 and later only closes the tiff handle so you can still read the pictures, the output or input buffer.

TiffPictureMBS.CombinePictureWithMask as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 6.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Returns a new picture which is created using the picture and it's mask.
Example
Var t as TiffPictureMBS
' ...
canvas1.backdrop=t.CombinePictureWithMask

TiffPictureMBS.Create(file as folderitem) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 4.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a new empty tiff file.
Example
Var p as Picture
Var f as FolderItem
Var t as TiffPictureMBS

p=New Picture(100,100,32)

f=SpecialFolder.Desktop.Child("test.tif")

t=new TiffPictureMBS
t.Pict=p

if t.Create(f) then
if t.WriteRGB then
t.Close
MsgBox "Ok"
f.Launch
end if
end if

Returns true on success.

See also:

TiffPictureMBS.Create(file as folderitem, endian as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 4.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a new empty tiff file.
Example
Var t As New TiffPictureMBS
t.Pict = LogoMBS(500)

// try with path
Var f As FolderItem = SpecialFolder.Desktop.Child("test.tif")

If t.Create(f, 0) Then
If t.WriteRGB Then
t.Close

// open in viewer
f.Launch
End If
End If

Returns true on success.

Endian settings:
0Default (System)
1BigEndian (Mac)
2LittleEndian (Win)

See also:

TiffPictureMBS.Create(Path as String, endian as integer = 0) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 19.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a new empty tiff file.
Example
Var t As New TiffPictureMBS
t.Pict = LogoMBS(500)

// try with path
Var f As FolderItem = SpecialFolder.Desktop.Child("test.tif")
Var p as string = f.NativePath

If t.Create(p) Then
If t.WriteRGB Then
t.Close

// open in viewer
f.Launch
End If
End If

Returns true on success.

Endian settings:
0Default (System)
1BigEndian (Mac)
2LittleEndian (Win)

See also:

TiffPictureMBS.CreateString(Size as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 5.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a new string based tiff writer.
Example
Function PictureToTiffStringMBS(pic as picture) As string
Var t as TiffPictureMBS

t=new TiffPictureMBS
if t.CreateString(&h100000) then
t.Pict=pic
if t.WriteRGB then
t.Close
Return t.OutputBuffer
end if
end if
End Function

Same as the Create() function, but memory based. You can now use functions like Scanline(), WriteSW() or WriteRGB() to put the picture data.

Returns true on success.
The Warning and Error events may show you reasons why it does not work.

The size parameter you pass in is a guess for the initial size of the memory block used. If more data is written, the memory block is resized, but it is quite slow to resize a memoryblock, so make a good guess!

You can and should use this function to write yourself a PictureToTiffString function. The plugin can not well make such a function as there are thousands of possible parameters combination you may want to use. (compared to the JPEG library where you only have the compression level parameter.)

See also:

Some examples using this method:

TiffPictureMBS.CreateString(Size as Integer, Mode as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 5.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a new string based tiff writer.

Same as the other CreateString method, but you can pass a mode string to the library.

mode="wb" for big endian and mode="wl" for little endian.

See also:

TiffPictureMBS.Flush as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 5.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Flush causes any pending writes for the specified file (including writes for the current directory) to be done.

In normal operation this call is never needed - the library automatically does any flushing required.

TiffPictureMBS.FlushData as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 5.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
FlushData flushes any pending image data for the specified file to be written out; directory-related data are not flushed.

In normal operation this call is never needed Å| the library automatically does any flushing required.

TiffPictureMBS.ImageCount as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 4.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Returns the number of images in the TIFF file.

Returns 0 on any error.

TiffPictureMBS.ImageIndex as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 4.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
The current image index.

0 based.

TiffPictureMBS.IsLastImage as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 4.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Whether the current picture is the last picture.

Useful if you walk through all pictures using NextImage.

TiffPictureMBS.MirrorVertical(output as TiffPictureMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 7.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Mirrors the current picture to another tiff object.

You may be able to pass the current tiff file as the output one if you have it open for read and write.
Returns true on success and false on failure.
Works for any color depth or color mode.

TiffPictureMBS.NextImage as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 4.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Loads the next image in the TIFF file.

Returns true on success and false on any error.

See also:

TiffPictureMBS.NextImage(HeaderOnly as boolean) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 4.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads the next image.

If HeaderOnly is false the current picture is read into the pict&mask properties.

See also:

TiffPictureMBS.Open(file as folderitem) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 4.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Opens a tiff file for readonly access.

You need to use the ReadRGB method or the Scanline property to get data from this file.
Returns true on success.

See also:

TiffPictureMBS.Open(file as folderitem, Mode as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 5.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Opens a tiff file for read/write access.
Example
Var file as folderitem = SpecialFolder.desktop.child("test.tif")
Var st as new MyTiff

// open for appending
if not st.Open(file,"r+") then
MsgBox "Open Tiff failed!"
else
// change one setting
st.Copyright = "Hello World"

// and save
call st.SaveImage
st.Close
end if

Same as the other Open method, but you can pass a mode string to the library.

The open mode parameter can include the following flags in addition to the "r" (Read), "w" (Write), and "a" (Append) flags. Note however that option flags must follow the read-write-append specification.

lWhen creating a new file force information be written with Little-Endian byte order (but see below). By default the library will create new files using the native CPU byte order.
bWhen creating a new file force information be written with Big-Endian byte order (but see below). By default the library will create new files using the native CPU byte order.
LForce image data that is read or written to be treated with bits filled from Least Significant Bit (LSB) to Most Significant Bit (MSB). Note that this is the opposite to the way the library has worked from its inception.
BForce image data that is read or written to be treated with bits filled from Most Significant Bit (MSB) to Least Significant Bit (LSB); this is the default.
HForce image data that is read or written to be treated with bits filled in the same order as the native CPU.
MEnable the use of memory-mapped files for images opened read-only. If the underlying system does not support memory-mapped files or if the specific image being opened cannot be memory-mapped then the library will fallback to using the normal system interface for reading information. By default the library will attempt to use memory-mapped files.
mDisable the use of memory-mapped files.
CEnable the use of "strip chopping" when reading images that are comprised of a single strip or tile of uncompressed data. Strip chopping is a mechanism by which the library will automatically convert the single-strip image to multiple strips, each of which has about 8 Kilobytes of data. This facility can be useful in reducing the amount of memory used to read an image because the library normally reads each strip in its entirety. Strip chopping does however alter the apparent contents of the image because when an image is divided into multiple strips it looks as though the underlying file contains multiple separate strips. Finally, note that default handling of strip chopping is a compile-time configuration parameter. The default behaviour, for backwards compatibility, is to enable strip chopping.
cDisable the use of strip chopping when reading images.

See also:

TiffPictureMBS.Open(Path as String, Mode as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 19.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Opens a tiff file for read/write access.
Example
Var t As New TiffPictureMBS

// try with path
Var f As FolderItem = SpecialFolder.Desktop.Child("test.tif")
Var p As String = f.NativePath

If t.Open(p, "r") Then

If t.ReadRGB Then

window1.Backdrop = t.Pict

End If
End If

Same as the other Open method, but you can pass a mode and path as string to the library.

The open mode parameter can include the following flags in addition to the "r" (Read), "w" (Write), and "a" (Append) flags. Note however that option flags must follow the read-write-append specification.

lWhen creating a new file force information be written with Little-Endian byte order (but see below). By default the library will create new files using the native CPU byte order.
bWhen creating a new file force information be written with Big-Endian byte order (but see below). By default the library will create new files using the native CPU byte order.
LForce image data that is read or written to be treated with bits filled from Least Significant Bit (LSB) to Most Significant Bit (MSB). Note that this is the opposite to the way the library has worked from its inception.
BForce image data that is read or written to be treated with bits filled from Most Significant Bit (MSB) to Least Significant Bit (LSB); this is the default.
HForce image data that is read or written to be treated with bits filled in the same order as the native CPU.
MEnable the use of memory-mapped files for images opened read-only. If the underlying system does not support memory-mapped files or if the specific image being opened cannot be memory-mapped then the library will fallback to using the normal system interface for reading information. By default the library will attempt to use memory-mapped files.
mDisable the use of memory-mapped files.
CEnable the use of "strip chopping" when reading images that are comprised of a single strip or tile of uncompressed data. Strip chopping is a mechanism by which the library will automatically convert the single-strip image to multiple strips, each of which has about 8 Kilobytes of data. This facility can be useful in reducing the amount of memory used to read an image because the library normally reads each strip in its entirety. Strip chopping does however alter the apparent contents of the image because when an image is divided into multiple strips it looks as though the underlying file contains multiple separate strips. Finally, note that default handling of strip chopping is a compile-time configuration parameter. The default behaviour, for backwards compatibility, is to enable strip chopping.
cDisable the use of strip chopping when reading images.

See also:

TiffPictureMBS.OpenString(data as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 5.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Opens a tiff image located in a binary string.
Example
Function TiffStringToPicture(data as string) As picture
Var t as MyTiffPictureMBS

t=new MyTiffPictureMBS

if t.OpenString(data) then
if t.ReadRGB then
return t.Pict
// you could add the mask here.
end if
end if

Return nil // failed
End Function

Same as the Open() function, but memory based. You can now use functions like Scanline(), ReadSW() or ReadRGB() to get the picture data.

Returns true on success.
The Warning and Error events may show you reasons why it does not work.
The string you pass is saved in the data property of the class for later use.

You can and should use this function to write yourself a TiffStringToPicture function.

See also:

TiffPictureMBS.OpenString(data as string, Mode as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 5.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Opens a tiff image located in a binary string.

Same as the other OpenString method, but you can pass a mode string to the library.

See also:

TiffPictureMBS.VStripSize(nrows as UInt32) as UInt64

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 13.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Returns the number of bytes in a strip with nrows rows of data.

TiffPictureMBS.VTileSize(nrows as UInt32) as UInt64

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 13.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Returns the number of bytes in a row-aligned tile with nrows of data.

TiffPictureMBS.WriteBW as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 5.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Write a black & white image.
Example
Var p as Picture
Var f as FolderItem
Var t as TiffPictureMBS

p=New Picture(100,100,32)
p.Graphics.ForeColor=rgb(0,0,0)
p.Graphics.FillOval 0,0,100,100

f=SpecialFolder.Desktop.Child("test.tif")

t=new TiffPictureMBS

if t.Create(f) then
t.Pict=p
if t.WriteBW then
MsgBox "ok"
end if
end if

Backdrop=p

Uses the pictures in the pict property to write a picture.
Currently masks are not supported.

The following settings are made before the image data is written:
PlanarConfig = PLANARCONFIG_CONTIG
Photometric = PHOTOMETRIC_MINISBLACK
BitsPerSample = 1
SamplesPerPixel = 1
FillOrder = FILLORDER_MSB2LSB
VerticalResolution = 72
HorizontalResolution = 72
Orientation = ORIENTATION_TOPLEFT
ResolutionUnit = RESUNIT_INCH
Compression = COMPRESSION_NONE

You may change settings before or later. For example if you set Compression before it should be used for writing image data to the file.
Returns true on success.

This method uses the YieldTicks property and may yield time to other threads.

Some examples using this method:

TiffPictureMBS.WriteEncodedStrip(strip as UInt32, data as Memoryblock, size as Integer = 0) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 13.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Compress and write a strip of data to an open TIFF file.

Compress size bytes of raw data from buf and write the result to the specified strip; replacing any previously written data. Note that the value of strip is a ‘‘raw strip number.'' That is, the caller must take into account whether or not the data are organized in separate planes (PlanarConfiguration=2).

The library writes encoded data using the native machine byte order. Correctly implemented TIFF readers are expected to do any necessary byte-swapping to correctly process image data with BitsPerSample greater than 8.

The strip number must be valid according to the current settings of the ImageLength and RowsPerStrip tags. An image may be dynamically grown by increasing the value of ImageLength prior to each call to WriteEncodedStrip.

Returns −1 is returned if an error was encountered. Otherwise, the value of size is returned.
If size is zero, we use the size of memoryblock.

TiffPictureMBS.WriteEncodedTile(tile as UInt32, data as Memoryblock, size as Integer = 0) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 13.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Compress and write a tile of data to an open TIFF file.

Compress size bytes of raw data from buf and append the result to the end of the specified tile. Note that the value of tile is a "raw tile number". That is, the caller must take into account whether or not the data are organized in separate places (PlanarConfiguration=2). ComputeTile automatically does this when converting an (x,y,z,sample) coordinate quadruple to a tile number.

The library writes encoded data using the native machine byte order. Correctly implemented TIFF readers are expected to do any necessary byte-swapping to correctly process image data with BitsPerSample greater than 8.

Returns −1 is returned if an error was encountered. Otherwise, the value of size is returned.

If size is zero, we use the size of memoryblock.

Next items

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


The biggest plugin in space...