Image size is not normal


#1

Now I'm learning JUCE GUI programming . I want to create a window, then a component in this window and a jpg file showing in this component.

So I write these codes.


MyComponent::MyComponent() : pic(ImageFileFormat::loadFrom(File("D:/GUItest/test.jpg"))),
                             f("simkai.ttf", 20, Font::plain)        //"f" is a Font, pic is an Image

{
    w=pic.getWidth();
    h=pic.getHeight();                   //w & h are integers
    return;
}
void MyComponent::paint(Graphics& g)
{
    // showing an image
    g.drawImage(pic, 0, 0, w, h, 0, 0, pic.getWidth(), pic.getHeight());

    // writing the size info on the window
    g.setFont(f);
    std::sprintf(text, "x=%d\ny=%d", getWidth(), getHeight());
    g.drawMultiLineText(text, 0, 20, 500);
    return;
}


And the window is the same size as the image.

But when the prog is running, I found the picture it showing is bigger than the actually size, especially when I comparing it with the same picture showing in windows' default photo viewer.

I can't upload images so I give the link ( Please copy and paste the link to the address bar and don't direct click this link ):

http://lggshare.free3v.net/ttttt.jpg

This shows the difference of the original size and the juce showing size. So how can I deal with it?

 


#2

It's because the system dpi scale factor is 1.25, so my image is bigger than nomal one.

I added "Desktop::getInstance().setGlobalScaleFactor(1.0);" and then everything is ok.