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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 SVG to BMP?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
PeterPanino Posted - Aug 19 2024 : 15:07:18
I need to create 32-bit BITMAP Thumbnail images from SVG files (preserving transparency) quickly and efficiently, with a customizable size.

Is this possible with ImageEn?
9   L A T E S T    R E P L I E S    (Newest First)
PeterPanino Posted - Aug 21 2024 : 12:12:24
Hi Nigel,

I have now solved the problem using the Skia capabilities in Delphi 12. I will publish a blog article and then post a link here.
xequte Posted - Aug 21 2024 : 05:21:12
Hi

Please provide a sample image that creates a black square.


Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - Aug 21 2024 : 02:10:27
This has created so far the best results:


var
  iebmp: TIEBitmap;
begin
  iebmp := TIEBitmap.Create;
  iebmp.LoadFromFile(ASVGFile);
  iebmp.CopyToTBitmap(Bitmap, True);


But the resulting Bitmap size is too small and randomly creates just a black square.
xequte Posted - Aug 20 2024 : 22:17:25
These both work fine for me:

  bmp1 := TIEBitmap.Create();
  bmp1.LoadFromFile( 'D:\Salzburg - Herbststimmung.svg' );
  bmp1.SaveToFile( 'D:\Salzburg - Herbststimmung.bmp' );
  bmp1.Free;


  io := TImageEnIO.Create(nil);
  try
    io.ImportFromFileSVG( 'D:\Salzburg - Herbststimmung.svg', AWidth, AHeight, True);
    io.SaveToFile('D:\Salzburg - Herbststimmung2.bmp');
  finally
    io.Free;
  end;



Nigel
Xequte Software
www.imageen.com
xequte Posted - Aug 20 2024 : 22:12:01
Accessing TIEBitmap.VclBitmap changes the bitmap location to TBitmap (so your debugging code will actually change the operation of ImageEn (making it more prone to memory errors). Instead call TIEBitmap.AssignTo() to output to a temporary bitmap and send that to CodeSite.

Alternatively (and off the record) you can use:

CodeSite.Send('ThisImageEnIO.IEBitmap:', ThisImageEnIO.IEBitmap.GetTempTBitmapEx() );


Nigel
Xequte Software
www.imageen.com
xequte Posted - Aug 20 2024 : 22:07:58
Hi Peter

Implementation of our native SVG support is ongoing:

http://www.imageen.com/help/SVG_Implementation_Status.html

But both the files you posted are supported in the current beta (email us).

Skia will generally give a better result, but is only supported in Delphi 12 and requires a large DLL.

It is not enough to add Vcl.Skia to your uses at run-time, it also needs to be enabled in the project (which copies the necessary the DLL, among other things).


Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - Aug 20 2024 : 03:35:20
I've done some tests by trying to get a valid TBitmap out from TImageEnIO:

CodeSite.Send('ASVGFilePath', ASVGFilePath); // this shows the correct SVG file path
var ThisImageEnIO := TImageEnIO.Create(nil);
try
  try
    ThisImageEnIO.ImportFromFileSVG(ASVGFilePath, AWidth, AHeight, True);
    ThisImageEnIO.IEBitmap.Write('test.bmp'); 
    CodeSite.Send('ThisImageEnIO.IEBitmap.VclBitmap:', ThisImageEnIO.IEBitmap.VclBitmap); // This outputs a BLACK BITMAP!
    ThisImageEnIO.Bitmap.SaveToFile('test.bmp'); // this is not executed
    CodeSite.Send('ThisImageEnIO.Bitmap:', ThisImageEnIO.Bitmap); // this is not executed
  except
    CodeSite.Send('Exception'); // this is not executed
  end;
finally
  ThisImageEnIO.Free;
end;


This workaround seems to work, but randomly, the same SVG file does not:

ThisImageEnIO.ImportFromFileSVG(ASVGPath, AWidth, AHeight, True);
var bmp := TBitmap.Create;
try
  ThisImageEnIO.IEBitmap.CopyToTBitmap(bmp); // randomly creates a BLACK square with the same SVG file that worked previously
  CodeSite.Send('bmp', bmp); 
finally
  bmp.Free;
end;


So, how can I create a valid TBitmap in memory from TImageEnIO?
PeterPanino Posted - Aug 20 2024 : 00:53:26
Hi Nigel

I've tried the SVGParsing demo:

\Demos\InputOutput\SVGParsing\SVGParsing.dpr

Unfortunately, it does not work with the attached SVG image:

attach/PeterPanino/202482005034_Salzburg - Herbststimmung.zip
1013.23 KB

Nor does it with this small SVG image:

attach/PeterPanino/20248201138_directions-arrows-8-blue.zip
1.29 KB

It does work, however, if I add Vcl.Skia to the uses clause. Maybe you should include Vcl.Skia in your demo by using a conditional compiler directive:

uses
  {$IF CompilerVersion >= 36.0}  // Delphi 12 corresponds to version 36.0
  Vcl.Skia,
  {$ENDIF}
  System.SysUtils, Vcl.Forms, ...;  // other units
xequte Posted - Aug 19 2024 : 17:46:33
Hi Peter

Yes, you can Native, Skia (Delphi 12) or ImageMagick for SVG loading. See:

https://www.imageen.com/help/File_Formats.html#SVG

To save as a 32bit Bitmap, see the example at:

http://www.imageen.com/help/TIEBitmap.SynchronizeRGBA.html

Nigel
Xequte Software
www.imageen.com