Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

JPEGStringToPictureMBS(buf as string) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method JPEG MBS Images Plugin Yes Yes Yes Yes No
Function: Reads a picture from a JPEG file.
Example:
dim s as string
dim h as new HTTPSocket

s=h.Get("http://www.monkeybreadsoftware.de/realbasic/images/rbplugin.jpg",90)

Backdrop=JPEGStringToPictureMBS(s)
Notes: Short version of the "JPEGStringToPicture(buf as string,allowdamaged as Boolean) as picture" method. allowdamaged is set to false.

See also:

Some examples using this method:

Some FAQ entries about this method:

Feedback, Comments & Corrections

JPEGStringToPictureMBS(buf as string,allowdamaged as Boolean) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method JPEG MBS Images Plugin Yes Yes Yes Yes No
Function: Reads a picture from a JPEG file.
Example:
dim p as Picture = LogoMBS(500)
dim s as string = PictureToJPEGStringMBS(p, 80)

s = leftb(s, lenb(s)-1000) // remove last 1000 bytes

dim q as Picture = JPEGStringToPictureMBS(s, true)

Backdrop = q
Notes:
This methods should read all JPEG file data you can get, but I've only tested it for 32 bit color and 8 bit grayscale.

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 120 KB big!
(REALbasic's OpenAsPicture depends on QuickTime)

I wrote it mainly because Realbasic'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.

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

See the "JPEGToString example", "jpeg load crashtest" and "SaveJPEG without QuickTime" examples.

See also:

Some examples using this method:

Some FAQ entries about this method:

Feedback, Comments & Corrections

PictureToJPEGStringMBS(pic as picture, quality as Integer = 80) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method JPEG MBS Images Plugin Yes Yes Yes Yes No
Function: Saves a picture into a string using JPEG compression.
Example:
dim p as Picture = LogoMBS(500)
dim s as string = PictureToJPEGStringMBS(p, 80)
dim q as Picture = JPEGStringToPictureMBS(s)

Backdrop = q
Notes:
This methods saves 32bit pictures to a file using JPEG Compression. Using the parameter you can specify the quality in range between 25 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 should be a bitmap picture without alpha channel or mask.
Use the JPEGExporterMBS class for more options.

The returned string has the encoding set to binary (no encoding). 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.

The picture is always encoded with 72 dpi. If you want to set a different dpi value, please use the JPEGExporterMBS class.

Some examples using this method:

Some FAQ entries about this method:

Feedback, Comments & Corrections

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




Links
MBS Xojo Plugins