Using latest WebCore, I have the following problem:
When loading png images (drawn images, not photos) in a TWebImageControl and resize them via the ResizeImage(w,h) method, it results in poor quality:
I tried to improve it by changing the line
var dataURL = canvas.toDataURL("image/png");
var dataURL = canvas.toDataURL("image/png", 1.0);
in function GetBase64Image of WEBLib.WebTools.pas, but that didn't help.
The resizing is 100% done by the browser, we just set the desired new size and the browser itself performs the resize. Given the result is PNG it is lossless compression, so this can't be causing a worse result. I also see the browser used anti-aliasing for the resize. So, I'm afraid that from TMS WEB Core level, we cannot force it to be better than this.
Thanks for the quick answer.
So my solution for showing an image with correct aspect ratio in a fixed size image control is by
- setting HeightStyle and WidthStyle of the TWebImageControl to "ssAbsolute"
- introducing a CSS class with attributes
height: 100%; width: 100%; object-fit: contain;
and applying this to the TWebImageControl