[Gambas-user] Trying to improve the image quality output

Benoît Minisini g4mba5 at gmail.com
Thu Mar 10 13:51:06 CET 2022


Le 09/03/2022 à 12:08, Martin Belmonte a écrit :
> Hi,
> I use a gambas code [1] to made images imposition [4] in order to print 
> two pages in one sheet and save paper. The final image quality is lower 
> that original so:
> 
> 1) Is possible improve the final quality in the gambas code [1] ?
> 2) There are some code to use Imagemagick with Extern in gambas, focused
> in the Montage function [2]? I use [3] in terminal that offer a better 
> image quality that gambas Cairo.Paint.
> 
> Please see the screenshot in imgur.com, where is possible see the 
> diferences between original image and gambas otput image
> https://imgur.com/7frYu2F
> 
> [1]
> 
>   hCanvas = New CairoPdfSurface("/tmp/job.pdf, 420.0, 297.0)
>   Cairo.Begin(hCanvas)
> 
>   h = 297 * 2.85
>   w = h * (1 / Sqr(2))
>   hImageL = Image.Load("/tmp/001.tif").Stretch(w, h)
>   hImageR = Image.Load("/tmp/002.tif"]).Stretch(w, h)
> 
>   Cairo.Source = Cairo.ImagePattern(hImageL, 0, 0,, Cairo.FilterBest)
>   Cairo.Paint
>   Cairo.Source = Cairo.ImagePattern(hImageR, w, 0,, Cairo.FilterBest)
>   Cairo.Paint
>   Cairo.ShowPage()
> 
> 
> [2]
> https://imagemagick.org/script/montage.php
> [3]
> magick montage -geometry +4+4 001.tif 002.tif montage.jpeg
> 
> [4]
> https://en.wikipedia.org/wiki/Imposition
> 
> -----
> 
> Regards
> Martín.
> 

Of course.

Image dimensions are in pixels. Cairo draws with logical coordinates.

You must not stretch the image to the logical coordinates, it's a 
non-sense. In your code, you are losing pixels.

You must instead modify the pattern matrix, so that the pattern 
coordinates (in pixels) are stretched to the Cairo logical coordinates.

Regards,

-- 
Benoît Minisini


More information about the User mailing list