Commit c33440a7 authored by Marcel Wiesweg's avatar Marcel Wiesweg Committed by Veaceslav Munteanu
Browse files

Small API change in Curves, return raw binary serialization, toBase64 can be...

Small API change in Curves, return raw binary serialization, toBase64 can be called in code using this.
Silence debug messages.
parent eb10fd00
......@@ -144,7 +144,7 @@ void CurvesContainer::writeToFilterAction(FilterAction& action, const QString& p
for (int i = 0; i < ColorChannels; ++i)
{
action.addParameter(prefix + QString("curveData[%1]").arg(i), curves.channelToBase64(i));
action.addParameter(prefix + QString("curveData[%1]").arg(i), curves.channelToBinary(i).toBase64());
}
}
......@@ -161,7 +161,7 @@ CurvesContainer CurvesContainer::fromFilterAction(const FilterAction& action, co
{
QByteArray base64 = action.parameter(prefix + QString("curveData[%1]").arg(i), QByteArray());
// check return value and set readParametersError?
curves.setChannelFromBase64(i, base64);
curves.setChannelFromBinary(i, QByteArray::fromBase64(base64));
}
// We don't need to call curves.curvesCalculateAllCurves() here ???
......
......@@ -181,20 +181,20 @@ ImageCurves& ImageCurves::operator=(const ImageCurves& other)
void ImageCurves::fillFromOtherCurves(ImageCurves* const otherCurves)
{
kDebug() << "Filling this curve from other curve " << otherCurves;
//kDebug() << "Filling this curve from other curve " << otherCurves;
curvesReset();
// if the other curves have the same bit depth, simply copy their data
if (isSixteenBits() == otherCurves->isSixteenBits())
{
kDebug() << "Both curves have same type: isSixteenBits = " << isSixteenBits();
//kDebug() << "Both curves have same type: isSixteenBits = " << isSixteenBits();
for (int channel = 0; channel < NUM_CHANNELS; ++channel)
{
if (otherCurves->getCurveType(channel) == CURVE_SMOOTH)
{
kDebug() << "Other is CURVE_SMOOTH";
//kDebug() << "Other is CURVE_SMOOTH";
setCurveType(channel, CURVE_SMOOTH);
for (int point = 0; point < NUM_POINTS; ++point)
......@@ -209,7 +209,7 @@ void ImageCurves::fillFromOtherCurves(ImageCurves* const otherCurves)
}
else
{
kDebug() << "Other is CURVE_FREE";
//kDebug() << "Other is CURVE_FREE";
setCurveType(channel, CURVE_FREE);
for (int i = 0 ; i <= d->segmentMax ; ++i)
......@@ -222,13 +222,13 @@ void ImageCurves::fillFromOtherCurves(ImageCurves* const otherCurves)
// other curve is 8 bit and this curve is 16 bit
else if (isSixteenBits() && !otherCurves->isSixteenBits())
{
kDebug() << "This curve is 16 bit and the other is 8 bit";
//kDebug() << "This curve is 16 bit and the other is 8 bit";
for (int channel = 0; channel < NUM_CHANNELS; ++channel)
{
if (otherCurves->getCurveType(channel) == CURVE_SMOOTH)
{
kDebug() << "Other is CURVE_SMOOTH";
//kDebug() << "Other is CURVE_SMOOTH";
setCurveType(channel, CURVE_SMOOTH);
for (int point = 0; point < NUM_POINTS; ++point)
......@@ -245,7 +245,7 @@ void ImageCurves::fillFromOtherCurves(ImageCurves* const otherCurves)
}
else
{
kDebug() << "Other is CURVE_FREE";
//kDebug() << "Other is CURVE_FREE";
setCurveType(channel, CURVE_FREE);
for (int i = 0 ; i <= d->segmentMax ; ++i)
......@@ -258,13 +258,13 @@ void ImageCurves::fillFromOtherCurves(ImageCurves* const otherCurves)
// other curve is 16 bit and this is 8 bit
else if (!isSixteenBits() && otherCurves->isSixteenBits())
{
kDebug() << "This curve is 8 bit and the other is 16 bit";
//kDebug() << "This curve is 8 bit and the other is 16 bit";
for (int channel = 0; channel < NUM_CHANNELS; ++channel)
{
if (otherCurves->getCurveType(channel) == CURVE_SMOOTH)
{
kDebug() << "Other is CURVE_SMOOTH";
//kDebug() << "Other is CURVE_SMOOTH";
setCurveType(channel, CURVE_SMOOTH);
//kDebug() << "Adopting points of channel " << channel;
......@@ -288,7 +288,7 @@ void ImageCurves::fillFromOtherCurves(ImageCurves* const otherCurves)
}
else
{
kDebug() << "Other is CURVE_FREE";
//kDebug() << "Other is CURVE_FREE";
setCurveType(channel, CURVE_FREE);
for (int i = 0 ; i <= d->segmentMax ; ++i)
......@@ -968,14 +968,14 @@ void ImageCurves::setCurveValue(int channel, int bin, int val)
void ImageCurves::setCurveValues(int channel, const QPolygon& vals)
{
kDebug() << "vals size: " << vals.size();
kDebug() << "segmentMax: " << d->segmentMax + 1;
//kDebug() << "vals size: " << vals.size();
//kDebug() << "segmentMax: " << d->segmentMax + 1;
if (d->curves && channel >= 0 && channel < NUM_CHANNELS)
{
if (vals.isEmpty())
{
kDebug() << "No curves values to assign: reset";
//kDebug() << "No curves values to assign: reset";
curvesChannelReset(channel);
}
// Bits depth are different ?
......@@ -985,7 +985,7 @@ void ImageCurves::setCurveValues(int channel, const QPolygon& vals)
if (vals.size() == 256)
{
kDebug() << "8 to 16 bits curves transform";
//kDebug() << "8 to 16 bits curves transform";
// 8 to 16 bits.
ImageCurves curve8(false);
......@@ -1007,7 +1007,7 @@ void ImageCurves::setCurveValues(int channel, const QPolygon& vals)
}
else
{
kDebug() << "16 to 8 bits curves transform";
//kDebug() << "16 to 8 bits curves transform";
// 16 to 8 bits.
ImageCurves curve8(false);
......@@ -1030,7 +1030,7 @@ void ImageCurves::setCurveValues(int channel, const QPolygon& vals)
}
else
{
kDebug() << "Assign curves values directly";
//kDebug() << "Assign curves values directly";
for (int j = 0 ; j <= d->segmentMax ; ++j)
{
......@@ -1353,7 +1353,7 @@ bool ImageCurves::isLinear(int channel) const
* Data then converted to base64.
*/
QByteArray ImageCurves::channelToBase64(int channel) const
QByteArray ImageCurves::channelToBinary(int channel) const
{
if (!d->curves || channel < 0 || channel >= NUM_CHANNELS)
{
......@@ -1432,29 +1432,23 @@ QByteArray ImageCurves::channelToBase64(int channel) const
}
}
return data.toBase64();
return data;
}
bool ImageCurves::setChannelFromBase64(int channel, const QByteArray& array)
bool ImageCurves::setChannelFromBinary(int channel, const QByteArray& data)
{
if (!d->curves || channel < 0 || channel >= NUM_CHANNELS)
{
return false;
}
if (array.isEmpty())
if (data.isEmpty())
{
curvesChannelReset(channel);
}
QByteArray decoded = QByteArray::fromBase64(array);
if (decoded.isEmpty())
{
return false;
}
QDataStream s(decoded);
QDataStream s(data);
quint32 nothing, count;
quint16 version;
......
......@@ -149,19 +149,19 @@ public:
bool isLinear() const;
/**
* Writes the given channel to a base64 representation.
* Writes the given channel to a raw binary representation.
* Note that 16bit free curves take a lot of memory (~85kB)
* while all other forms take less than 400 bytes.
*/
QByteArray channelToBase64(int channel) const;
QByteArray channelToBinary(int channel) const;
/**
* Set the channel from the given base64 representation.
* Set the channel from the given raw binary representation.
* The data is checked for validity, only on valid data true is returned.
* Note that the bytes depth (isSixteenBits()) of the encoded
* representation must match the depth of this curves object.
*/
bool setChannelFromBase64(int channel, const QByteArray& array);
bool setChannelFromBinary(int channel, const QByteArray& array);
/// Methods for to save/load the curves values to/from a Gimp curves text file.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment