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