Platforms to show: All Mac Windows Linux Cross-Platform

PNGWriterMBS class

Type Topic Plugin Version macOS Windows Linux iOS Targets
class PNG MBS Images Plugin 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
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

You can use this class to write PNG files by row.

Based on LibPNG.

Constants

Constant Value Description
ResolutionDPI 2 One of the resolution unit type constants. The unit for points per inch.
ResolutionMeter 1 One of the resolution unit type constants. The unit for points per meter.
ResolutionUnknown 0 One of the resolution unit type constants.

Type Constants

Constant Value Description
TypeGray 0 Gray
TypeGrayA 4 Gray with Alpha
TypePalette 1 Palette
TypeRGB 2 RGB
TypeRGBA 6 RGB with Alpha.

This class has no sub classes.

Some examples using this class:

Blog Entries

Xojo Developer Magazine

Release notes

  • Version 19.5
    • Added path variants for OpenWriteDestination method to PNGWriterMBS class.
  • Version 19.0

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


PNGReaderMBS   -   PopupMenu


The biggest plugin in space...