Platforms to show: All Mac Windows Linux Cross-Platform

PNGReaderMBS.ApplyOptions(gamma as double) as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Applies various options.
Notes:
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
PNGReaderMBS.BitDepth as Integer
property, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The bit depth of the PNG file.
Notes: (Read and Write property)
class PNGReaderMBS
class, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The class for reading PNG files.
Example:
dim Current as PictureMBS // global
dim f as FolderItem

f=GetopenFolderItem(FileTypes.Png)

if f<>Nil then
Current=nil

dim p as new PNGReaderMBS

if p.OpenFile(f) then
if p.ApplyOptions(0) then

Current=new PictureMBS(p.Width,p.Height,PictureMBS.ImageFormatRGB)

dim i,c as integer

c=p.Height-1
for i=0 to c
Current.RowInFormat(i, PictureMBS.ImageFormatRGBA)=p.ReadRow
next

end if
end if
end if
Notes: Use this class to read PNG files row by row as memoryblock.
PNGReaderMBS.ColorType as Integer
property, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The color type of the PNG file.
Notes:
The value is a combination of this constants:
PNG_COLOR_MASK_PALETTE= 1
PNG_COLOR_MASK_COLOR= 2
PNG_COLOR_MASK_ALPHA= 4

The PNG library will convert on reading every row into 32bit RGBA, so don't worry about this.
(Read and Write property)
PNGReaderMBS.CombinePictureWithMask as picture
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe in REAL Studio 2010r3 and newer, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Combines the pict and the mask property to a picture with mask.
PNGReaderMBS.Height as Integer
property, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The height of the picture in pixels.
Notes: (Read and Write property)
PNGReaderMBS.InterlaceType as Integer
property, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The interlace setting.
Notes: (Read and Write property)
PNGReaderMBS.Interlacing as Integer
property, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 9.1, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Whether the png file is interlaced.
Notes:
Value is 1 if not interlaced and 7 if interlaced.
(Read and Write property)
PNGReaderMBS.Mask as Picture
property, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe in REAL Studio 2010r3 and newer, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The mask of the picture.
Notes: (Read and Write property)
PNGReaderMBS.Open(file as folderitem, data as string) as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Opens either the data string or the file.
Notes: Returns true on success.
PNGReaderMBS.OpenData(data as string) as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Opens a PNG file from the data string.
Notes: Returns true on success.
PNGReaderMBS.OpenFile(file as folderitem) as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Opens a file.
Notes: Returns true on success.
PNGReaderMBS.OpenSpecialData(data as string) as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 10.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: 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
Notes: 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.
PNGReaderMBS.Pict as Picture
property, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe in REAL Studio 2010r3 and newer, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The picture read.
Notes: (Read and Write property)
PNGReaderMBS.PNGLibVersion as string
shared method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The version of the PNG library compiled into the plugin.
PNGReaderMBS.ReadICCProfile(byref name as string, byref compression as integer, byref profile as string) as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 9.4, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Reads the ICC Profile from the PNG file.
Notes:
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.
PNGReaderMBS.ReadPicture as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe in REAL Studio 2010r3 and newer, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Reads the picture into the pict and mask properties.
Notes: Returns true on success.
PNGReaderMBS.ReadRow as memoryblock
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: 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
Notes:
Returns nil on any error.
Format is RGBA as in the example with 4 bytes per pixel.
PNGReaderMBS.ReadsRGBTag(byref file_srgb_intent as integer) as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 9.4, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Reads the sRGB tag.
Notes: Returns true if the value was read into the given variable.
PNGReaderMBS.RowBytes as integer
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The length of each row in bytes.
PNGReaderMBS.SourceData as String
property, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 10.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The source data used in Open functions.
Example:
dim p as PNGReaderMBS // your reader

// write data to file
dim fo as FolderItem = SpecialFolder.Desktop.Child("mbsout.png")
dim bo as BinaryStream = fo.CreateBinaryFile("") // BinaryStream.Create(fo,true) in newer RB Versions

bo.Write p.SourceData
Notes:
If you used OpenSpecialData, the data here is the PNG without the Apple modifications, but still with swapped colors.
This property is set by the OpenSpecialData, Open and OpenData functions.
(Read and Write property)
PNGReaderMBS.SourceFile as FolderItem
property, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 10.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The folderitem passed to the Open functions.
Notes:
This property is set by the Open and OpenFile functions.
(Read and Write property)
PNGReaderMBS.SwapRB as Boolean
property, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 10.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Whether to swap red and blue channels.
Example:
dim p as new PNGReaderMBS
p.SwapRB = true
Notes:
The PNG files for the iPhone have swapped channels so the iPhone does not need to swap them for display. One of the tricks Apple uses for making the iPhone faster.
This flag is set to true by OpenSpecialData.
(Read and Write property)
PNGReaderMBS.Width as Integer
property, PNG, MBS REALbasic PNG Plugin (PNG), class PNGReaderMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The width of the picture in pixels.
Notes: (Read and Write property)

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




Links
MBS REAL studio PDF Plugins - Pfarrgemeinde St. Arnulf Nickenich