Home » U++ Library support » U++ Library : Other (not classified elsewhere) » PdfDraw, custom DPI request + my fix
|
|
|
|
Re: PdfDraw, custom DPI request + my fix [message #58827 is a reply to message #58818] |
Thu, 15 September 2022 10:59 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
OK, that is misunderstanding and the problem is elsewhere.
Image::GetSize returns "pixel size" without taking account of DPI (or any other physical dimension).
Now there is Image::GetDots, which returns the size of image in "dots", where dot which is basically 600DPI pixel. Everything in U++ Draw related code that deals with physical dimensions is in dots, including all dimensions in PdfDraw.
Long story short, if you use GetDots instead of GetSize here, it will work as you needed.
Just for reference, to be sure I have tested with this code:
GUI_APP_MAIN
{
for(const char *fn : { "C:/upp/MyApps/6x9_300dpi.png", "C:/upp/MyApps/6x9_600dpi.png" }) {
Image img = StreamRaster::LoadFileAny(fn);
Size isz = img.GetDots();
DDUMP(isz);
PdfDraw draw(isz.cx, isz.cy);
draw.DrawImage(0, 0, isz.cx, isz.cy, img);
SaveFile("D:/xxx/" + GetFileTitle(fn) + ".pdf", draw.Finish());
}
}
|
|
|
Re: PdfDraw, custom DPI request + my fix [message #58829 is a reply to message #58764] |
Thu, 15 September 2022 18:55 |
Mountacir
Messages: 45 Registered: November 2021
|
Member |
|
|
All this time and the problem was me using GetSize() instead of GetDots().
At some point i even doubled the image sizes to get to correct output pdf. well, this is embarrassing.
Very sorry for my wrong PR and thank you so much for your help.
|
|
|
Goto Forum:
Current Time: Fri Mar 29 13:46:26 CET 2024
Total time taken to generate the page: 0.01817 seconds
|