Problem with High DPI scaling

@patjep,

No, it just behaves differently in QT GUI. Anyways, we will further evaluate and update you with more details on it.

@Amjad_Sahi ,

Great, I’m looking forward to your updates on this issue.

@patjep,

We give you a simple demo which has nothing to do with Aspose.Cells to explain the different behavior using GDIPlus in QT.

#include <QtWidgets/qapplication.h>
#include
#include <comdef.h>
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment(lib, “gdiplus.lib”)
using namespace std;
//#include “Aspose.Cells.h”
//using namespace Aspose::Cells;
int main(int args, char** argv) {
QApplication app(args, argv);
ULONG_PTR gdiplusToken;
GdiplusStartupInput gdiplusStartupInput;
GdiplusStartup(&gdiplusToken,&gdiplusStartupInput,NULL);
Bitmap mBitMap(506, 283);
Graphics* mGr = Graphics::FromImage(&mBitMap);
mGr->SetPageUnit(Gdiplus::Unit::UnitPixel);
mGr->SetPageScale(1.0f);
Gdiplus::Font font((L"Aharoni"), 14.0f, (Gdiplus::Unit)1);
StringFormat* stringFormat = new StringFormat();
stringFormat->SetAlignment(StringAlignmentCenter);
stringFormat->SetLineAlignment(StringAlignmentCenter);
RectF rect(0, 0, 409.05f, 141.0f);
RectF boundingBox;
INT codepointsFitted = 0;
INT linesFilled = 0;
/*
Note :When you remove “QApplication app(args, argv);”, boundingBox will show different values,please debug and check.
*/
Gdiplus::Status status = mGr->MeasureString((L"Chart Title"), 7 , &font, rect, stringFormat,&boundingBox,&codepointsFitted,&linesFilled);
delete stringFormat;
GdiplusShutdown(gdiplusToken);
return 0;
}

Since Aspose.Cells also uses GDIPlus and functions such as “MeasureString” as above, so when you use it in QT GUI framework the result is different (for example for “SetDPI”). We do not think it is a bug for QT or Aspose.Cells. We suspect one probable reason is that some settings (or you need to add some new settings) in QT that might cause this, so you have to evaluate it by yourselves.

@Amjad_Sahi ,

Something must be wrong here. Qt5 is a GUI library, thus it creates a manages device contexts (CreateDC) which represents the screen. Your example of the issue seems to point out that the
issue at hand is that Aspose.Cells use the very same device (presumabley “DISPLAY”), correct?
It seems weird to me that Aspose.Cells would use the context of the screen to render its content
when it could create a device of it’s own that wouldn’t interfere with the GUI.

I think you should consider fixing this issue/bug since it effectively blocks GUI applications
on Windows from scaling their own content on High DPI screens. If you aim to support GUI applications this must be fixed as High DPI screens are pretty much standard these days.

@patjep,
We have noted your response and will share our feedback after detailed analysis.

@Amjad_Sahi @ahsaniqbalsidiqui

Just want to check on the status. Will you have a fix for me
some time soon?

@patjep,

I am afraid, there is no update available yet. Once we have any new information to share, we will update you.

@patjep,
We have created a topic in froum.qt.io. The support in QT gave a suggestion. If the suggestion still can not solve your problem, maybe you can follow up on that topic.

@ahsaniqbalsidiqui

Can you elaborate how this is supposed to help me? I’m not trying to
mix GDI Plus and Qt directly, it’s done by invoking Aspose.Cells.
I’m not trying to draw anything related to Aspose.Cells on the
screen either.

@patjep,
We have noted your response and will provide our feedback soon.

@patjep,
Although your code does not draw anything, but we think the page in stackoverflow shows that
If you want to use GDIplus(Aspose.cells use gdiplus) in QT you have to add extra code on QT side.
We are not well familiar with QT GUI module, so we are afraid we cannot give you further advice.

@ahsaniqbalsidiqui

I am by no means convinced that this issue is actually related to Qt itself. Either way,
let’s view this issue from another angle. You cannot tell me what needs to be done to
allow Qt to draw using GDI+, that’s fine. Can you instead tell me which features/functions
in GDI+ that Aspose.Cells depends on which could case this issue?

Maybe I’ll be able to workaround the limitations in Aspose.Cells if I can get some pointers on
where to look.

@patjep,

We will get back to you to provide the details.

@Amjad_Sahi

Are you close to providing me with this information? This is a serious issue for
us and we’ve already been forced to move the release date of the next version
of our product. Please provide me with an update ASAP.

@patjep,

Sorry for the delay.

Our concerned developer was on holidays for their Chinese New Year. Hopefully he will be back in the next couple of days. We will gather the information and share it with you soon.

@patjep,

Please note, there are several GDI+ functions that Aspose.Cells depends upon and which may cause the issue. But the most important is Gdiplus::DllExports::GdipMeasureString which is called by MeasureString in the demo before.

@Amjad_Sahi

Thank you for the information. I’ll see if I can do something with this piece
of knowledge.