Re: #tdf51510: Change the DPI to get better resolution, but failed the unit test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

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:


           /* get Image Preferred DPI from File/Properties.  User can specify DPI they wanted
            * to exported. */
           SfxObjectShell* pDocSh = SfxObjectShell::Current();
           sal_Int32 nImagePreferredDPI = 0;
           if (pDocSh)
           {
                   try
                   {
                           uno::Reference< lang::XMultiServiceFactory > xFac( pDocSh->GetModel(), uno::
UNO_QUERY_THROW );
                           uno::Reference< beans::XPropertySet > xProps( xFac->createInstance("com.sun.
star.document.Settings"), uno::UNO_QUERY_THROW );
                           xProps->getPropertyValue("ImagePreferredDPI") >>= nImagePreferredDPI;
                   }
                   catch( uno::Exception& )
                   {
                   }
           }

then sent the nImagePreferredDPI to generate the bitmap.  It worked!  At least we can use designated DPI to get a better bitmap quality.

Then when we tried to patch it to latest libreoffice.core and compile it, it failed to link:

/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&)':
vectorgraphicdata.cxx:(.text+0x226d): undefined reference to `SfxObjectShell::Current()'
/usr/bin/ld: vectorgraphicdata.cxx:(.text+0x228f): undefined reference to `SfxObjectShell::GetModel() const'
collect2: error: ld returned 1 exit status
make[1]: *** [/home/lodev/git/libreoffice.core/vcl/Library_vcl.mk:20:/home/lodev/git/libreoffice.core/instdir/program/libvcllo.so] 錯誤 1

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.

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.  

Would anyone please give a little help and hints here?


Thanks, Dev


Lodev 於 2023/9/11 21:32 寫道:
Hi,

sos 於 2023/8/31 17:53 寫道:

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.

Apparent dimensions are a result of deviding the available pixels in the Image by the print intentions .
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

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.

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.
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.
grtz
Fernand


Sorry for disturbing again, but we're not experienced enough.

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,

                xProps->setPropertyValue("ImagePreferredDPI", uno::Any(nImagePreferredDPI));

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?


Dev


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux