ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 SVG in database demo
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

816 Posts

Posted - Dec 07 2023 :  05:17:15  Show Profile  Reply
I could append an SVG file to the database using the FireDAC database TIEDBMultiBitmap Demo in Delphi 12 and by adding Vcl-Skia to the uses list. However, the SVG looks blurry in the TImageEnMView and very small in the TImageEnView:

attach/PeterPanino/202312751523_DBMultiBitmapFD.zip
622.11 KB

How can I show the SVG image in this demo without quality loss?

PeterPanino

816 Posts

Posted - Dec 07 2023 :  07:16:13  Show Profile  Reply
The loss of quality is apparently due to converting the SVG file into a raster image when inserting it into the database. Is it possible to influence this conversion so that a raster image of a specific minimum size is always generated?
Go to Top of Page

PeterPanino

816 Posts

Posted - Dec 07 2023 :  07:32:41  Show Profile  Reply
Specifying an explicit size, unfortunately, does not work with SVG:

fDBMultiBitmap.AppendImage( 512,512, ie24RGB );
Go to Top of Page

PeterPanino

816 Posts

Posted - Dec 07 2023 :  07:55:40  Show Profile  Reply
Even when using this Append overload, the same small raster image is produced:


    var bm := TIEBitmap.Create;
    try
      bm.Width := 512;
      bm.Height := 512;
      bm.Read(dlgOpenImage.Filename);
      fDBMultiBitmap.AppendImage( bm );
    finally
      bm.Free;
    end;
Go to Top of Page

xequte

38046 Posts

Posted - Dec 07 2023 :  15:55:39  Show Profile  Reply
Hi Peter

You don't want ImageEn to convert the file at all when it is inserted into the table, so just use regular database methods to insert the SVG file into the table, something like:


var
  fs: TFileStream;
begin
  fs := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
  try
    fs.Position := 0;
    // Transfer from the memory stream to the blobstream
    aBlobStream := BlobField.DataSet.CreateBlobStream( BlobField, bmWrite );
    try
      aBlobStream.CopyFrom( fs, fs.Size );
    finally
      aBlobStream.Free;
    end;
  finally
    fs.free;
  end;


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

xequte

38046 Posts

Posted - Dec 07 2023 :  16:07:55  Show Profile  Reply
Note: If you do want to load the image into the database as a raster format, you can set its size as follows:

var
  bmp: TIEBitmap;
begin
  bmp := TIEBitmap.Create;
  try
    bmp.ParamsEnabled := True;
    bmp.Params.LoadToWidth  := 1000;
    bmp.Params.LoadToHeight := 1000;
    bmp.Params.AutoScaleImport := True;
    bmp.Read('input.svg');

    ... Do something with bmp...

  finally
    bmp.Free;
  end;
end;


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

PeterPanino

816 Posts

Posted - Dec 08 2023 :  11:29:18  Show Profile  Reply
var
  fs: TFileStream;
begin
  fs := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
  try
    fs.Position := 0;
    // Transfer from the memory stream to the blobstream
    aBlobStream := BlobField.DataSet.CreateBlobStream( BlobField, bmWrite );
    try
      aBlobStream.CopyFrom( fs, fs.Size );
    finally
      aBlobStream.Free;
    end;
  finally
    fs.free;
  end;


It would be nice if you could integrate this into your Database demo project. SVG is quickly becoming a central topic in Delphi.
Go to Top of Page

xequte

38046 Posts

Posted - Dec 14 2023 :  19:27:41  Show Profile  Reply
Hi

Please email me for the latest beta. When TIEDBMultiBitmap stores images in blobs it will now load the image content directly (if ImageFormat is not specified).

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: