The TRESTRequestDataSetAdapter component (introduced in RAD Studio 11.0) helps create a REST Request, from a TDataSet to send to a REST Server.
The TRESTRequestDataSetAdapter is a companion for the TRESTResponseDataSetAdapter component that takes a JSON data packet from a REST request response and concerts it into a TDataSet.
The TRESTRequestDataSetAdapter works well with the TEMSDataSetResource to accept data from POST, PUT, DELETE operations from the client side to update server side data.
This video will take you though how this works, and also demo’s a really useful unit of code, REST.DataUpdater.pas, that automatically manages the data transport based on the type of data update you have made.
On the whole moving to 64bit (on iOS or Windows) is beautifully simple to achieve! It can be just as simple as adding the Delphi 64bit Windows target platform in the project manager and rebuilding the project.
My experience from talking to many developers who have moved up is that normally there are a few things to check in your code but typically its not a massive task to get compiling and ready to test.
A lot has been recorded on moving from Windows 32bit to Windows 64bit Delphi and this should be a useful summary if your just planning now moving up from older versions of Delphi to Delphi 10. If you are building iOS applications, then you will need to use the 64bit build now to get into the AppStore. Thankfully, Delphi has made the task of using 64bit very simple across all platforms and protected us from the headaches non Delphi Developers have had on the whole.
Lets start with this short video from David I who covers some the foundations in 7 minutes!
In FireMonkey, Bitmap is the common currency for working with images. If you want to send an image via Stream using LiveBindings or want to save an Image to disk or into a database on a device with limited storage however, they are quite large.
Thankfully FireMonkey has a really easy to use CodecManager that allows you to SaveToFile or SaveToStream and convert to PNG or JPG across all platforms (which are vastly smaller in size).
Creating a PNG, JPG/JPEG is as simple as calling the Bitmap.SaveToFile with the correct file extension. This works really well with even more extensions supported.
Personally I would use PNG as the JPG formats are around the same size on some test I’ve run, but produce a better quality of image, especially when grabbing screenshots.
SaveToStream and TBitmapCodecManager
Bitmap.SaveToStream doesn’t expose the CodexManager in the same way as it is available automatically with the SaveToFile option so takes a little more work to get a compressed image into the memory stream.
This is done using the TBitmapCodecManager class. A simple screen test has gone from over 1mb as a bitmap to around 6kb when saved to PNG using this approach.
The following code is an example using two image viewers (and a few save to files to help demonstrate the difference in file size). The key part is the TBitmapSurface and TBitmapCodecManager.
procedure TForm1.Button1Click(Sender: TObject);
aFile : string;
// Comparison save file as BMP
aFile := 'c:\test\myImage';
Stream := TMemoryStream.Create;
Stream.Position := 0;
Surf := TBitmapSurface.Create;
// use the codec to save Surface to streamifnot TBitmapCodecManager.SaveToStream(
'.png') thenraise EBitmapSavingFailed.Create(
'Error saving Bitmap to png');
// do something with the png stream image
Stream.Position := 0;
// comparison output as PNG from the stream
Stream.Position := 0;
Now, you can obviously save as a ‘PNG’ from the bitmap, but the above code shows how to avoid saving a file to disk unless you really need to.
One present I’m going to be playing with over Christmas is the Castalia IDE plug in. If you want to know why, check out the 10 minute demo here of some of the cool refactoring and IDE tools that Castalia provides.
The Embarcadero sales teams will be in between Christmas and new year so there is still time to code smarter in the new year.
Programming with Delphi & InterBase
Privacy & Cookies Policy
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.