Support really big images 50000px
This commit is contained in:
+19
-19
@@ -190,10 +190,10 @@ void ImageWidgetGL::zoom(int zoom, const QPointF &mousePos)
|
||||
if(!mousePos.isNull())
|
||||
focus = mousePos;
|
||||
|
||||
if(width() > m_image->width() * m_scale)
|
||||
m_dx = -width() * 0.5f + m_image->width() * m_scale * 0.5f;
|
||||
if(height() > m_image->height() * m_scale)
|
||||
m_dy = -height() * 0.5f + m_image->height() * m_scale * 0.5f;
|
||||
if(width() > m_imgWidth * m_scale)
|
||||
m_dx = -width() * 0.5f + m_imgWidth * m_scale * 0.5f;
|
||||
if(height() > m_imgHeight * m_scale)
|
||||
m_dy = -height() * 0.5f + m_imgHeight * m_scale * 0.5f;
|
||||
|
||||
float newScale = std::sqrt(std::pow(2.0f, (float)m_scaleStop));
|
||||
float r = newScale / m_scale;
|
||||
@@ -237,10 +237,10 @@ QVector2D ImageWidgetGL::getImagePixelCoord(const QVector2D &pos)
|
||||
{
|
||||
float dx = m_dx;
|
||||
float dy = m_dy;
|
||||
if(m_width > m_image->width()*m_scale)
|
||||
dx = -width()*0.5f + m_image->width()*m_scale*0.5f;
|
||||
if(m_height > m_image->height()*m_scale)
|
||||
dy = -height()*0.5f + m_image->height()*m_scale*0.5f;
|
||||
if(m_width > m_imgWidth * m_scale)
|
||||
dx = -width()*0.5f + m_imgWidth*m_scale * 0.5f;
|
||||
if(m_height > m_imgHeight * m_scale)
|
||||
dy = -height()*0.5f + m_imgHeight*m_scale * 0.5f;
|
||||
|
||||
QVector2D offset(dx, dy);
|
||||
return (pos + offset) / m_scale;
|
||||
@@ -353,8 +353,8 @@ void swPaint(std::shared_ptr<RawImage> &rawImage, float dx, float dy, float scal
|
||||
int height = widget->height();
|
||||
QImage img(width, height, QImage::Format_RGB32);
|
||||
img.fill(Qt::gray);
|
||||
int ox = dx;
|
||||
int oy = dy;
|
||||
int64_t ox = dx;
|
||||
int64_t oy = dy;
|
||||
|
||||
auto mtf = [&mtfParams](int i, float x)
|
||||
{
|
||||
@@ -376,18 +376,18 @@ void swPaint(std::shared_ptr<RawImage> &rawImage, float dx, float dy, float scal
|
||||
float r[4];
|
||||
float g[4];
|
||||
float b[4];
|
||||
for(int y = std::max(0, -oy); y < height; y++)
|
||||
for(int64_t y = std::max((int64_t)0, -oy); y < height; y++)
|
||||
{
|
||||
uint32_t *pixels = (uint32_t*)(img.scanLine(y));
|
||||
float iptr;
|
||||
float fy = std::modf((y + oy) * iscale - 0.5f, &iptr);
|
||||
int py = iptr;
|
||||
uint32_t w = py * rawImage->widthBytes();
|
||||
uint32_t w2 = w;
|
||||
int64_t py = iptr;
|
||||
int64_t w = py * rawImage->widthBytes();
|
||||
int64_t w2 = w;
|
||||
if(py+1 < imgHeight)w2 += rawImage->widthBytes();
|
||||
if(py >= imgHeight)break;
|
||||
|
||||
for(int x = std::max(0, -ox); x < width; x++)
|
||||
for(int64_t x = std::max((int64_t)0, -ox); x < width; x++)
|
||||
{
|
||||
float fx = std::modf((x + ox) * iscale - 0.5f, &iptr);
|
||||
int px = iptr;
|
||||
@@ -467,10 +467,10 @@ void ImageWidgetGL::paintGL()
|
||||
{
|
||||
float dx = m_dx;
|
||||
float dy = m_dy;
|
||||
if(m_width > m_image->width() * m_scale)
|
||||
dx = -width() * 0.5f + m_image->width() * m_scale * 0.5f;
|
||||
if(m_height > m_image->height() * m_scale)
|
||||
dy = -height() * 0.5f + m_image->height() * m_scale * 0.5f;
|
||||
if(m_width > m_imgWidth * m_scale)
|
||||
dx = -width() * 0.5f + m_imgWidth * m_scale * 0.5f;
|
||||
if(m_height > m_imgHeight * m_scale)
|
||||
dy = -height() * 0.5f + m_imgHeight * m_scale * 0.5f;
|
||||
QBrush highlight = style()->standardPalette().highlight();
|
||||
|
||||
f->glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
Reference in New Issue
Block a user