Platforms to show: All Mac Windows Linux Cross-Platform

Back to PNGWriterMBS class.

PNGWriterMBS.SetAlphaData(alphas() as Integer, colors() as color) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sets the alpha data and the color palette.

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

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Writes the alpha data to the file.

You must call SetAlphaData before.
Returns true on success.

PNGWriterMBS.SetEXIF(EXIFData 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
Writes the EXIF data block.

Returns true on success or false on failure.

PNGWriterMBS.SetGamma(gamma as Double = 0.0) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Defines the gamma value and other options for the PNG file.

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

Default for Mac is 1.8 and for Windows 2.2.
If you use SRGB, the Gamma must be 2.2.

PNGWriterMBS.SetGrayPicture(pict as picture, mask as picture = nil) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 12.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies a picture into the internal buffers for writing a Grayscale image file.

This method sets width, height, type and bpc properties.
Returns true on success.

Mask can be nil.

Some examples using this method:

PNGWriterMBS.SetHeader(Interlace as boolean = false, Filter as Integer = -1, Compression as Integer = -1) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Defines the header options for the PNG file.

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

Compression can be between 0 (none) to 9 (max). Default is 6. Value -1 means the plugin will not change from default of PNG library. Normally you have no better compression for setting higher than 6, but only burn more CPU power.

PNGWriterMBS.SetICCProfile(name as string, CompressionType as Integer, 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
Adds a ICC Profile to the PNG.

Name is the profile name as an ASCII string.
CompressionType is always 0 (PNG_COMPRESSION_TYPE_BASE).

Some examples using this method:

PNGWriterMBS.SetPalette as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sets the palette data.

Returns true on success.

PNGWriterMBS.SetPaletteData(colors() as color) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sets the color palette.

The array can have up to 256 colors.
Returns true on success.

PNGWriterMBS.SetPalettePicture(pict as picture) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies a picture into the internal buffers.

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

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 10.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sets the resolution of the PNG.

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 = nil) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies a picture into the internal buffers.
Example
// Write a RGBA PNG file
Var current as Picture = LogoMBS(500)

// create a mask
Var g as Graphics = current.Mask.Graphics
g.ForeColor = &cFFFFFF
g.FillRect 0,0,500,500
g.ForeColor = &c000000
g.FillOval 0,0,500,500

// show in window
Window1.Backdrop = current

// and write to file
Var f as FolderItem = SpecialFolder.Desktop.Child("test.png")

Var p as new PNGWriterMBS

if p.OpenWriteDestination(f) then // open file
if p.SetRGBPicture(current, current.mask) then // set picture to write
if p.SetHeader(false, -1) then // setup file header
if p.SetGamma(0) then // and default gamma
if p.WriteInfo then // write file header
if p.WriteRows then // write pixels
if p.WriteEnd then // and write file end
p = nil // cleanup
f.Launch
end if
end if
end if
end if
end if
end if
end if

This method sets width, height, type and bpc properties.
Returns true on success.

Mask can be nil.

Some examples using this method:

PNGWriterMBS.SetRows(rows() as memoryblock) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method PNG MBS Images Plugin 12.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Uses the given memoryblocks for row data.

The memory is not copied, so keep the array alive!
This method sets height. You need to set width, bpc, type and rowbytes.
Returns true on success.

Some examples using this method:

PNGWriterMBS.SetsRGB(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
Sets the sRGB intent.

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

Some examples using this method:

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


The biggest plugin in space...