Skip to content

Linear filtering when scaling QNanoImages from fbos #55

Description

@daljit97

I am trying to use QNanoImage to perform some zooming operations on a QOpenGLFramebufferObject. I can see that when I load an image from a file and scale the image (using painter->scale), linear filtering is used by default and the image is scaled "smoothly" (similar to the QML standard smooth: true). Now when I try to do the same thing using an fbo, it seems that nearest filtering is always used: the image appears pixelated. The code I am using is the following:

            QNanoImage cacheImage = QNanoImage::fromFrameBuffer(m_cacheBuffer.get(),
                                                                QNanoImage::FLIPY |
                                                                QNanoImage::GENERATE_MIPMAPS);
            painter->scale(m_contentScale);
            painter->drawImage(cacheImage,0,0);

So I decided to blit the fbo directly using:

            QOpenGLFramebufferObject::blitFramebuffer(fbo,QRect(0,0,1000,1000),
                                                      m_cacheBuffer.get(), QRect(0,0,width()/m_contentScale, height()/m_contentScale),
                                                      GL_COLOR_BUFFER_BIT,
                                                      GL_LINEAR);

which actually uses linear filtering and the image appears "smoothly" scaled (it works only if I explicity set GL_COLOR_BUFFER_BIT as the GLbitfield). I don't have too much experience with OpenGL, so I am not sure why would that be the case. Could this be due to format that my fbo is created with?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions