Draw an image with the correct size using openGLContext.copyTexture

I want to draw image on my OpenGL component and stretch it to the size of the component so the width and height will be same as bounds of component. And I can’t understand the logic of the copyTexture method. My picture appears+/- 25 percent shorter or larger for some other images. Is this a bug or I do something wrong? My code below:

void MyComponent::render() {

const float desktopScale = (float) openGLContext.getRenderingScale();
glViewport(0, 0, desktopScale * getWidth(), desktopScale * getHeight());

OpenGLHelpers::clear(Colour::fromRGB(33, 33, 33));

Rectangle t (648, 988); // size of my PNG image
auto b = getBounds();
Rectangle bSize(b.getWidth(), b.getHeight());
openGLContext.copyTexture(t, bSize, b.getWidth(), b.getHeight(), false);


Thank you. Below you can see result of drawing. I added two same components.


Possibly your Image has non power of two dimensions? JUCE will automatically add a border to the texture so that its dimensions are powers of two for maximum hardware compatibility as not all GPUs support non power of two textures. You can disable that behavior through a macro afaik

Sorry not sure what you mean by the power of two dimensions? Red border this is the part of my image so that is ok. The problem just that this image does not fill all the black space.

Added: Do you mean my image should have size like - 128x64, 64x32, 32x16, 16x8, 8x4, 4x2, 2x1, and 1x1, etc? I’ll try that.