Understand to relation between zoomImage and actualImage

本文介绍了一种使用GLSL实现图像缩放的方法,具体展示了如何通过绘制实际图像的小型预览,并用红色区域标示放大区域的位置。通过调整偏移量和缩放宽度等参数,可以灵活地控制显示效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



http://www.codeproject.com/Articles/236394/Bi-Cubic-and-Bi-Linear-Interpolation-with-GLSL


/* This function draws miniature of actual image with a Red region indicating the zoomed area. */
void CZoomInterpolationDlg::DrawActualImage()
{
    // Set Rendering area of Actual image.    glViewport(805, 10, 200, 150 );

    // Image is attached.    m_glTexture.Enable();

    // Entire image is mapped to screen.    m_glVertexBuffer.DrawVertexBuffer( GL_QUADS );
    m_glTexture.Disable();

    // Set Red color for Zoom area indication.    glColor3f(1.0, 0.0, 0.0 );

    float fXStart = m_fXOffset * 2;     
    float fYStart = m_fYOffset * 2;
    float fWidth = m_fZoomWidth * 2;
    float fHeight = m_fZoomHeight * 2;

    // Draw a rectangle indicate zoom area.    glBegin( GL_LINE_LOOP );


    glVertex2d( -1.0 + fXStart         ,  -1.0 + fYStart );
    glVertex2d( -1.0 + fXStart + fWidth,  -1.0 + fYStart );
    glVertex2d( -1.0 + fXStart + fWidth,  -1.0 + fYStart + fHeight );
    glVertex2d( -1.0 + fXStart         ,  -1.0 + fYStart + fHeight );
    glVertex2d( -1.0 + fXStart         ,  -1.0 + fYStart );
    glColor3f( 1.0,1.0, 1.0 );
    glEnd();
}


void CZoomInterpolationDlg::PrepareVertexBuffer()
{
    const float fXOffset = m_fXOffset;
    const float fYOffset = m_fYOffset;
    const float fWidth = m_fZoomWidth;
    const float fHeight = m_fZoomHeight;
    m_glVertexBufferZoom.SetAt( 0, -1.0f,1.0f, 0.0f,    fXOffset, fHeight + fYOffset ); // Left Top  corner
    m_glVertexBufferZoom.SetAt( 1, -1.0f,-1.0f, 0.0f,   fXOffset, fYOffset );// Left Bottom
    m_glVertexBufferZoom.SetAt( 2, 1.0f , -1.0f, 0.0f,  fXOffset + fWidth, fYOffset); // Right bottom
    m_glVertexBufferZoom.SetAt( 3, 1.0f, 1.0f,  0.0f,   fXOffset + fWidth, fHeight + fYOffset ); // Right top
}


    // 下图将说明这种对应关系


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值