Platforms to show: All Mac Windows Linux Cross-Platform

Back to TiffPictureMBS class.

TiffPictureMBS.RawStripSize(strip 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 raw strip (i.e. not decoded).

TiffPictureMBS.ReadBW 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 current picture in BW mode.
Example
Var f as FolderItem
Var p as Picture
Var t as TiffPictureMBS

f=SpecialFolder.Desktop.Child("Multipage fax.tif")
t=f.OpenAsTiffMBS(true)

if t.ReadBW then
title=str(t.ImageCount)

p=t.pict
Title=str(p.Depth)
Canvas1.Backdrop=p
end if

Returns true on success and false on any error.
Only if the current picture is a 1bit black&white picture, a new picture is created in the pict property and the data is copied inside.

Data in the TIFF file must be in 1 bit BW mode. Else use ReadRGB which does a lot of converting.

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

See also:

Some examples using this method:

TiffPictureMBS.ReadBW(left as Integer, top as Integer, width as Integer, height as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 8.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads the current picture in BW mode.
Example
Var f as FolderItem
Var p as Picture
Var t as TiffPictureMBS

f=SpecialFolder.Desktop.Child("Multipage fax.tif")
t=f.OpenAsTiffMBS(true)

if t.ReadBW(0,0,t.width/2,t.height/2) then
title=str(t.ImageCount)

p=t.pict
Title=str(p.Depth)
Canvas1.Backdrop=p
end if

Returns true on success and false on any error.
Only if the current picture is a 1bit black&white picture, a new picture is created in the pict property and the data is copied inside.

Data in the TIFF file must be in 1 bit BW mode. Else use ReadRGB which does a lot of converting.

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

See also:

TiffPictureMBS.ReadEncodedStrip(strip as UInt32, byref data as Memoryblock) as UInt32

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

Read the specified strip of data and place up to size bytes of decompressed information in the (user supplied) data buffer.

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). To read a full strip of data the data buffer should typically be at least as large as the number returned by StripSize.
The library attempts to hide bit- and byte-ordering differences between the image and the native machine by converting data to the native machine order. Bit reversal is done if the FillOrder tag is opposite to the native machine bit order. 16- and 32-bit samples are automatically byte-swapped if the file was written with a byte order opposite to the native machine byte order,

Returns the actual number of bytes of data that were placed in buf is returned; ReadEncodedStrip returns -1 if an error was encountered.

TiffPictureMBS.ReadEncodedTile(tile as UInt32, byref data as Memoryblock) as Integer

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

Read the specified tile of data and place up to size bytes of decompressed information in the (user supplied) data buffer.

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 planes (PlanarConfiguration=2). ComputeTile automatically does this when converting an (x,y,z,sample) coordinate quadruple to a tile number. To read a full tile of data the data buffer should be at least as large as the value returned by TileSize.

The library attempts to hide bit- and byte-ordering differences between the image and the native machine by converting data to the native machine order. Bit reversal is done if the FillOrder tag is opposite to the native machine bit order. 16- and 32-bit samples are automatically byte-swapped if the file was written with a byte order opposite to the native machine byte order,

Returns the actual number of bytes of data that were placed in buf is returned; ReadEncodedTile returns −1 if an error was encountered.

TiffPictureMBS.ReadPreviewBW as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 9.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads the current picture in BW mode as a preview.

This method is faster than ReadBW, because it reads only every 8th line and every 8th pixel in each row. So the picture you get is much smaller, but may be enough for a preview.

Returns true on success and false on any error.
Only if the current picture is a 1bit black&white picture, a new picture is created in the pict property and the data is copied inside.

Data in the TIFF file must be in 1 bit BW mode. Else use ReadRGB which does a lot of converting.

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

See also:

Some examples using this method:

TiffPictureMBS.ReadPreviewBW(left as Integer, top as Integer, width as Integer, height as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 9.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads the current picture in BW mode as a preview.

This method is faster than ReadBW, because it reads only every 8th line and every 8th pixel in each row. So the picture you get is much smaller, but may be enough for a preview.

Returns true on success and false on any error.
Only if the current picture is a 1bit black&white picture, a new picture is created in the pict property and the data is copied inside.

Data in the TIFF file must be in 1 bit BW mode. Else use ReadRGB which does a lot of converting.

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

See also:

TiffPictureMBS.ReadPreviewRGB(ReduceFactor as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 9.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads a CMYK or RGB picture and stores it in the pict and name properties.

This method is faster than ReadRGB, because it reads only every ReduceFactorth line and every ReduceFactorth pixel in each row. So the picture you get is much smaller, but may be enough for a preview.

Returns true on success.
ReadRGB does converting on the picture data if needed so you can read CMYK, RGB, BW and other image data using this function.

This function works with most Tiff formats, but has problems with some like 16 bit CMYK.

Some examples using this method:

TiffPictureMBS.ReadRawStrip(strip as UInt32, byref data as Memoryblock) as UInt32

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 13.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Return the undecoded contents of a strip of data from an open TIFF file.

Read the contents of the specified strip into the (user supplied) data buffer. Note that the value of strip is a "raw strip number". That is, the caller must take into account whether or not the data is organized in separate planes (PlanarConfiguration=2). To read a full strip of data the data buffer should typically be at least as large as the number returned by StripSize.

Returns the actual number of bytes of data that were placed in buf is returned; ReadEncodedStrip returns -1 if an error was encountered.

TiffPictureMBS.ReadRawTile(tile as UInt32, byref data as Memoryblock) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 13.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Return an undecoded tile of data from an open TIFF file.


Read the contents of the specified tile into the (user supplied) data buffer. Note that the value of tile is a "raw tile number". That is, the caller must take into account whether or not the data is organized in separate planes (PlanarConfiguration=2). ComputeTile automatically does this when converting an (x,y,z,sample) coordinate quadruple to a tile number. To read a full tile of data the data buffer should typically be at least as large as the value returned by TileSize.

Returns the actual number of bytes of data that were placed in buf is returned; ReadEncodedTile returns −1 if an error was encountered.

TiffPictureMBS.ReadRGB as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 4.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads a CMYK or RGB picture and stores it in the pict and name properties.

Returns true on success.
ReadRGB does converting on the picture data if needed so you can read CMYK, RGB, BW and other image data using this function.

This function works with most Tiff formats, but has problems with some like 16 bit CMYK.

See also:

Some examples using this method:

TiffPictureMBS.ReadRGB(byref ErrorMessage as string, Dest as MemoryBlock = nil) as memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads the image into a memoryblock as RGB.

The Scanline() array gives you the raw uncompressed data. But this method decodes the data into a RGBA image.

The Memoryblock has the size of 4*width*height. Each pixel has one byte for red, one byte for green, one byte for blue and one byte for alpha. If no alpha is in the file, all pixels have the same alpha of 255.

If the decompression fails the function returns nil. (e.g. out of memory).
If the decoding fails, you also get an error message.

This function works with most Tiff formats, but has problems with some like 16 bit CMYK.

If dest is not nil and big enough, the plugin will use it and return it on success. This can avoid additional memory allocations which can cost CPU time (especially to clear the bytes).

See also:

TiffPictureMBS.ReadRGBMemoryBegin(byref ErrorMessage as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 10.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Starts a RGBA reader for the given TIFF picture.

Like ReadRGB, but with ReadRGBMemoryBegin, ReadRGBMemoryEnd and ReadRGBMemoryStep you can read the RGBA data in portions.

The Memoryblock returned by ReadRGBMemoryStep has the size of 4*width*height. Each pixel has one byte for red, one byte for green, one byte for blue and one byte for alpha. If no alpha is in the file, all pixels have the same alpha of 255.

If the decompression fails the function returns false. (e.g. out of memory).
If the decoding fails, you also get an error message.

This function works with most Tiff formats, but has problems with some like 16 bit CMYK.

TiffPictureMBS.ReadRGBMemoryEnd

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 10.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Cleans up the internal data structures created by ReadRGBMemoryBegin.

TiffPictureMBS.ReadRGBMemoryStep(x as Integer, y as Integer, width as Integer, height as Integer, Dest as MemoryBlock = nil) as memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 10.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads the image into a memoryblock as RGBA.
Example
Var t as new TiffPictureMBS
Var f as FolderItem = SpecialFolder.Desktop.Child("test.tif")
Var e as string

if t.Open(f) then
if t.ReadRGBMemoryBegin(e) then

Var w as Integer = t.Width
Var h as Integer = t.Height

Var p as new PictureMBS(w, h, PictureMBS.ImageFormatRGB)

for y as Integer = 0 to h-1 step 100

Var m as MemoryBlock = t.ReadRGBMemoryStep(0, y, w, 100)

for i as Integer = 0 to 99
p.RowInFormat(i+y, PictureMBS.ImageFormatRGBA)=m
next

next

t.ReadRGBMemoryEnd
Backdrop = p.copypicture(0,0,1000,1000) // display a portion
end if

end if

As you see in the example, you can use this method to easily read huge TIFF files into a PictureMBS object.

If the decompression fails the function returns nil. (e.g. out of memory).
Please make sure that the range in x and y, width and height is right.

If dest is not nil and big enough, the plugin will use it and return it on success. This can avoid additional memory allocations which can cost CPU time (especially to clear the bytes).

TiffPictureMBS.ReadWithLUT(ColorLookupTable() as color) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 9.8 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads the current picture with a Color Lookup Table.

Returns true on success and false on any error.
Works with 8, 16 amd 32 bits per sample. And with 1 or 3 samples per pixels (Gray or RGB). The lookup table has 256 entries for 8 bit and 65536 entries for 16/32 bit.
This method uses the YieldTicks property and may yield time to other threads.

See also:

Some examples using this method:

TiffPictureMBS.ReadWithLUT(ColorLookupTable() as color, left as Integer, top as Integer, width as Integer, height as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 9.8 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads the current picture with a Color Lookup Table.

Returns true on success and false on any error.
Works with 8, 16 amd 32 bits per sample. And with 1 or 3 samples per pixels (Gray or RGB). The lookup table has 256 entries for 8 bit and 65536 entries for 16/32 bit.
This method uses the YieldTicks property and may yield time to other threads.

See also:

TiffPictureMBS.RewriteDirectory as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TIFF MBS Images Plugin 8.7 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Writes existing picture and header information to file replacing the old data.

Returns true on success and false on any error.
As the data is added to the file and just the reference to the old data is deleted, the filesize will grow.

Calls TIFFReWriteDirectory internally. Same as SaveImage.

Some examples using this method:

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


The biggest plugin in space...