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

PictureToFileStringMBS(p as picture, compressor as string, quality as Integer) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Pictures Import and Export MBS QuickTime Plugin 3.3 Yes Yes No Yes No
Function: QuickTime will make a string from the picture using the specified compressor.
Example:
dim s as string
dim q,p as Picture

p=NewPicture(100,100,32)

s=PictureToFileStringMBS(p,"BMPf",1024)

Title=str(lenb(s))
q=StringtoPictureMBS(s,"test.bmp","")

Backdrop=q
Notes:
p as picture:
Your picture must be a pixel bitmap or in other words a picture made using newpicture. You can check it using the graphics property or just use a function like that to verify that your picture is well:

Function MakeGoodPicture(old as picture) As picture
dim p as picture

p=old
if p<>nil and old.graphics=nil then
p=newpicture(old.width,old.height,32)
p.graphics.drawpicture old,0,0
end if

return p
End Function

compressor as string:
The codec is a 4 letter code to determinate the codec to use. Possible values for QuickTime 5.0, which I've tested:

".SGI"SGI
"8BPS"Photoshop
"BMPf" Windows BMP
"JPEG"JPEG
"PICT"Mac Picture
"PNGf"PNG
"PNTG"MacPaint
"TIFF"Tiff
"TPIC"TGA
"qtif"QuickTime Image file
(if codec is "", jpeg is used as default)

quality as Integer
Any value between 0 and &h400 to indicate the quality:

&h000Min Quality
&h100Low Quality
&h200Normal Quality
&h300High Quality
&h3FFMax Quality
&h400Lossless Quality

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 function requires QuickTime 3.0 or newer!

The returned string has the encoding set to Binary. 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.

Feedback, Comments & Corrections

PicturetoStringMBS(p as picture,codec as string,quality as Integer,depth as Integer) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Pictures Import and Export MBS QuickTime Plugin Yes Yes No Yes No
Function: QuickTime will make a string from the picture using the specified codec.
Example:
dim s as string
dim pic as Picture = LogoMBS(500)
s=PicturetoStringMBS(pic,"jpeg",512,0)
Notes:
p as picture:
Your picture must be a pixel bitmap or in other words a picture made using newpicture. You can check it using the graphics property or just use a function like that to verify that your picture is well:

Function MakeGoodPicture(old as picture) As picture
dim p as picture

p=old
if p<>nil and old.graphics=nil then
p=newpicture(old.width,old.height,32)
p.graphics.drawpicture old,0,0
end if

return p
End Function

codec as string:
The codec is a 4 letter code to determinate the codec to use. Possible values for QuickTime 5.0, which I've tested:

"jpeg",
"gif ",
"png ",
"tiff",
"tga ".
(if codec is "", jpeg is used as default)

quality as Integer
Any value between 0 and &h400 to indicate the quality:

&h000Min Quality
&h100Low Quality
&h200Normal Quality
&h300High Quality
&h3FFMax Quality
&h400Lossless Quality

depth as Integer

The depth at which the image is likely to be viewed. Compressors may use this as an indication of the color or grayscale resolution of the compressed image. If you set this parameter to 0, the Image Compression Manager determines the appropriate value for the source image. Values of 1, 2, 4, 8, 16, 24, and 32 indicate the number of bits per pixel for color images. Values of 34, 36, and 40 indicate 2-bit, 4-bit, and 8-bit grayscale, respectively, for grayscale images.


Improved for RB 4.5 on Windows to work better by not flipping the image randomly.

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 function requires QuickTime 3.0 or newer!

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.

Some examples using this method:

Feedback, Comments & Corrections

StringtoPictureByOSTypeMBS(data as String, OSType as String) as Picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Pictures Import and Export MBS QuickTime Plugin Yes Yes No Yes No
Function: QuickTime will make a picture object from the provided data string (e.g. a downloaded jpeg file from the Internet) and make a picture object from it. To make it faster provide a filename or MimeType so QuickTime will work faster.
Example:
dim data as string // some jpeg data
dim p as Picture
p=StringtoPictureByOSTypeMBS(data,"JPEG")
Notes:
This function is based on the source code from Stephan Huber:
http://www.digitalmind.de/realbasic
I added it to extend it for Windows and add the inverse function.

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

The OSType is the same type like in mactype of a folderitem.

Some examples using this method:

Feedback, Comments & Corrections

StringtoPictureMBS(data as String, FileName as String, MimeType as String) as Picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Pictures Import and Export MBS QuickTime Plugin Yes Yes No Yes No
Function: QuickTime will make a picture object from the provided data string (e.g. a downloaded jpeg file from the Internet) and make a picture object from it. To make it faster provide a filename or MimeType so QuickTime will work faster.
Example:
dim data as string // picture data
dim p as picture = StringtoPictureMBS(data,"mypicture.jpg","Image/jpeg")
Notes:
This function is based on the source code from Stephan Huber
http://www.digitalmind.de/realbasic
I added it to extend it for Windows and add the inverse function.

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 function requires QuickTime 3.0 or newer!
See also FileExtensionToMimeTypeMBS function.

Some examples using this method:

Feedback, Comments & Corrections

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




Links
MBS FileMaker Plugins