MBS Plugin Documentation

Search:

Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchie

New in Version 7.0 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 8.0 8.1 8.2 8.3 8.4 8.5 8.6 8.7 9.0

The list of the   themes,   classes,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

class JPEGExporterMBS
class, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: A class for JPEG Exporting.
Example:
dim g as FolderItem
dim ji as JPEGImporterMBS
dim je as JPEGExporterMBS
dim f as FolderItem
dim m as MemoryBlock

// this code copies a JPG: CMYK or RGB

// import it
g=DesktopFolder.Child("PICT1533.JPG")
ji=new JPEGImporterMBS
ji.File=g
ji.AllowDamaged=true
ji.CMYK=true // if it is cmyk
if ji.InitJPEG then
do
loop until ji.LoopJPEG<>0
ji.FinishJPEG
end if

// export it
f=desktopfolder.child("PICT1533 copy.JPG")
je=new JPEGExporterMBS
je.File=f
je.Quality=75

if ji.CMYK then
m=ji.PictureData
je.ExportCMYK m, ji.Width, ji.Height, ji.Width*4
else
je.Picture=ji.Picture
je.Export
end if

Notes:
This class is not depending on any library! It works without QuickTime even on System 7, but as it contains everything needed this method is around 100 KB big!
(REALbasic's SaveAsJPEG depends on QuickTime)
JPEGExporterMBS.data as string
property, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The destination string.
Notes:
If file is nil, the compressed data is saved in this property.

The returned string has the encoding set to MacRoman. If you want to concat the string with another you should change the encoding, so both strings have the same encoding. If you don't handle that RB may convert the JPEG data to UTF8 (Unicode) which will destroy it.
(Read and Write property)
JPEGExporterMBS.Error(message as string)
event, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Plugin version: 8.5, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: This events reports all error messages from the jpeg library.
JPEGExporterMBS.ErrorCode as integer
property, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The error code from the Export method.
Notes:
The last function was successfull if ErrorCode is 0.
If the parameters are not valid, the value is set to -1.
Other values are Mac OS error codes.
(Read and Write property)
JPEGExporterMBS.ErrorMessage as string
property, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The last error message reported.
Notes: (Read and Write property)
JPEGExporterMBS.Export
method, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Exports the picture.
Example:
dim g as FolderItem
dim ji as JPEGImporterMBS
dim je as JPEGExporterMBS
dim f as FolderItem
dim m as MemoryBlock

// this code copies a JPG: CMYK or RGB

// import it
g=DesktopFolder.Child("PICT1533.JPG")
ji=new JPEGImporterMBS
ji.File=g
ji.AllowDamaged=true
ji.CMYK=true // if it is cmyk
if ji.InitJPEG then
do
loop until ji.LoopJPEG<>0
ji.FinishJPEG
end if

// export it
f=desktopfolder.child("PICT1533 copy.JPG")
je=new JPEGExporterMBS
je.File=f
je.Quality=75

if ji.CMYK then
m=ji.PictureData
je.ExportCMYK m, ji.Width, ji.Height, ji.Width*4
else
je.Picture=ji.Picture
je.Export
end if

Notes:
This methods saves 32bit pictures to a file using JPEG Compression. Using the properties of the class you can specify the quality in range between 0 and 100%

This method is not depending on any library! It works without QuickTime even on System 7, but as it contains everything needed this method is around 100 KB big!
(REALbasic's SaveAsJPEG depends on QuickTime)

You may use the function picture.bitmap to make sure that the picture is a bitmap, because this function works only for bitmap pictures.

This method uses the YieldTicks property and may yield time to other threads.
JPEGExporterMBS.ExportCMYK(data as memoryblock, width as integer, height as integer, rowbytes as integer)
method, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Console safe, Plugin version: 3.1, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Exports a picture from CMYK data in a memoryblock.
Example:
dim g as FolderItem
dim ji as JPEGImporterMBS
dim je as JPEGExporterMBS
dim f as FolderItem
dim m as MemoryBlock

// import it
g=getOpenFolderItem("image/jpeg")
ji=new JPEGImporterMBS
ji.File=g
ji.AllowDamaged=true
ji.ImportCMYK

m=ji.PictureData

// export it
f=desktopfolder.child("test.jpg")
je=new JPEGExporterMBS
je.HorizontalResolution=300
je.VerticalResolution=300
je.ResolutionUnit=1
je.File=f
je.Quality=75
je.ExportCMYK m, ji.Width, ji.Height, ji.Width*4

Notes:
This methods saves 32bit CMYK pictures to a file using JPEG Compression. Using the properties of the class you can specify the quality in range between 0 and 100%

This method is not depending on any library! It works without QuickTime even on System 7, but as it contains everything needed this method is around 100 KB big!
(REALbasic's SaveAsJPEG depends on QuickTime)

The picture must be in the format that one byte is used for each channel and the channels are ordered in memory in Cyan, Magenta, Yellow and Black.
If rowbytes is 0, the plugin uses width*4 for rowbytes.

This method uses the YieldTicks property and may yield time to other threads.
JPEGExporterMBS.ExportRGB(data as memoryblock, width as integer, height as integer, rowbytes as integer)
method, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Console safe, Plugin version: 8.4, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Exports a picture from RGB data in a memoryblock.
Example:
dim f as FolderItem
dim ji as new JPEGImporterMBS
dim je as new JPEGExporterMBS
dim m as MemoryBlock
dim i,c as integer

// read jpeg
f=DesktopFolder.Child("input.jpg")

ji.Mode=ji.ModeRGB // read RGB to memoryblock
ji.File=f
ji.Import

m=ji.PictureData

// add red
c=m.Size-1
for i=0 to c step 3
m.Byte(i)=255
next

// write jpeg
f=DesktopFolder.Child("test.jpg")

je.File=f
je.ExportRGB(m,ji.Width, ji.Height, ji.Width*3)

Notes: The memoryblock data must be in the format with bytes in the order RGB.
JPEGExporterMBS.file as folderitem
property, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The destination file.
Notes:
If file is nil, the destination is the data property.
(Read and Write property)
JPEGExporterMBS.HorizontalResolution as Integer
property, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Console safe, Plugin version: 3.2, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The horizontal resolution.
Notes: (Read and Write property)
JPEGExporterMBS.Info(message as string, msglevel as integer)
event, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Plugin version: 8.5, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: This events reports all information messages from the jpeg library.
Notes:
msglevel is one of:
-1:recoverable corrupt-data warning, may want to abort.
0:important advisory messages (always display to user).
1:first level of tracing detail.
2,3,...:successively more detailed tracing messages.
JPEGExporterMBS.Picture as Picture
property, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The picture to use.
Example:
j.picture=MyPic.Bitmap.

Notes:
Should be a bitmap picture, so you the bitmap function of the picture class.
(Read and Write property)
JPEGExporterMBS.ProfileData as String
property, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Console safe, Plugin version: 7.2, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: An ICC profile to write to the file.
Example:
dim f as FolderItem
dim j as JPEGImporterMBS
dim p as CMProfileMBS
dim e as JPEGExporterMBS

f=DesktopFolder.Child("test2.jpg")
j=new JPEGImporterMBS

j.ReadMarkers=true // else no metadata is read at all
j.ReadProfileData=true // needed to fill ProfileData property
j.file=f

j.Import

if j.ProfileData="" then
MsgBox "no profile"
Return
end if

p=CMCreatesRGBProfileMBS

f=DesktopFolder.Child("test3.jpg")
e=new JPEGExporterMBS
e.File=f
e.Picture=j.Picture
e.ProfileData=p.SaveProfileToString
e.Quality=75
e.Export


Notes:
the string must contain the binary data of the profile. For example SaveProfileToString of the CMProfileMBS class returns such a string.
If the string is empty, no profile is written.
(Read and Write property)
JPEGExporterMBS.Progressive as Boolean
property, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: whether to make a progressive compressed image.
Notes:
Default is true.
(Read and Write property)
JPEGExporterMBS.Quality as integer
property, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The quality to use.
Notes:
Range from 0 to 100. Default is 75.
(Read and Write property)
JPEGExporterMBS.ResolutionUnit as Integer
property, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Console safe, Plugin version: 3.2, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The unit of the resolution properties.
Notes:
Values:
0unknown
1dots per inch
2dots per cm
(Read and Write property)
JPEGExporterMBS.VerticalResolution as Integer
property, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Console safe, Plugin version: 3.2, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The vertical resolution.
Notes: (Read and Write property)
JPEGExporterMBS.Warning(message as string)
event, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Plugin version: 8.5, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: This events reports all warning messages from the jpeg library.
JPEGExporterMBS.WarningMessage as String
property, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Console safe, Plugin version: 8.5, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The last warning message reported.
Notes: (Read and Write property)
JPEGExporterMBS.YieldTicks as Integer
property, Pictures Import and Export, MBS JPEG Plugin (JPEGCompression), class JPEGExporterMBS, Console safe, Plugin version: 7.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: How much time is given back to REALbasic for other ticks.
Example:
YieldTicks=6 // only use 1/10th of a second

Notes:
If value is greater than zero, the application will yield to another RB thread after the given number of ticks have passed. 60 ticks are one second. Using a small value can slow down processing a lot while a big value keeps your application not responding to mouse clicks.
If you use this property with e.g. 6 as the value, you may also want to use this method in a thread so you can handle mouse events or let REALbasic redraw a progressbar.
(Read and Write property)

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