Jump to content

angusj

Members
  • Content Count

    26
  • Joined

  • Last visited

  • Days Won

    3

angusj last won the day on September 16

angusj had the most liked content!

Community Reputation

61 Excellent

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. OK, so if I understand you correctly, you're wanting to create SVG files but use ImageEN to read and render them. My strong recomendation is to create SVGs in UTF-8 format. SVGs were initially designed for web display and it's very rare to find an SVG file that isn't UTF-8 encoded (and just about everything web related is UTF-8). HTHs.
  2. I'm somewhat confused by your questions. Your first sentence implies you're wanting to bypass the rendering done by ImageEN (mentioned in your fourth sentence). Is that your intention? If so, are you intending to write your own SVG parser and renderer?
  3. Actually I forgot to mention 😱, you have to load some fonts before they can be rendered in Image32 (and SVG files only very rarely contain font resources). Image32 reads TrueType fonts both directly from files or indirectly through the OS as demo'ed in SVG101 ... procedure TForm1.FormCreate(Sender: TObject); begin ... FontManager.Load('Arial'); FontManager.Load('Arial Bold'); FontManager.Load('Arial Italic'); FontManager.Load('Arial Bold Italic'); FontManager.Load('Times New Roman'); FontManager.Load('Times New Roman Bold'); FontManager.Load('Times New Roman Italic'); FontManager.Load('Times New Roman Bold Italic'); and make sure you add Img32.Text to your uses clause. Also, you don't need to load a whole lot of fonts, just the ones that you'll need. More info here: http://www.angusj.com/delphi/image32/Docs/Units/Img32.Text/_Body.htm You certainly don't need ImagePanel, that's just useful for displaying images on a form. You can just save images to file if you wish.
  4. Hi misc_bb. Yes, I think you are 😜. Try modifying the SVG101 sample by adding a TSaveDialog control (with filters for PNG and JPG file types). Then make sure both Img32.Fmt.PNG and Img32.Fmt.JPG are in you uses clause. Finally add a mainmenu option with the following OnClick event: procedure TForm1.SaveAs1Click(Sender: TObject); begin if SaveDialog1.Execute then ImagePanel.Image.SaveToFile(SaveDialog1.FileName); end; Edit: If the image has transparency, make sure you save it as in PNG format, otherwise you'll probably get a black background. Edit2: And if you don't want to add that extra bit of code, just make sure the image panel has focus (in SVG101) and click Ctrl+C. Then you can paste the result into your favorite image editor.
  5. Done. Also, there was a problem with the last update where I failed to upload a recent change in Img32.pas which caused problems in Img32.Layers. That's now fixed too. I've also made a minor update to the Layers301 sample application. https://sourceforge.net/projects/image32/files/
  6. Just updated to version 3.2 https://sourceforge.net/projects/image32/
  7. Using your metaphor they're only optional if you buy the sports car. 😜
  8. Try this ... unit Img32.SVG.Reader; .... TElement = class private .... fId : UTF8String; public .... property Id: UTF8String read fId; end; procedure Id_Attrib(aOwnerEl: TElement; const value: UTF8String); begin aOwnerEl.fId := value; //ADD THIS LINE aOwnerEl.fReader.fIdList.AddObject(string(value), aOwnerEl); end;
  9. @Rollo62 I've just uploaded to Image32's SourceForge repository another update to the SVG reader. The changes are primarily in anticipation of future animation but they should also allow you to dynamically change (most) element properties including fill and stroke colors, opacity etc. https://sourceforge.net/p/image32/code/ci/master/tree/source/ Example: procedure ChangeNearBlackPenToNavy(element: TElement); var i: integer; dd: TDrawData; begin if (element.DrawData.strokeColor <> clInvalid) and (element.DrawData.strokeColor <> clNone32) and (RgbToHsl(element.DrawData.strokeColor).lum < 5) then begin dd := element.DrawData; dd.strokeColor := clNavy32; element.DrawData := dd; end; //recursively call all children for i := 0 to element.ChildCount -1 do ChangeNearBlackPenToNavy(element[i]); end; //and to use the above procedure begin if not svgReader.LoadFromFile(fn) then Exit; //edit the loaded SVG elements ChangeNearBlackPenToNavy(svgReader.RootElement); //draw the edited SVG elements svgReader.DrawImage(ImagePanel.Image, true); end;
  10. @Rollo62 Thank you for the encouraging feedback. I'm glad Image32 is behaving as advertised 😁. I'm afraid Image32's SVG support is pretty much read-only. There is an extremely basic SVG writer, that's separate from the reader, and really just proof of concept. The reader was designed for speed, not for editing as you've discovered. Regarding hashing: I'm assuming it's faster than string comparing, which there are many, but honestly I haven't tested if it makes a difference and how much (and yes it does complicate the code). Regarding UTF8String: Just about every SVG is written in UTF-8 which given it was initially created for web graphics makes sense. So again for performance the file isn't converted to Unicode, and the XML parser just creates pointers into the UTF-8 stream. No, not at the moment. I do intend to convert the reader to read-write at some stage. However I'm not sure when that will happen as I'm taking a much needed breather after spending a lot of time on this. I also have another project (my Clipper library) that's been stuck in a partial update for several years that's probably my next priority. If there was huge demand for read-write SVGs I might make that the higher priority but my perception is that reading SVGs is/was by far the bigger need. Cheers.
  11. angusj

    SVG Library

    Image32 will happily convert SVG to PNG/BMP/JPEG. http://www.angusj.com/delphi/image32/Docs/Overview.htm http://www.angusj.com/delphi/image32/Docs/Units/Img32.Fmt.SVG/_Body.htm
  12. I started with open source back on Compuserve, before the Internet existed. My first PC had Z80A CPU, CP/M OS plus dual 5.25" floppies.
  13. No worries Rob. Judging by the number of 'likes' etc I'm getting I suspect a few others have made the same mistake. Keep it up! 😜
  14. Hi Tim. Yeah, writing to SVG is currently barely functional (unlike reading them). Also, you can't do it the way you write/save images of other formats. There is an SVG writing demo, but it's very primative. I think for the foreseeable future is best to consider SVG as read only.
×