| | 95 | void CSurface::ClampToEdge() |
| | 96 | { |
| | 97 | // fix up the last row and column to simulate clamp_to_edge |
| | 98 | if (!m_info.width || !m_info.height == 0) |
| | 99 | return; // invalid texture |
| | 100 | CSurfaceRect rect; |
| | 101 | if (Lock(&rect)) |
| | 102 | { |
| | 103 | for (unsigned int y = 0; y < m_info.height; y++) |
| | 104 | { |
| | 105 | BYTE *src = rect.pBits + y * rect.Pitch; |
| | 106 | for (unsigned int x = m_info.width; x < m_width; x++) |
| | 107 | memcpy(src + x*m_bpp, src + (m_info.width - 1)*m_bpp, m_bpp); |
| | 108 | } |
| | 109 | BYTE *src = rect.pBits + (m_info.height - 1) * rect.Pitch; |
| | 110 | for (unsigned int y = m_info.height; y < m_height; y++) |
| | 111 | { |
| | 112 | BYTE *dest = rect.pBits + y * rect.Pitch; |
| | 113 | memcpy(dest, src, rect.Pitch); |
| | 114 | } |
| | 115 | Unlock(); |
| | 116 | } |
| | 117 | } |
| | 118 | |