From Clomosy Docs
No edit summary |
ClomosyAdmin (talk | contribs) No edit summary |
||
| Line 45: | Line 45: | ||
<h2> See Also </h2> | <h2> See Also </h2> | ||
* [[Clomosy_Class#File_and_Stream_Handling | File and Stream Handling]] | * [[Clomosy_Class#File_and_Stream_Handling | File and Stream Handling]] | ||
{{#seo:|description=Master Base64ToStream in Clomosy! Learn how to convert Base64-encoded content into streams for enhanced data management in your mobile apps.}} | |||
Latest revision as of 14:36, 23 December 2024
function Clomosy.Base64ToStream(ABase64:string):TclMemoryStream;
Base64ToStream is a function used to convert a Base64 string to a stream (TCLMemoryStream). This function takes a Base64 code and converts it to a TCLMemoryStream object, making the data readable.
For example, Base64ToStream function can be used to convert Base64-encoded data obtained from a file or over a network into a TCLMemoryStream. This allows the data to be processed using this stream or transferred elsewhere later.
Example
In the example, the data held in Base64 format within the TclMemo object is converted to a TCLMemoryStream object using the Base64ToStream function. This converted data is then transferred to a TclImage object.
var
Form1 : TCLForm;
noteMemo : TclMemo;
SourceImg : TCLImage;
void memoBase64ToStreamClick;
var
LMemStream:TCLMemoryStream;
{
noteMemo.Lines.Text = Clomosy.FileToBase64(clPathCombine('apple.png',Clomosy.AppFilesPath));
LMemStream = Clomosy.Base64ToStream(noteMemo.Lines.Text);
SourceImg.Bitmap.LoadFromStream(LMemStream);
}
//------ Main Code ------
{
Form1 = TCLForm.Create(Self);
Form1.AddAssetFromUrl('https://clomosy.com/demos/apple.png');
noteMemo = Form1.AddNewMemo(Form1,'noteMemo','---');
noteMemo.Align = alMostTop;
noteMemo.Height = 400;
noteMemo.StyledSettings = ssFamily;
noteMemo.TextSettings.WordWrap = True;
Form1.AddNewEvent(noteMemo,tbeOnClick,'memoBase64ToStreamClick');
SourceImg = Form1.AddNewImage(Form1,'SourceImg');
SourceImg.Align = alClient;
Form1.setImage(SourceImg,'https://clomosy.com/learn/xMark.png');
Form1.Run;
}