Platforms to show: All Mac Windows Linux Cross-Platform

JPEGImporterMBS.BlueTestPicture as picture
Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 5.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Returns a 100x100 pixel big picture filles with RGB(0,0,255).
Notes: Just for testing how well the plugin picture code works.

Feedback, Comments & Corrections

JPEGImporterMBS.CleanMarkers
Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 6.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Clears the marker list.

Feedback, Comments & Corrections

JPEGImporterMBS.FinishJPEG
Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 3.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Releases all memory buffers needed for the JPEG decompression.
Notes:
This must be called if you used InitJPEG!
Else you have a memory leak.

Feedback, Comments & Corrections

JPEGImporterMBS.GreenTestPicture as picture
Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 5.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Returns a 100x100 pixel big picture filles with RGB(0,255,0).
Notes: Just for testing how well the plugin picture code works.

Feedback, Comments & Corrections

JPEGImporterMBS.Import
Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Imports the picture.
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:
This methods should read all JPEG files you can get, but I've only tested it for 32 bit color and 8 bit grayscale.

I wrote it mainly because Xojo's built in OpenAsJPEG code crashes badly if your picture is not full downloaded. For example if you have a webbrowser you can now show JPEGs while you download them. Normally you can see a good picture allready with 50% of the data.

Xojo's OpenAsPicture in contrast crashes if the picture is not 100% downloaded or instead of a crash you get a white picture.

This method uses the YieldTicks property and may yield time to other threads.
Depending on the mode this method can read CMYK and RGB. RGB either to memoryblock or to a picture object.
The memoryblock data must be in the format with bytes in the order RGB.

Feedback, Comments & Corrections

JPEGImporterMBS.ImportCMYK
Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 3.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Imports a CMYK picture.
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 should read all JPEG files you can get, but I've only tested it for 32 bit color and 8 bit grayscale.

The read CMYK values are stored in the picturedata property.

This method uses the YieldTicks property and may yield time to other threads.

Feedback, Comments & Corrections

JPEGImporterMBS.InitJPEG as boolean
Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 3.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Initializes the JPEG decompressor for use with LoopJPEG.
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:
Call FinishJPEG even if this failes.
Returns true if you can loop using LoopJPEG.

Feedback, Comments & Corrections

JPEGImporterMBS.LoopJPEG as Integer
Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 3.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Decompresses one line of the picture.
Example:
dim j as new JPEGImporterMBS
// fill properties...

if j.initJPEG then
do
loop until j.LoopJPEG<>0
end if
j.FinishJPEG

backdrop=j.Picture // nil if failed
Notes:
Return values:
0Decompression was okay
1Finished decompression
2if there was an error.
3Not initialized
4Header only was requested

Feedback, Comments & Corrections

JPEGImporterMBS.MarkerCount as Integer
Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 6.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Number of markers found in the JPEG data stream.
Example:
dim j as JPEGImporterMBS
dim f as FolderItem

f=SpecialFolder.Desktop.Child("test.jpg")
j=new JPEGImporterMBS

j.ReadMarkers=true // else no metadata is read at all

// do the import

MsgBox str(j.MarkerCount)
Notes: Only available if ReadMarkers was true on reading the JPEG data.

Feedback, Comments & Corrections

JPEGImporterMBS.MarkerItem(index as Integer) as JPEGImporterMarkerMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 6.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Returns the marker with the given index.
Example:
dim j as JPEGImporterMBS
dim f as FolderItem

f=SpecialFolder.Desktop.Child("test.jpg")
j=new JPEGImporterMBS

j.ReadMarkers=true // needed to fill ExifData property

// do the import

dim data as string = j.MarkerItem(0).Data

// work with data
Notes: Only available if ReadMarkers was true on reading the JPEG data.

Feedback, Comments & Corrections

JPEGImporterMBS.ReadHeader as boolean
Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 3.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Read the header of the JPEG data in a file or a memoryblock.
Example:
dim f as FolderItem
dim j as JPEGImporterMBS

f=SpecialFolder.Desktop.Child("Jaguar1600.jpg")
j=new JPEGImporterMBS
j.file=f
if j.ReadHeader then
MsgBox str(j.Width)+" x "+str(j.Height)
else
MsgBox "no JPEG"
end if
Notes:
You can use this function to see if the file is a JPEG image and which dimension it has.
This function calls InitJPEG and FinishJPEG, so we get all the metadata, but no picture.

Feedback, Comments & Corrections

JPEGImporterMBS.RedTestPicture as picture
Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 5.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Returns a 100x100 pixel big picture filles with RGB(255,0,0).
Notes: Just for testing how well the plugin picture code works.

Feedback, Comments & Corrections

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

The biggest plugin in space...




Links
MBS Xojo Plugins

Start Chat