[Digikam-devel] Re: extragear/graphics/digikam

Andi Clemens andi.clemens at gmx.net
Sat Nov 13 15:27:30 GMT 2010


Does not compile anymore...

Andi

On Saturday 13 November 2010 16:14:53 Gilles Caulier wrote:
> SVN commit 1196491 by cgilles:
> 
> use integer value to set radius of blur filter. Integer is nore universal
> to be shared between gaussian and CImg blur algorithm Marcel, this need a
> little adjust in GoSC2010 branche
> 
> 
>  M  +5 -5      imageplugins/enhance/blurtool.cpp
>  M  +26 -15    libs/dimg/filters/fx/blurfilter.cpp
>  M  +3 -3      libs/dimg/filters/fx/blurfilter.h
>  M  +8 -8      utilities/queuemanager/basetools/enhance/blur.cpp
>  M  +1 -1      utilities/queuemanager/basetools/enhance/blur.h
> 
> 
> --- trunk/extragear/graphics/digikam/imageplugins/enhance/blurtool.cpp
> #1196490:1196491 @@ -72,7 +72,7 @@
>      const QString       configGroupName;
>      const QString       configRadiusAdjustmentEntry;
> 
> -    RDoubleNumInput*    radiusInput;
> +    RIntNumInput*       radiusInput;
>      ImageRegionWidget*  previewWidget;
>      EditorToolSettings* gboxSettings;
>  };
> @@ -92,9 +92,9 @@
>      // --------------------------------------------------------
> 
>      QLabel* label  = new QLabel(i18n("Smoothness:"));
> -    d->radiusInput = new RDoubleNumInput();
> -    d->radiusInput->setRange(0.0, 120.0, 0.1);
> -    d->radiusInput->setDefaultValue(0.0);
> +    d->radiusInput = new RIntNumInput();
> +    d->radiusInput->setRange(0, 100, 1);
> +    d->radiusInput->setDefaultValue(0);
>      d->radiusInput->setWhatsThis(i18n("A smoothness of 0 has no effect, "
>                                        "1 and above determine the Gaussian
> blur matrix radius " "that determines how much to blur the image.")); @@
> -118,7 +118,7 @@
> 
>      // --------------------------------------------------------
> 
> -    connect(d->radiusInput, SIGNAL(valueChanged(double)),
> +    connect(d->radiusInput, SIGNAL(valueChanged(int)),
>              this, SLOT(slotTimer()));
> 
>      connect(d->previewWidget, SIGNAL(signalOriginalClipFocusChanged()),
> --- trunk/extragear/graphics/digikam/libs/dimg/filters/fx/blurfilter.cpp
> #1196490:1196491 @@ -42,7 +42,7 @@
>  namespace Digikam
>  {
> 
> -BlurFilter::BlurFilter(DImg* orgImage, QObject* parent, double radius)
> +BlurFilter::BlurFilter(DImg* orgImage, QObject* parent, int radius)
> 
>            : DImgThreadedFilter(orgImage, parent, "GaussianBlur")
> 
>  {
>      m_radius = radius;
> @@ -51,7 +51,7 @@
> 
>  BlurFilter::BlurFilter(DImgThreadedFilter* parentFilter,
>                         const DImg& orgImage, const DImg& destImage,
> -                       int progressBegin, int progressEnd, double radius)
> +                       int progressBegin, int progressEnd, int radius)
> 
>            : DImgThreadedFilter(parentFilter, orgImage, destImage,
>            : progressBegin, progressEnd,
> 
>                                 parentFilter->filterName() + ":
> GaussianBlur") {
> @@ -68,10 +68,10 @@
>  {
>  #if defined(__MACOSX__) || defined(__APPLE__)
>      gaussianBlurImage(m_orgImage.bits(), m_orgImage.width(),
> m_orgImage.height(), -                      m_orgImage.sixteenBit(),
> lround(m_radius*10.0)); +                      m_orgImage.sixteenBit(),
> m_radius);
>  #else
>      cimgBlurImage(m_orgImage.bits(), m_orgImage.width(),
> m_orgImage.height(), -                  m_orgImage.sixteenBit(),
> m_radius);
> +                  m_orgImage.sixteenBit(), m_radius/10;0);
>  #endif
>  }
> 
> @@ -87,9 +87,12 @@
>      if (radius <= 0.0)
>      {
>         m_destImage = m_orgImage;
> +       postProgress(100);
>         return;
>      }
> 
> +    kDebug() << "Radius: " << radius;
> +
>      kDebug() << "BlurFilter::Process Computation...";
> 
>      if (!sixteenBit)           // 8 bits image.
> @@ -97,9 +100,11 @@
>          // convert DImg (interleaved RGBA) to CImg (planar RGBA)
>          CImg<uchar> img = CImg<uchar>(data, 4, width, height, 1, true).
>                            get_permute_axes("yzvx");
> +        postProgress(25);
> 
>          // blur the image
>          img.blur(radius);
> +        postProgress(50);
> 
>          // Copy CImg onto destination.
>          kDebug() << "BlurFilter::Finalization...";
> @@ -117,15 +122,18 @@
>                  ptr    += 4;
>              }
>          }
> +        postProgress(75);
>      }
>      else                                // 16 bits image.
>      {
>          // convert DImg (interleaved RGBA) to CImg (planar RGBA)
>          CImg<unsigned short> img = CImg<unsigned short>((unsigned
> short*)data, 4, width, height, 1, true). get_permute_axes("yzvx");
> +        postProgress(25);
> 
>          // blur the image
>          img.blur(radius);
> +        postProgress(50);
> 
>          // Copy CImg onto destination.
>          kDebug() << "BlurFilter::Finalization...";
> @@ -143,7 +151,10 @@
>                  ptr    += 4;
>              }
>          }
> +        postProgress(75);
>      }
> +
> +    postProgress(100);
>  }
> 
>  void BlurFilter::gaussianBlurImage(uchar* data, int width, int height,
> bool sixteenBit, int radius) @@ -178,7 +189,7 @@
>      factor   = exp (lnfactor);
>      sd       = exp (lnsd);
> 
> -    for (i = 0; !runningFlag() && (i < nKSize); ++i)
> +    for (i = 0; runningFlag() && (i < nKSize); ++i)
>      {
>          x = sqrt ((i - nCenter) * (i - nCenter));
>          Kernel[i] = (int)(factor * exp (-0.5 * pow ((x / sd), 2)) / (sd *
> sqrt (2.0 * M_PI))); @@ -197,8 +208,8 @@
> 
>      int** arrMult = Alloc2DArray (nKernelWidth, sixteenBit ? 65536 : 256);
> 
> -    for (i = 0; !runningFlag() && (i < nKernelWidth); ++i)
> -        for (j = 0; !runningFlag() && (j < (sixteenBit ? 65536 : 256));
> ++j) +    for (i = 0; runningFlag() && (i < nKernelWidth); ++i)
> +        for (j = 0; runningFlag() && (j < (sixteenBit ? 65536 : 256));
> ++j) arrMult[i][j] = j * Kernel[i];
> 
>          // We need to copy our bits to blur bits
> @@ -217,9 +228,9 @@
> 
>      // Now, we enter in the main loop
> 
> -    for (h = 0; !runningFlag() && (h < height); ++h)
> +    for (h = 0; runningFlag() && (h < height); ++h)
>      {
> -        for (w = 0; !runningFlag() && (w < width); ++w, i+=4)
> +        for (w = 0; runningFlag() && (w < width); ++w, i+=4)
>          {
>              if (!sixteenBit)        // 8 bits image.
>              {
> @@ -227,7 +238,7 @@
> 
>                  // first of all, we need to blur the horizontal lines
> 
> -                for (n = -radius; !runningFlag() && (n <= radius); ++n)
> +                for (n = -radius; runningFlag() && (n <= radius); ++n)
>                  {
>                      // if is inside...
>                      if (IsInside (width, height, w + n, h))
> @@ -266,7 +277,7 @@
> 
>                  // first of all, we need to blur the horizontal lines
> 
> -                for (n = -radius; !runningFlag() && (n <= radius); ++n)
> +                for (n = -radius; runningFlag() && (n <= radius); ++n)
>                  {
>                      // if is inside...
>                      if (IsInside (width, height, w + n, h))
> @@ -310,16 +321,16 @@
>      i = j = 0;
> 
>      // We enter in the second main loop
> -    for (w = 0; !runningFlag() && (w < width); ++w, i = w*4)
> +    for (w = 0; runningFlag() && (w < width); ++w, i = w*4)
>      {
> -        for (h = 0; !runningFlag() && (h < height); ++h, i += width*4)
> +        for (h = 0; runningFlag() && (h < height); ++h, i += width*4)
>          {
>              if (!sixteenBit)        // 8 bits image.
>              {
>                  uchar *org, *dst;
> 
>                  // first of all, we need to blur the vertical lines
> -                for (n = -radius; !runningFlag() && (n <= radius); ++n)
> +                for (n = -radius; runningFlag() && (n <= radius); ++n)
>                  {
>                      // if is inside...
>                      if (IsInside(width, height, w, h + n))
> @@ -359,7 +370,7 @@
>                  unsigned short *org, *dst;
> 
>                  // first of all, we need to blur the vertical lines
> -                for (n = -radius; !runningFlag() && (n <= radius); ++n)
> +                for (n = -radius; runningFlag() && (n <= radius); ++n)
>                  {
>                      // if is inside...
>                      if (IsInside(width, height, w, h + n))
> --- trunk/extragear/graphics/digikam/libs/dimg/filters/fx/blurfilter.h
> #1196490:1196491 @@ -39,11 +39,11 @@
> 
>  public:
> 
> -    explicit BlurFilter(DImg* orgImage, QObject* parent=0, double
> radius=3.0); +    explicit BlurFilter(DImg* orgImage, QObject* parent=0,
> int radius=3);
> 
>      // Constructor for slave mode: execute immediately in current thread
> with specified master filter explicit BlurFilter(DImgThreadedFilter*
> parentFilter, const DImg& orgImage, const DImg& destImage, -              
>          int progressBegin=0, int progressEnd=100, double radius=3.0); +  
>                      int progressBegin=0, int progressEnd=100, int
> radius=3);
> 
>      ~BlurFilter();
> 
> @@ -88,7 +88,7 @@
> 
>  private:
> 
> -    double m_radius;
> +    int m_radius;
>  };
> 
>  }  // namespace Digikam
> ---
> trunk/extragear/graphics/digikam/utilities/queuemanager/basetools/enhance/
> blur.cpp #1196490:1196491 @@ -52,9 +52,9 @@
> 
>      QWidget* box  = new QWidget;
>      QLabel* label = new QLabel(i18n("Smoothness:"));
> -    m_radiusInput = new RDoubleNumInput();
> -    m_radiusInput->setRange(0.0, 120.0, 0.1);
> -    m_radiusInput->setDefaultValue(0.0);
> +    m_radiusInput = new RIntNumInput();
> +    m_radiusInput->setRange(0, 100, 1);
> +    m_radiusInput->setDefaultValue(0);
>      m_radiusInput->setWhatsThis(i18n("A smoothness of 0 has no effect, "
>                                       "1 and above determine the Gaussian
> blur matrix radius " "that determines how much to blur the image.")); @@
> -68,7 +68,7 @@
> 
>      setSettingsWidget(box);
> 
> -    connect(m_radiusInput, SIGNAL(valueChanged(double)),
> +    connect(m_radiusInput, SIGNAL(valueChanged(int)),
>              this, SLOT(slotSettingsChanged()));
>  }
> 
> @@ -80,21 +80,21 @@
>  {
>      BatchToolSettings settings;
> 
> -    settings.insert("Radius", (double)m_radiusInput->defaultValue());
> +    settings.insert("Radius", (int)m_radiusInput->defaultValue());
> 
>      return settings;
>  }
> 
>  void Blur::slotAssignSettings2Widget()
>  {
> -    m_radiusInput->setValue(settings()["Radius"].toDouble());
> +    m_radiusInput->setValue(settings()["Radius"].toInt());
>  }
> 
>  void Blur::slotSettingsChanged()
>  {
>      BatchToolSettings settings;
> 
> -    settings.insert("Radius", (double)m_radiusInput->value());
> +    settings.insert("Radius", (int)m_radiusInput->value());
> 
>      BatchTool::slotSettingsChanged(settings);
>  }
> @@ -104,7 +104,7 @@
>      if (!loadToDImg())
>          return false;
> 
> -    double radius = settings()["Radius"].toDouble();
> +    double radius = settings()["Radius"].toInt();
> 
>      BlurFilter blur(&image(), 0L, radius);
>      blur.startFilterDirectly();
> ---
> trunk/extragear/graphics/digikam/utilities/queuemanager/basetools/enhance/
> blur.h #1196490:1196491 @@ -57,7 +57,7 @@
> 
>  private:
> 
> -    RDoubleNumInput* m_radiusInput;
> +    RIntNumInput* m_radiusInput;
>  };
> 
>  } // namespace Digikam



More information about the Digikam-devel mailing list