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 ![Go to previous message Go to previous message](theme/default/images/up.png) ![Go to next message Go to next message](theme/default/images/down.png) |
![](https://www.ultimatepp.org/forums/images/custom_avatars/3.png) |
mirek
Messages: 14003 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 ![Go to previous message Go to previous message](theme/default/images/up.png) |
Mountacir
Messages: 49 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: Sun Sep 01 07:24:46 CEST 2024
Total time taken to generate the page: 0.00573 seconds
|