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 |
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.
- 2 events
- 5 properties
- 22 methods
- method CloseDestination
- method Finish as string
- method OpenWriteDestination(file as folderitem) as boolean
- method OpenWriteDestination(Path as String) as boolean
- method SetAlphaData(alphas() as Integer, colors() as color) as boolean
- method SetAlphas as boolean
- method SetEXIF(EXIFData as string) as boolean
- method SetGamma(gamma as Double = 0.0) as boolean
- method SetGrayPicture(pict as picture, mask as picture = nil) as boolean
- method SetHeader(Interlace as boolean = false, Filter as Integer = -1, Compression as Integer = -1) as boolean
- method SetICCProfile(name as string, CompressionType as Integer, Profile as string) as boolean
- method SetPalette as boolean
- method SetPaletteData(colors() as color) as boolean
- method SetPalettePicture(pict as picture) as boolean
- method SetResolution(ResolutionHorizontal as Integer, ResolutionVertical as Integer, Unit as Integer) as boolean
- method SetRGBPicture(pict as picture, mask as picture = nil) as boolean
- method SetRows(rows() as memoryblock) as boolean
- method SetsRGB(intent as Integer) as boolean
- method WriteEnd as boolean
- method WriteInfo as boolean
- method WriteRow(row as memoryblock)
- method WriteRows as boolean
- shared method PNGLibVersion as string
- 8 constants
- const ResolutionDPI = 2
- const ResolutionMeter = 1
- const ResolutionUnknown = 0
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:
- /Images/LargePicture/PNG Load and Save
- /Images/PNG/Filters and Interlace
- /Images/PNG/png with profile
- /Images/PNG/Write Gray image
- /Images/PNG/Write with PictureMBS
Blog Entries
- MBS Xojo Plugins, version 19.5pr6
- MBS Xojo Plugins in version 19.0
- MBS Xojo Plugins, version 19.0pr6
- MBS Xojo / Real Studio Plugins, version 15.0pr11
- MBS Real Studio Plugins, version 11.3pr13
Xojo Developer Magazine
The items on this page are in the following plugins: MBS Images Plugin.
Feedback: Report problem or ask question.
