Platforms to show: All Mac Windows Linux Cross-Platform

Back to PNGReaderMBS class.

PNGReaderMBS.ApplyOptions(gamma as double = 0.0, ScreenGamma as double = -1.0) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Applies various options.

The gamma parameter defines what gamma correction is applied:
positive value: use the value as the gamma correction
zero: use default value (or value saved in file itself)
negative value: do not correct gamma

Added ScreenGamma parameter in plugin version 15.2. If you set both gamma and Screengamma to a value > 0.0, the plugin will use those gamma values. If both are equal, no gamma correction is made.

16-bit images are always reduced to 8-bit images.

Returns true on success and false on failure. Calls ReadHeader method if needed.

Some examples using this method:

PNGReaderMBS.CombinePictureWithMask as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Combines the pict and the mask property to a picture with mask.

PNGReaderMBS.Open(file as folderitem, data as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Opens either the data string or the file.

Returns true on success.

PNGReaderMBS.OpenData(data as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Opens a PNG file from the data string.

Returns true on success.

PNGReaderMBS.OpenFile(file as folderitem) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Opens a file.
Example
Dim p As New PNGReaderMBS
Dim f As FolderItem = SpecialFolder.Desktop.Child("test.png")

If p.OpenFile(f) Then
If p.ApplyOptions Then
If p.ReadPicture Then
window1.Backdrop = p.Pict
End If
end if
End If

Returns true on success.

See also:

PNGReaderMBS.OpenFile(Path as String) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 19.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Opens a file.
Example
Dim p As New PNGReaderMBS
Dim f As FolderItem = SpecialFolder.Desktop.Child("test.png")
Dim path As String = f.NativePath

If p.OpenFile(path) Then
If p.ApplyOptions Then
If p.ReadPicture Then
window1.Backdrop = p.Pict
End If
end if
End If

Returns true on success.

See also:

PNGReaderMBS.OpenSpecialData(data as string) as boolean   Deprecated

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 10.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
This item is deprecated and should no longer be used.
Same as OpenData but with special handling of the png data.
Example
dim f as FolderItem = getfolderitem("mbs.png")
dim b as BinaryStream = f.OpenAsBinaryFile(false) // BinaryStream.Open(f) in newer RB versions
dim s as string = b.Read(B.Length)

dim p as new PNGReaderMBS
if p.OpenSpecialData(s) then
if p.ApplyOptions(0) then
if p.ReadPicture then
Backdrop = p.Pict
Title = "OK"
else
Title = "Failed to read picture."
end if
else
Title = "Failed to apply options."
end if
else
Title = "Failed to open picture."
end if

This function can be used to read PNG files made for the Apple iPhone. The PNG is converted from the Apple format to the normal PNG format and passed to OpenData. In the SourceData property you can get the modified PNG data. Still this modified PNG data has the channels swapped, so you should read the image with the pict property.

On Mac OS X 10.8, the NSImage class also reads iOS optimized PNG files.

Deprecated as it does not read all files and we can't fix this old code. Please use a command line tool to convert instead.

PNGReaderMBS.ReadEXIF(byref exif as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 19.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads the EXIF data block.

Returns true on success or false on failure.

PNGReaderMBS.ReadHeader as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 19.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads header of PNG.

This reads header and fill properties Width, Height, ColorType, OriginalColorType, InterlaceType and BitDepth.
Returns true on success and false on failure.

PNGReaderMBS.ReadICCProfile(byref name as string, byref compression as Integer, byref profile as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 9.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads the ICC Profile from the PNG file.

Name is the profile name, compression the method used to compress the profile data and profile a string with the content of the profile as binary data.
Returns true on success.

Some examples using this method:

PNGReaderMBS.ReadPicture as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads the picture into the pict and mask properties.

Returns true on success.

Some examples using this method:

PNGReaderMBS.ReadRow as memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads the next row as a memoryblock.
Example
dim fSource as FolderItem = SpecialFolder.Desktop.Child("test.png") // some png with alpha
dim oPNGInput as new PNGReaderMBS

If oPNGInput.OpenFile(fSource) Then
If oPNGInput.ApplyOptions(0) Then

dim imgSource as New PictureMBS(oPNGInput.Width, oPNGInput.Height, PictureMBS.ImageFormatRGBA)

' Read row by row the file and puts it in a PictureMBS instance

dim nMax as Integer = oPNGInput.Height - 1
For nInd as Integer = 0 To nMax
imgSource.RowInFormat(nInd, PictureMBS.ImageFormatRGBA, true) = oPNGInput.ReadRow()
Next

' show only alpha/mask channel
Backdrop=imgSource.AlphaChannel.CopyPicture

' show Picture without mask
Backdrop=imgSource.CopyPicture

' show picture with mask
Backdrop=imgSource.CopyPictureWithMask

End If
End If

Returns nil on any error.
Format is RGBA as in the example with 4 bytes per pixel.

See also:

Some examples using this method:

PNGReaderMBS.ReadRow(mem as memoryblock) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 11.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads the next row into the given memoryblock.

Returns false on any error and true on success.
Format is RGBA as in the example with 4 bytes per pixel.
Make sure the memoryblock is big enough. Else you risk a crash.

See also PNGReaderMBS.RowBytes.

ReadRow with reusing memoryblock is faster than allocating a new one for each row.

See also:

PNGReaderMBS.ReadRowAlphaOnly(mem as memoryblock) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 14.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads the next row into the given memoryblock.

Returns false on any error and true on success.
Format is alpha channel as in the example with one byte per pixel.
Make sure the memoryblock has size from RowBytes property. Else you risk a crash.
The data in memoryblock is width bytes long, 1/4 of the size of the memoryblock.

See also PNGReaderMBS.RowBytes.

ReadRow with reusing memoryblock is faster than allocating a new one for each row.

PNGReaderMBS.ReadRowMaskOnly(mem as memoryblock) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 14.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads the next row into the given memoryblock.

Returns false on any error and true on success.
Format is mask (inverse alpha) as in the example with one byte per pixel.
Make sure the memoryblock has size from RowBytes property. Else you risk a crash.
The data in memoryblock is width bytes long, 1/4 of the size of the memoryblock.

See also PNGReaderMBS.RowBytes.
ReadRow with reusing memoryblock is faster than allocating a new one for each row.

PNGReaderMBS.ReadsRGBTag(byref file_srgb_intent as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 9.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads the sRGB tag.

Returns true if the value was read into the given variable.

Some examples using this method:

PNGReaderMBS.RowBytes as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
The length of each row in bytes.

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


The biggest plugin in space...