Platforms to show: All Mac Windows Linux Cross-Platform

PNGWriterMBS.bpc as Integer
property, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The bytes per pixel.
Notes:
Should be 3 for RGB, 1 for palette pictures and 4 for RGB with Alpha.
(Read and Write property)
class PNGWriterMBS
class, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The class to write a PNG file.
Example:
dim Current as PictureMBS // your picture
dim f as FolderItem

f=GetsaveFolderItem(FileTypes.Png,"test.png")

if f<>Nil then
const PNG_COLOR_MASK_PALETTE = 1
const PNG_COLOR_MASK_COLOR = 2
const PNG_COLOR_MASK_ALPHA = 4

dim p as new PNGWriterMBS

p.Width=Current.Width
p.Height=Current.Height
p.Type=PNG_COLOR_MASK_COLOR
p.bpc=3
p.Rowbytes=p.Width*p.bpc

if p.OpenWriteDestination(f) then
if p.SetHeader(false, -1) then
if p.SetGamma(0) then
if p.WriteInfo then
dim i,c as integer

c=p.Height-1
for i=0 to c
p.WriteRow current.RowInFormat(i, Current.ImageFormatRGB)
next

if p.WriteEnd then
MsgBox "OK"
end if
end if
end if
end if
end if
end if
Notes: You can use this class to write PNG files by row.
PNGWriterMBS.CloseDestination
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Closes the file.
PNGWriterMBS.Finish as string
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Finishes the PNG file and returns the PNG file content as string.
Notes: Returns "" on any error.
PNGWriterMBS.Height as Integer
property, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The height of the picture to write.
Notes: (Read and Write property)
PNGWriterMBS.OpenWriteDestination(file as folderitem) as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Opens the file to write.
Notes: If you pass nil for the file, the data is collected in memory and you can get it on the end using the Finish method.
PNGWriterMBS.PNGLibVersion as string
shared method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, 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.
PNGWriterMBS.ResolutionDPI = 2
const, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Plugin version: 10.1, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: One of the resolution unit type constants.
Notes: The unit for points per inch.
PNGWriterMBS.ResolutionMeter = 1
const, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Plugin version: 10.1, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: One of the resolution unit type constants.
Notes: The unit for points per meter.
PNGWriterMBS.ResolutionUnknown = 0
const, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Plugin version: 10.1, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: One of the resolution unit type constants.
PNGWriterMBS.Rowbytes as Integer
property, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The bytes per row.
Notes: (Read and Write property)
PNGWriterMBS.SetAlphaData(alphas() as integer, colors() as color) as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Sets the alpha data and the color palette.
Notes:
The array can have up to 256 colors.
The color and the alpha arrays must have the same size.
Returns true on success.
PNGWriterMBS.SetAlphas as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Writes the alpha data to the file.
Notes:
You must call SetAlphaData before.
Returns true on success.
PNGWriterMBS.SetGamma(gamma as double) as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Defines the gamma value and other options for the PNG file.
Notes:
Returns on success.

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
PNGWriterMBS.SetHeader(Interlace as boolean, Filter as integer) as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Defines the header options for the PNG file.
Notes:
Interlace is true the Adam7 interlacing is used.
FilterType specifies the filter:

const PNG_NO_FILTERS= 0
const PNG_FILTER_NONE= 8
const PNG_FILTER_SUB= 16
const PNG_FILTER_UP= 32
const PNG_FILTER_AVG= 64
const PNG_FILTER_PAETH= 128
const PNG_FILTER_ALL= 248
PNGWriterMBS.SetICCProfile(name as string, CompressionType as integer, Profile as string) as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.4, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Adds a ICC Profile to the PNG.
Notes:
Name is the profile name as an ASCII string.
CompressionType is always 0 (PNG_COMPRESSION_TYPE_BASE).
PNGWriterMBS.SetPalette as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Sets the palette data.
Notes: Returns true on success.
PNGWriterMBS.SetPaletteData(colors() as color) as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Sets the color palette.
Notes:
The array can have up to 256 colors.
Returns true on success.
PNGWriterMBS.SetPalettePicture(pict as picture) as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe in REAL Studio 2010r3 and newer, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Copies a picture into the internal buffers.
Notes:
You need to define the color palette before calling this method.

This method sets width, height, type and bpc properties.
Returns true on success.
PNGWriterMBS.SetResolution(ResolutionHorizontal as integer, ResolutionVertical as integer, Unit as integer) as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 10.1, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Sets the resolution of the PNG.
Notes:
Unit is ResolutionUnknown, ResolutionMeter or ResolutionDPI.
Internally the PNG saves only in dots per meter, so the plugin converts DPI to DPM for you.
PNGWriterMBS.SetRGBPicture(pict as picture, mask as picture) as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe in REAL Studio 2010r3 and newer, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Copies a picture into the internal buffers.
Notes:
This method sets width, height, type and bpc properties.
Returns true on success.
PNGWriterMBS.SetsRGB(intent as integer) as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.4, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Sets the sRGB intent.
Notes:
Possible values:

const PNG_sRGB_INTENT_PERCEPTUAL= 0
const PNG_sRGB_INTENT_RELATIVE = 1
const PNG_sRGB_INTENT_SATURATION= 2
const PNG_sRGB_INTENT_ABSOLUTE = 3
PNGWriterMBS.Type as Integer
property, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The color type.
Notes:
The value is a combination of this constants:
PNG_COLOR_MASK_PALETTE= 1
PNG_COLOR_MASK_COLOR= 2
PNG_COLOR_MASK_ALPHA= 4
(Read and Write property)
PNGWriterMBS.Width as Integer
property, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The width of the picture to write.
Notes: (Read and Write property)
PNGWriterMBS.WriteEnd as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Finishes the writing.
Notes:
Returns true on success.

Do not call if you use WriteRows.
PNGWriterMBS.WriteInfo as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Writes the PNG file header.
Notes:
Returns true on success.

Do not call if you use WriteRows.
PNGWriterMBS.WriteRow(row as memoryblock)
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Writes one row of image data.
Notes:
The data must be in the RGBA format with one byte per value.
(4 bytes per Pixel)

Returns true on success.

Do not call if you use WriteRows.
PNGWriterMBS.WriteRows as boolean
method, PNG, MBS REALbasic PNG Plugin (PNG), class PNGWriterMBS, Console safe, Plugin version: 9.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Writes the picture from memory to the file.
Notes: If you call this method, you need to call SetRGBPicture or SetPalettePicture before and you can't call WriteInfo, WriteRow and WriteEnd.

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




Links
MBS REAL studio Plugins - Pfarrgemeinde St. Arnulf Nickenich