Usage of TBitmapCodecManager in C++

Viewed 67

Please tell me how to use TBitmapCodecManager correctly in C++. My development environment is C++Builder 10.4 (Community Eddition) under FMX.

Here is the code of Delphi's TBitmapCodecManager sample rewritten for C++ for the purpose of PNG->ICO conversion.

However, a compile error occurs only on the last line:

bcc32 error: [E2108] typedef 'TBitmapCodecManager' is used incorrectly.

TMemoryStream * strm;
strm = new TMemoryStream;

TBitmapSurface * bmpss;
bmpss = new TBitmapSurface;

TBitmapCodecSaveParams * pm;
pm = new TBitmapCodecSaveParams;

pm-> Quality = 100;
bmpss-> Assign (Image1-> Bitmap);

TBitmapCodecManager.SaveToStream (strm, bmpss,'.ico', pm); // <-- error here

Could you please tell me the correct usage?

ref)png / bmp-> ico by FMX (c ++) TBitmapCodecManager

1 Answers

TBitmapCodecManager::SaveToStream() is a class method in Delphi, which is translated to a static method in C++ (actually to __classmethod, which is a special kind of static in C++Builder). Unlike in Delphi, in C++ you need to use the :: scope resolution operator to call a static method on a class type, not the . member access operator.

Also, C++ uses "" for strings, and '' for characters, unlike in Delphi which uses '' for both.

Try this:

TBitmapCodecManager::SaveToStream(strm, bmpss, _D(".ico"), pm);

Regarding the use of the _D() macro, this is explained in Embarcadero's documentation: String Literals char16_t and wchar_t on macOS and iOS.

Related