Tag Archives: Delphi

Delphi 64bit Code

Updating 32bit code to Delphi 64bit

Ever since Delphi XE2, it has been possible to generate Delphi 64bit applications from the same code base as your traditional Windows 32bit Delphi code. The business case for 64-bit for business is covered in this tech paper The Impact of 64-bit Applications to your Company’s Bottom Line.

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!

Continue reading Delphi 64bit Code

Bitmap to PNG/JPEG/JPG in Delphi / C++Builder

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);
  Stream: TMemoryStream;
  Surf: TBitmapSurface;
  aFile : string;
  ImageViewer1.Bitmap :=

  // 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 stream
      if not TBitmapCodecManager.SaveToStream( 
                       '.png') then
        raise 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.

Happy coding!

Setting the default XML DOM in Delphi XE7

Managing the default XML DOM

Scanning the whats new in RAD Studio XE7 (Delphi, C++ Builder) it covers the introduction of a new XML Dom (OmniXML) meaning there are now 3 XML DOMS to choose from when setting the default XML DOM.

  • ADOM
  • OmniXML

The XML Dom defines which engine in essence is used to work with your XML documents.

Should I read on? Well if your using SOAP or XML in your projects, then this could make a difference to your speed and performance of the applications, and it takes seconds to implement.

Continue reading Setting the default XML DOM in Delphi XE7

Castalia IDE Plugin Free with XE7 (ends soon)

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.

Don’t forget if your latest version is XE2 your last chance to qualify for upgrade pricing is now.  http://www.embarcadero.com/radoffer

The Embarcadero sales teams will be in between Christmas and new year so there is still time to code smarter in the new year.