Platforms to show: All Mac Windows Linux Cross-Platform

Back to JPEG2000MBS class.

JPEG2000MBS.Close

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 15.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Performs cleanup.

Called automatically by destructor for you.
You can call it after you are done to free memory now.

JPEG2000MBS.Compress as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 15.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Compresses image.

Please use first InitCompress, than loop over rows and use SetRow to fill in data.
This method will compress image and set ImageData property.
Returns true on success and false on failure.

JPEG2000MBS.GetRow(Index as Integer, Row as MemoryBlock = nil) as MemoryBlock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 15.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Queries image data for a row.

If you pass in a memoryblock, we use it, else we create a new one.
So you can pass in memoryblock from last call to GetRow.
Returns nil in case of error.

JPEG2000MBS.InitCompress(Width as Integer, Height as Integer, BytesPerPixel as Integer, BytesPerRow as Integer = 0) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 15.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Initializes the compression for a new image.
Example
dim p as Picture = LogoMBS(200)
dim pp as new PictureMBS(p)

// compress RGB in PictureMBS
dim je as new JPEG2000MBS
if je.InitCompress(pp.Width, pp.Height, 3, pp.RowSize) then
dim h as Integer = pp.Height-1

for i as Integer = 0 to h
dim rowData as MemoryBlock = pp.RowInFormat(i, pp.ImageFormatRGB)
if not je.SetRow(i, rowData) then
Break
exit
end if
next
if je.Compress then
dim ImageData as MemoryBlock = je.ImageData
if ImageData <> nil then
// and decode to show
dim pic as Picture = JPEG2000MBS.Decode(ImageData)
window1.Backdrop = pic
end if
end if
end if

Returns true on success or false on failure.
If BytesPerRow is zero, we calculate it based on BytesPerPixel and Width.
BytesPerPixel can be 1 for gray, 3 for RGB and 4 for RGBA.

Some examples using this method:

JPEG2000MBS.InitDecompress(ImageData as MemoryBlock) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 15.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Initializes the decompression for given image data.
Example
dim p as Picture = LogoMBS(200)

dim j80 as MemoryBlock = JPEG2000MBS.Encode(p, 80)

// decompress to PictureMBS
dim jd as new JPEG2000MBS

if jd.InitDecompress(j80) then
dim pi as new PictureMBS(jd.Width, jd.Height, PictureMBS.ImageFormatRGB)
dim h as Integer = pi.Height-1

dim r as MemoryBlock
for i as Integer = 0 to h
// get row. Recycle MemoryBlock, so we don't create new one each row.
r = jd.getRow(i, r)
pi.RowInFormat(i, pi.ImageFormatRGB) = r
next

// get picture
window1.Backdrop = pi.CopyPicture
end if

Returns true on success or false on failure.
BytesPerPixel is set to 1 for gray, 3 for RGB and 4 for RGBA.

Some examples using this method:

JPEG2000MBS.SetRow(Index as Integer, Row as MemoryBlock) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 15.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sets data for a row.

Returns true on success.

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


The biggest plugin in space...