Platforms to show: All Mac Windows Linux Cross-Platform

JPEGImporterMBS class

Type Topic Plugin Version macOS Windows Linux iOS Targets
class JPEG MBS Images Plugin ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: A class for JPEG Importing.
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=SpecialFolder.Desktop.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=SpecialFolder.Desktop.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!

Bases on libjpeg.

Color Spaces

Constant Value Description
ColorSpaceCMYK 4 C/M/Y/K
ColorSpaceGrayScale 1 Gray
ColorSpaceRGB 2 red/green/blue
ColorSpaceUnknown 0 Not set.
ColorSpaceYCbCr 3 Y/Cb/Cr (also known as YUV)
ColorSpaceYCCK 5 Y/Cb/Cr/K

Orientation Constants

Constant Value Description
kOrientationBottomLeft 4 row 0 bottom, col 0 lhs
kOrientationBottomRight 3 row 0 bottom, col 0 rhs
kOrientationLeftBottom 8 row 0 lhs, col 0 bottom
kOrientationLeftTop 5 row 0 lhs, col 0 top
kOrientationRightBottom 7 row 0 rhs, col 0 bottom
kOrientationRightTop 6 row 0 rhs, col 0 top
kOrientationTopLeft 1 row 0 top, col 0 lhs
kOrientationTopRight 2 row 0 top, col 0 rhs

Modes

Constant Value Description
ModeAuto 30 Load the image into the picturedata property.
Switches on import to RGB, Gray or CMYK depending on color space of JPEG file.
ModeAutoByRow 31 Load the image into the picturedata property.
Switches on import to RGB, Gray or CMYK depending on color space of JPEG file.
ModeCMYK 2 Load the image into the picturedata property.
The PictureData Memoryblock uses 4 bytes per pixel.
ModeCMYKbyRow 12 Same as ModeCMYK, but PictureData contains only the current row
The PictureData Memoryblock uses 4 bytes per pixel.
ModeGray 3 Load the image into the picturedata property.
The PictureData Memoryblock uses one byte per pixel.
ModeGraybyRow 13 Same as ModeGray, but PictureData contains only the current row
The PictureData Memoryblock uses one byte per pixel.
ModePicture 0 Load the image into the picture property.
ModeRaw 20 Load the image into the picturedata property.
The PictureData Memoryblock uses 1 to 4 bytes per pixel.

Check the colorspace property to know which color space is used.
ModeRGB 1 Load the image into the picturedata property.
The PictureData Memoryblock uses 3 bytes per pixel.
ModeRGBbyRow 11 Same as ModeRGB, but PictureData contains only the current row
The PictureData Memoryblock uses 3 bytes per pixel.

This class has no sub classes.

Some examples using this class:

Blog Entries

Xojo Developer Magazine


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


JPEGImporterMarkerMBS   -   JPEGMovieMBS


💬 Ask a question or report a problem
The biggest plugin in space...