We are using SVG images in our application.
Here's what our code looks like for JPEG images (it's a working sample from our application, it is similar to this):
Var
memoryStreamFile: TMemoryStream;
blobFieldFile:TBlobField;
JPEGImage: TJPEGImage;
//ImageJPEG:TImage is a TImage on the form
blobFieldFile:=ClientDataSet.fieldbyName('Image') as TblobField ;
memoryStreamFile := TMemoryStream.Create;
blobFieldFile.SaveToStream(memoryStreamFile);
memoryStreamFile.Position:=0;
JPEGImage := TJPEGImage.Create;
try
JPEGImage.LoadFromStream(memoryStreamFile);
ImageJPEG.Picture.Assign(JPEGImage);
finally
JPEGImage.Free;
end;
I would like to do the same as above for SVG images:
Var
memoryStreamFile: TMemoryStream;
blobFieldFile:TBlobField;
SVGImage: TSVGImage; -->>This does not exist
//ImageSVG:TImage is a TImage on the form
blobFieldFile:=ClientDataSet.fieldbyName('Image') as TblobField ;
memoryStreamFile := TMemoryStream.Create;
blobFieldFile.SaveToStream(memoryStreamFile);
memoryStreamFile.Position:=0;
SVGImage := TSVGImage.Create;//Sample of how I would envision it to work. Obviously this does not exist
try
SVGImage.LoadFromStream(memoryStreamFile);
ImageSVG.Picture.Assign(SVGImage);
finally
SVGImage.Free;
end;
We basically generate the SVG code in text format and would like to load the text into TImage
.
Is there a way to stream this that I'm not seeing?
I know that I can take our SVG text and save it to file, and then do TImage.Picture.LoadFromFile()
, but I prefer to do TImage.Picture.LoadFromStream()
.
I know that there are other components that could be used, ie Delphi SVG (we currently use this).