During the last few days i changed a lot, and today i’ll show you the results. 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’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:
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’t it?
For the VCL implementation, there is a new DesignTimePackage, which allows you to use it in a TImage at DesignTime. The image is loaded at nativeresolution. Set Stretch to True in TImage for an upscaled version. It’ll register *.aimg and *.AsciiImage. The current structure is just a simple textfile, but the format is subject to change in the future.
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.
I did the implementation in XE6 and hope i haven’t broken compatibility with XE. Still need to get my hands on an up to date version of Delphi. Another problem is, i don’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.
Another new addition is the possibility to alter/hook creation of a RenderContext. There are multiple Possibilities:
- set a hook with a call to the classfunction TRenderContextFactory.SetHookCreateDefaultRenderContext. This will replace the DefaultCreation for all TAsciiImages.
- Suitable if you want to replace the RenderContext with an own implementation
- set OnCreateRenderContext of your TAsciiImage instance, to override handling for this specific instance
- Suitable if you need a specific RenderContext for a specific instance