<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi,</p>
<p>Following sos' suggestion, we tried to get Image Preferred DPI
from file properties. We thought to use this value directly to
draw bitmap. After asking the last question we found a sample in
sfx2/source/dialog/dinfdlg.cxx to get this property value. So we
added the following code to get the DPI:</p>
<p><br>
</p>
<p><span style="font-family:monospace"><span
style="color:#000000;background-color:#ffffff;"> </span><span
style="background-color: rgb(255, 255, 255);"> </span><span
style="background-color: rgb(255, 255, 255);">/* get Image
Preferred DPI from File/Properties. User can specify DPI they
wanted</span><span
style="background-color: rgb(255, 255, 255);">
</span><br>
<span style="background-color: rgb(255, 255, 255);">
* to exported. */</span><span
style="background-color: rgb(255, 255, 255);">
</span><br>
SfxObjectShell* pDocSh = SfxObjectShell::Current();
<br>
sal_Int32 nImagePreferredDPI = <span
style="background-color: rgb(255, 255, 255);">0</span><span
style="background-color: rgb(255, 255, 255);">;
</span><br>
<span style="background-color: rgb(255, 255, 255);">if</span><span
style="background-color: rgb(255, 255, 255);"> (pDocSh)
</span><br>
{
<br>
<span
style="background-color: rgb(255, 255, 255);">try</span><span
style="background-color: rgb(255, 255, 255);">
</span><br>
{
<br>
uno::Reference<
lang::XMultiServiceFactory > xFac( pDocSh->GetModel(),
uno::<br>
UNO_QUERY_THROW );
<br>
uno::Reference<
beans::XPropertySet > xProps( xFac->createInstance(<span
style="background-color: rgb(255, 255, 255);">"com.sun.</span><br>
star.document.Settings"<span
style="background-color: rgb(255, 255, 255);">),
uno::UNO_QUERY_THROW );
</span><br>
xProps->getPropertyValue(<span
style="background-color: rgb(255, 255, 255);">"ImagePreferredDPI"</span><span
style="background-color: rgb(255, 255, 255);">) >>=
nImagePreferredDPI;
</span><br>
}
<br>
<span
style="background-color: rgb(255, 255, 255);">catch</span><span
style="background-color: rgb(255, 255, 255);">(
uno::Exception& )
</span><br>
{
<br>
}
<br>
}<br>
<br>
</span></p>
<p><span style="font-family:monospace"></span>then sent the
nImagePreferredDPI to generate the bitmap. It worked! At least
we can use designated DPI to get a better bitmap quality.</p>
<p>Then when we tried to patch it to latest libreoffice.core and
compile it, it failed to link:</p>
<p><font face="monospace">/usr/bin/ld:
/home/lodev/git/libreoffice.core/workdir/CxxObject/vcl/source/gdi/vectorgraphicdata.o:
in function
`convertPrimitive2DSequenceToBitmapEx(std::deque<com::sun::star::uno::Reference<com::sun::star::graphic::XPrimitive2D>,
std::allocator<com::sun::star::uno::Reference<com::sun::star::graphic::XPrimitive2D>
> > const&, basegfx::B2DRange const&, unsigned
int, o3tl::Length, std::optional<Size> const&)':<br>
vectorgraphicdata.cxx:(.text+0x226d): undefined reference to
`SfxObjectShell::Current()'<br>
/usr/bin/ld: vectorgraphicdata.cxx:(.text+0x228f): undefined
reference to `SfxObjectShell::GetModel() const'<br>
collect2: error: ld returned 1 exit status<br>
make[1]: ***
[/home/lodev/git/libreoffice.core/vcl/Library_vcl.mk:20:/home/lodev/git/libreoffice.core/instdir/program/libvcllo.so]
錯誤 1</font><br>
</p>
<p>We thought that the time we succeeded should be because the
related objects (sfx2) had been there when we tried, so it could
compiled and linked successfully. This time we did it from
starting so it failed because the object files were no longer
there, and we have no idea how to make sfx objects compile first.<br>
</p>
<p>So again we're stuck. We did prove the idea, using Image
Preferred DPI to generate better bitmap, works. User can specify
a bigger DPI there to get better bitmap resolutions after
exporting to OOXML. Just that maybe we shouldn't use sfx object
to get the property. But we have no idea how to get the property
value since we're not very familiar with the reference things. </p>
<p>Would anyone please give a little help and hints here?</p>
<p><br>
</p>
<p>Thanks, Dev<br>
</p>
<p><br>
<span style="font-family:monospace"></span></p>
<div class="moz-cite-prefix">Lodev 於 2023/9/11 21:32 寫道:<br>
</div>
<blockquote type="cite"
cite="mid:1b4fbdd7-2384-48e4-9b0f-fb1152a1d148@ossii.com.tw">Hi,
<br>
<br>
sos 於 2023/8/31 17:53 寫道:
<br>
<blockquote type="cite">
<br>
Sorry to come back to this: every document has a property called
"Image Preferred DPI" that can be used to represent the printing
intentions of that document.
<br>
<br>
Apparent dimensions are a result of deviding the available
pixels in the Image by the print intentions .
<br>
if the user like to send the document to a professional printing
house then all images need to have a DPI of minimal 254, laser
printers need 150 DPI and on screen presentations 96 DPI
<br>
<br>
Tomaz has this implemented a feature called "Image Preferred
DPI" so the dimensions of an image in the document can been
checked/controled by the number of pixels in the image and the
print intentions off a document.
<br>
<br>
With a Preferred DPI of 254 and 2450 pixels in the image, the
image can be displayed at a maximum size of 10 inches. If the
image is smaller, then fewer than 2450 pixels are needed.
<br>
So the "Image Preferred DPI" can be used to determine the "Print
Intentions" for a Document, and it can easily calculate how many
DPI or pixels an image needs.
<br>
grtz
<br>
Fernand
<br>
<br>
</blockquote>
<br>
Sorry for disturbing again, but we're not experienced enough.
<br>
<br>
Following your instruction, we thought about getting the "Image
Preferred DPI" property and used it as aDPI when creating
bitmaps. That way, at least user could try to assign a large DPI
to get better resolution. However we failed to find out how to
get it. We know it is in File-Properties and we know it is set in
sfx2/source/dialog/dinfdlg.cxx,
<br>
<br>
xProps->setPropertyValue("ImagePreferredDPI",
uno::Any(nImagePreferredDPI));
<br>
<br>
But we couldn't find out how to get this "ImagePreferredDPI"
property value and use it in
vcl/source/gdi/vectorgraphicdata.cxx. A little more help here
please?
<br>
<br>
<br>
Dev
<br>
<br>
</blockquote>
</body>
</html>