FNCSignatureCapture - SavetoImageFile problem

Delphi 11.2
FMX App for Windows and Android

When using the SafeToImageFile method all works fine for .png but all I get is a black square when choosing to save to .bmp or .jpg and I really need to be able to save to .jpg.

Should I be doing something different for this?

Thanks

Bill

Can you try with MakeScreenShot instead?

Have tried but that also will show the clear icon and the 'sign here' text. Not a good look. I need to place the graphic on a PDF created by an app I am developing. MakeScreenShot adopts the style colour of the signature control which in this case is slightly dark so signature is not very visible. The .png works perfectly .... isn't there a way to achieve same for .jpg?

Bill

Unfortunately this is default FMX TBitmap behavior, the codecs for Android don't support BMP (FMX.Graphics.TBitmapCodecManager - RAD Studio API Documentation). JPEG is supported but it takes the background as a parameter which is black by default. We'll investigate if we can implement a background color when exporting to JPEG. So, I would suggest to export to PNG, or export to a PNG stream, then redraw the stream onto a new bitmap, then save it to JPEG.

Thank you for your suggestion. When it comes to graphics I'm a bit of a fish out of water. Can you point me to any good examples of how to do this. Have spent a little time already on this but can't find any examples of png to jpg.....maybe I'm using wrong search parameters.

Bill

Hi,

this is a sample code to go from BMP to JPEG, but I suppose it can be used to go from PNG to JPEG as well.

uses FMX.Surfaces;
 
procedure TForm1.BMPtoJPG(InputBitmap: TBitmap; outputjpgfilename: string);
// BITMAP TO PNG/JPEG/JPG
var
  Stream: TMemoryStream;
  Surf: TBitmapSurface;
begin
  Stream := TMemoryStream.Create;
  try
    Stream.Position := 0;
    Surf := TBitmapSurface.Create;
    try
      Surf.Assign(InputBitmap);
      if not TBitmapCodecManager.SaveToStream(Stream,Surf,'.jpg') then
      begin
        raise EBitmapSavingFailed.Create('Error saving Bitmap to jpg');
      end;
    finally
      Surf.Free;
    end;
    Stream.Position := 0;
    //ImageViewer1.Bitmap.LoadFromStream(Stream);
 
    Stream.Position := 0;
    Stream.SaveToFile(outputjpgfilename);
  finally
    Stream.Free;
  end;
end;

Pieter,

Many thanks. I'll see if I can make this work.

Bill