Understand to relation between zoomImage and actualImage



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
}


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

Understand to relation between zoomImage and actualImage_第1张图片



你可能感兴趣的:(Understand to relation between zoomImage and actualImage)