Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

JPEGExporterMBS.Export
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method JPEG MBS Images Plugin Yes Yes Yes Yes No
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=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 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.

Feedback, Comments & Corrections

JPEGExporterMBS.ExportCMYK(data as memoryblock, width as UInt32, height as UInt32, rowbytes as UInt32)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method JPEG MBS Images Plugin 3.1 Yes Yes Yes Yes No
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=SpecialFolder.Desktop.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.

Feedback, Comments & Corrections

JPEGExporterMBS.ExportGray
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method JPEG MBS Images Plugin 12.3 Yes Yes Yes Yes No
Function: Exports an 8 bit grayscale picture.
Notes: Same as Export, but writes grayscale picture. The picture from picture property is converted to grayscale internally for this.

See also:

Feedback, Comments & Corrections

JPEGExporterMBS.ExportGray(data as memoryblock, width as UInt32, height as UInt32, rowbytes as UInt32)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method JPEG MBS Images Plugin 17.1 Yes Yes Yes Yes No
Function: Exports an 8 bit grayscale picture.
Notes:
Same as Export, but writes grayscale picture using data in memoryblock.
If rowbytes is 0, the plugin uses width for rowbytes.
This method uses the YieldTicks property and may yield time to other threads.

See also:

Feedback, Comments & Corrections

JPEGExporterMBS.ExportRGB(data as memoryblock, width as UInt32, height as UInt32, rowbytes as UInt32)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method JPEG MBS Images Plugin 8.4 Yes Yes Yes Yes No
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=SpecialFolder.Desktop.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=SpecialFolder.Desktop.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.

Feedback, Comments & Corrections

JPEGExporterMBS.ExportRGBwithRowDataEvent(width as UInt32, height as UInt32, rowbytes as UInt32)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method JPEG MBS Images Plugin 9.2 Yes Yes Yes Yes No
Function: Exports a picture from RGB data in memoryblocks from the GetRowData event.
Notes:
You need to implement the GetRowData event by subclassing this class.
The memoryblock data must be in the format with bytes in the order RGB.

Feedback, Comments & Corrections

JPEGExporterMBS.Markers(Index as Integer) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property JPEG MBS Images Plugin 14.2 Yes Yes Yes Yes No
Function: Additional markers.
Example:
dim j as new JPEGExporterMBS

j.Picture = LogoMBS(500)
j.Markers(5) = "Hello World"
j.File = SpecialFolder.Desktop.Child("test.jpg")
j.Export

// now open jpeg file in text editor and you see hello world near beginning
Notes:
Index from 0 to 15.
Index zero is used for JFIF header.
Index one is normally used for EXIF or XMP.
Index 13 is often used for Photoshop.

see also
http://www.ozhiker.com/electronics/pjmt/jpeg_info/app_segments.html

You can use this markers to embed a given string in the file. You can encrypt data and store it next to the image as you like.
Of course this will not survive if image is loaded and saved again. But can work as a container to hide data and user sees only image.
(Read and Write computed property)

Feedback, Comments & Corrections

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




Links
MBS Xojo tutorial videos