Blog Options
Archive
<< April 2024 >>-
Wednesday 24
- Expanding the StellarDS.io tooling -
Monday 22
- Easy Guide to Building a Pexels Gallery App with TMS WEB Core -
Wednesday 17
- New free component for sophisticated file uploads with TMS WEB Core -
Tuesday 16
- Closing the gap with TMS FNC UI Pack new additions -
Thursday 11
- Unveiling the Latest Enhancements in TMS VCL UI Pack -
Friday 5
- TMS components and Delphi and C++Builder 12.1 -
Wednesday 3
- Customizing the login page of your application using TMS Sphinx
- A Python library for using StellarDS.io effortlessly
- Introducing: How it Works with Holger - Building a Pexels gallery app with TMS WEB Core video series
- TMS FNC Cloud Pack with StellarDS.io backend: unparalleled productivity in VCL & FMX
Authors
- Bernard Roussely (1)
- Wagner Landgraf (82)
- Roman Yankovsky (2)
- Bart Holvoet (27)
- Aaron Decramer (18)
- Pieter Scheldeman (99)
- Nancy Lescouhier (32)
- Adrian Gallero (33)
- Bruno Fierens (404)
- Marcos Douglas B. Santos (5)
- Wagner R. Landgraf (1)
- Bradley Velghe (16)
- Bernard (2)
- Andrew Simard (86)
- Holger Flick (15)
- Gjalt Vanhouwaert (30)
- Tunde Keller (22)
- Masiha Zemarai (119)
Blog
All Blog Posts | Next Post | Previous PostTMS WEB Core v1.2 tips & tricks part 7: Get Base64 encoding for images
Bookmarks:Thursday, June 27, 2019
Not so long ago, I posted about how to convert an image into a Base64 string. Today, I will show you that using TMS Web Core, this is even easier.If we look into the source code of TMS Web Core, we find that the custom image control adds a public property called Base64Image of type string. That means, we can read the Base64 string of an image using that property. However, this is a read-only property. You cannot assign a Base64-string to it in order to assign image data. I will show a different approach how to work with Base64-strings for images in one of my next posts.
TCustomImageControl = class(TCustomControl) // ... public // ... property Base64Image: string read GetBase64Img; end;
Lets try this functionality. Drop (1) a TWebImage (WebImage) and a (2) TWebMemo (WebMemo) on the form.
Implement the OnCreate event of the form as follows to load an image and assign its Base64 representation to the memo:
procedure TForm1.WebFormCreate(Sender: TObject); begin WebImage.URL := 'https://images.pexels.com/photos/' + '2355519/pexels-photo-2355519.jpeg'; WebMemo.Lines.Text := WebImage.Base64Image; end;
Running the application results in the following app in the web browser:
Note that we can also assign a URL to the web image component in order to load an image.
Holger Flick
Bookmarks:
This blog post has received 4 comments.
2. Monday, October 7, 2019 at 2:51:53 PM
You could extend the demo by showing how to load to image the Base64 string in the memo.
Dino Gomezel
3. Monday, October 7, 2019 at 5:32:05 PM
You can set an image as base64 data with
WebImageControl.URL= ''data:image/png;base64,''+ base64stringimagedata;
WebImageControl.URL= ''data:image/png;base64,''+ base64stringimagedata;
Bruno Fierens
4. Tuesday, October 8, 2019 at 9:37:04 AM
Thank you!
Dino Gomezel
All Blog Posts | Next Post | Previous Post
Are there any additiona examples about TWeb(Db)ImageControl ?
Dino Gomezel