{"id":143,"date":"2015-05-27T16:29:55","date_gmt":"2015-05-27T16:29:55","guid":{"rendered":"http:\/\/memnarch.bplaced.net\/blog\/?p=143"},"modified":"2015-05-27T20:27:35","modified_gmt":"2015-05-27T20:27:35","slug":"asciiimage-for-delphi-gdi-downsampling-firemonkey-and-more","status":"publish","type":"post","link":"https:\/\/memnarch.bplaced.net\/blog\/2015\/05\/asciiimage-for-delphi-gdi-downsampling-firemonkey-and-more\/","title":{"rendered":"AsciiImage for Delphi: GDI-Downsampling, FireMonkey and more!"},"content":{"rendered":"<p>During the last few days i changed a lot, and today i&#8217;ll show you the results.<!--more--> First of all, the GDI-Based Rendering does some sort of DownSampling which allows smoother Graphics. This is implemented by scaling the image by 2, 4 or 8(default) and stretchdrawing it back to it&#8217;s original size. You can change the global default for Downsampling by using the corresponding class methods. Here is an example on how it looks:<\/p>\n<p><a href=\"https:\/\/memnarch.bplaced.net\/blog\/wp-content\/uploads\/2015\/05\/DownSampling.png\"><img decoding=\"async\" loading=\"lazy\" class=\" size-full wp-image-144 aligncenter\" src=\"https:\/\/memnarch.bplaced.net\/blog\/wp-content\/uploads\/2015\/05\/DownSampling.png\" alt=\"DownSampling\" width=\"651\" height=\"676\" srcset=\"https:\/\/memnarch.bplaced.net\/blog\/wp-content\/uploads\/2015\/05\/DownSampling.png 651w, https:\/\/memnarch.bplaced.net\/blog\/wp-content\/uploads\/2015\/05\/DownSampling-289x300.png 289w\" sizes=\"(max-width: 651px) 100vw, 651px\" \/><\/a><\/p>\n<p>The AsciiImage has a native resolution of 16 and is rendered to a target with a resolution of 32. The second one with downsampling looks a lot better, doesn&#8217;t it?<\/p>\n<p>For the VCL implementation, there is a new DesignTimePackage, which allows you to use it in a TImage at DesignTime.\u00a0The image is loaded at nativeresolution. Set Stretch to True in TImage for an upscaled version. It&#8217;ll register *.aimg and *.AsciiImage.\u00a0 The current structure is just a simple textfile, but the format is subject to change in the future.<\/p>\n<p>Did i say VCL-Implementation before? Yes, and that means, there is a FireMonkey-Implementation, too! For you nothing changes, except, that you can use the AsciiImage-Unit in VCL and FireMonkey. A corresponding RenderContext is created automatically.<\/p>\n<p><a href=\"https:\/\/memnarch.bplaced.net\/blog\/wp-content\/uploads\/2015\/05\/Firemonkey.png\"><img decoding=\"async\" loading=\"lazy\" class=\" size-full wp-image-145 aligncenter\" src=\"https:\/\/memnarch.bplaced.net\/blog\/wp-content\/uploads\/2015\/05\/Firemonkey.png\" alt=\"Firemonkey\" width=\"550\" height=\"333\" srcset=\"https:\/\/memnarch.bplaced.net\/blog\/wp-content\/uploads\/2015\/05\/Firemonkey.png 550w, https:\/\/memnarch.bplaced.net\/blog\/wp-content\/uploads\/2015\/05\/Firemonkey-300x182.png 300w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><\/p>\n<p>I did the implementation in XE6 and hope i haven&#8217;t broken compatibility with XE. Still need to get my hands on an up to date version of Delphi. Another problem is, i don&#8217;t have a Mac. But i do have an Android, but no mobile-addon. So everything was tested on windows-only. From what i can see, there are no windows-dependencies in the Firemonkey-Version. Feedback is welcome, to get that thing working if you encounter problems.<\/p>\n<p>Another new addition is the possibility to alter\/hook creation of a RenderContext. There are multiple Possibilities:<\/p>\n<ul>\n<li>set a hook with a call to the classfunction TRenderContextFactory.SetHookCreateDefaultRenderContext. This will replace the DefaultCreation for all TAsciiImages.\n<ul>\n<li>Suitable if you want to replace the RenderContext with an own implementation<\/li>\n<\/ul>\n<\/li>\n<li>set OnCreateRenderContext of your TAsciiImage instance, to override handling for this specific instance\n<ul>\n<li>Suitable if you need a specific RenderContext for a specific instance<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>During the last few days i changed a lot, and today i&#8217;ll show you the results.<\/p>\n","protected":false},"author":1,"featured_media":148,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[11,7,16,14,15],"_links":{"self":[{"href":"https:\/\/memnarch.bplaced.net\/blog\/wp-json\/wp\/v2\/posts\/143"}],"collection":[{"href":"https:\/\/memnarch.bplaced.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/memnarch.bplaced.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/memnarch.bplaced.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/memnarch.bplaced.net\/blog\/wp-json\/wp\/v2\/comments?post=143"}],"version-history":[{"count":4,"href":"https:\/\/memnarch.bplaced.net\/blog\/wp-json\/wp\/v2\/posts\/143\/revisions"}],"predecessor-version":[{"id":150,"href":"https:\/\/memnarch.bplaced.net\/blog\/wp-json\/wp\/v2\/posts\/143\/revisions\/150"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/memnarch.bplaced.net\/blog\/wp-json\/wp\/v2\/media\/148"}],"wp:attachment":[{"href":"https:\/\/memnarch.bplaced.net\/blog\/wp-json\/wp\/v2\/media?parent=143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/memnarch.bplaced.net\/blog\/wp-json\/wp\/v2\/categories?post=143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/memnarch.bplaced.net\/blog\/wp-json\/wp\/v2\/tags?post=143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}