diff --git a/image.frag b/image.frag index 71b2eaf..e7fa6fa 100644 --- a/image.frag +++ b/image.frag @@ -6,9 +6,16 @@ uniform vec2 scale; uniform float a; uniform int stretch; +float asinh_(float x) +{ + return log(x + sqrt(x*x + 1.0f)); +} + void main(void) { vec4 color = texture2D(qt_Texture0, qt_TexCoord0); + color = color*scale.x + scale.y; + max(color, vec4(0.0f)); switch(stretch) { @@ -25,13 +32,15 @@ void main(void) break; case 4: { - float l = color.r*0.2126f + color.g*0.7152f + color.b*0.7152f; - color *= asinh(l / a) / asinh(1 / a); + //float l = color.r*0.2126f + color.g*0.7152f + color.b*0.0722f; + float l = (color.r+color.g+color.b)*0.33333f; + float k = asinh(l*a)/(l*asinh(a)); + color *= k; } break; } - color = color*scale.x + scale.y; + //color = color*scale.x + scale.y; //float color = pow(c, 0.4545); gl_FragColor = color; } diff --git a/imagescrollareagl.cpp b/imagescrollareagl.cpp index eebb6dd..65f7d67 100644 --- a/imagescrollareagl.cpp +++ b/imagescrollareagl.cpp @@ -113,6 +113,7 @@ void ImageWidget::setStrech(int stretch) void ImageWidget::setStretchParam(float param) { + qDebug() << param; m_param = param; update(); } @@ -127,11 +128,10 @@ void ImageWidget::setOffset(int dx, int dy) void ImageWidget::paintGL() { if(m_blockRepaint)return; - qDebug() << "PAINT"; + qDebug() << "PAINT" << m_param; float dx = m_dx; float dy = m_dy; - qDebug() << "dxy" << dx << dy; if(width() > m_image->width()*m_scale) dx = -width()*0.5f + m_image->width()*m_scale*0.5f; if(height() > m_image->height()*m_scale) @@ -281,7 +281,6 @@ void ImageScrollAreaGL::updateScrollbars(bool zoom) void ImageScrollAreaGL::resizeEvent(QResizeEvent *event) { QWidget::resizeEvent(event); - qDebug() << "resize" << m_imageWidget->size(); m_verticalScrollBar->setPageStep(m_imageWidget->height()); m_horizontalScrollBar->setPageStep(m_imageWidget->width()); updateScrollbars(); @@ -341,6 +340,5 @@ void ImageScrollAreaGL::oneToOne() void ImageScrollAreaGL::scrollEvent() { - qDebug() << m_horizontalScrollBar->value() << m_verticalScrollBar->value(); m_imageWidget->setOffset(m_horizontalScrollBar->value(), m_verticalScrollBar->value()); } diff --git a/stretchpanel.cpp b/stretchpanel.cpp index a049fec..6a83550 100644 --- a/stretchpanel.cpp +++ b/stretchpanel.cpp @@ -37,13 +37,14 @@ void StretchPanel::calculateParam() switch(m_stretchSelect->currentIndex()) { case 2: - param = val*10/UINT16_MAX; + param = val*100/UINT16_MAX; break; case 3: param = val; break; case 4: - param = 1.001-val/UINT16_MAX; + val += 100; + param = val/100.0f; break; default: return;