<commit_before>/*
  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization
  dedicated to making software imaging solutions freely available.

  You may not use this file except in compliance with the License.
  obtain a copy of the License at

    http://www.imagemagick.org/script/license.php

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

  MagickCore image composite private methods.
*/
#ifndef _MAGICKCORE_COMPOSITE_PRIVATE_H
#define _MAGICKCORE_COMPOSITE_PRIVATE_H

#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif

/*
  ImageMagick Alpha Composite Inline Methods (special export)
*/

#include "magick/color.h"
#include "magick/image.h"
#include "magick/image-private.h"

static inline MagickRealType RoundToUnity(const MagickRealType value)
{
  return(value < 0.0 ? 0.0 : (value > 1.0) ? 1.0 : value);
}

static inline MagickRealType MagickOver_(const MagickRealType p,
  const MagickRealType alpha,const MagickRealType q,const MagickRealType beta)
{
  return((1.0-QuantumScale*alpha)*p+(1.0-QuantumScale*beta)*q*
    QuantumScale*alpha);
}

static inline void MagickCompositeOver(const PixelPacket *p,
  const MagickRealType alpha,const PixelPacket *q,const MagickRealType beta,
  PixelPacket *composite)
{
  MagickRealType
    gamma;

  /*
    Compose pixel p over pixel q with the given opacities.
  */
  if (alpha == TransparentOpacity)
    {
      if (composite != q)
        *composite=(*q);
      return;
    }
  gamma=1.0-QuantumScale*QuantumScale*alpha*beta;
#if !defined(MAGICKCORE_HDRI_SUPPORT)
  composite->opacity=(Quantum) (QuantumRange*(1.0-gamma)+0.5);
  gamma=1.0/(gamma <= MagickEpsilon ? 1.0 : gamma);
  SetRedPixelComponent(composite,gamma*MagickOver_((MagickRealType)
    GetRedPixelComponent(p),alpha,(MagickRealType)
    GetRedPixelComponent(q),beta)+0.5);
  SetGreenPixelComponent(composite,gamma*MagickOver_((MagickRealType)
    GetGreenPixelComponent(p),alpha,(MagickRealType)
    GetGreenPixelComponent(q),beta)+0.5);
  SetBluePixelComponent(composite,gamma*MagickOver_((MagickRealType)
    GetBluePixelComponent(p),alpha,(MagickRealType)
    GetBluePixelComponent(q),beta)+0.5);
#else
  SetOpacityPixelCompoment(composite,QuantumRange*(1.0-gamma));
  gamma=1.0/(gamma <= MagickEpsilon ? 1.0 : gamma);
  SetRedPixelComponent(composite,gamma*MagickOver_((MagickRealType)
    GetRedPixelComponent(p),alpha,(MagickRealType)
    GetRedPixelComponent(q),beta));
  SetGreenPixelComponent(composite,gamma*MagickOver_((MagickRealType)
    GetGreenPixelComponent(p),alpha,(MagickRealType)
    GetGreenPixelComponent(q),beta));
  SetBluePixelComponent(composite,gamma*MagickOver_((MagickRealType)
    GetBluePixelComponent(p),alpha,(MagickRealType)
    GetBluePixelComponent(q),beta));
#endif
}

static inline void MagickPixelCompositeOver(const MagickPixelPacket *p,
  const MagickRealType alpha,const MagickPixelPacket *q,
  const MagickRealType beta,MagickPixelPacket *composite)
{
  MagickRealType
    gamma;
<commit_msg>misspelled SetOpacityPixelComponent in hdri branch of composite-private.h<commit_after>/*
  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization
  dedicated to making software imaging solutions freely available.

  You may not use this file except in compliance with the License.
  obtain a copy of the License at

    http://www.imagemagick.org/script/license.php

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

  MagickCore image composite private methods.
*/
#ifndef _MAGICKCORE_COMPOSITE_PRIVATE_H
#define _MAGICKCORE_COMPOSITE_PRIVATE_H

#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif

/*
  ImageMagick Alpha Composite Inline Methods (special export)
*/

#include "magick/color.h"
#include "magick/image.h"
#include "magick/image-private.h"

static inline MagickRealType RoundToUnity(const MagickRealType value)
{
  return(value < 0.0 ? 0.0 : (value > 1.0) ? 1.0 : value);
}

static inline MagickRealType MagickOver_(const MagickRealType p,
  const MagickRealType alpha,const MagickRealType q,const MagickRealType beta)
{
  return((1.0-QuantumScale*alpha)*p+(1.0-QuantumScale*beta)*q*
    QuantumScale*alpha);
}

static inline void MagickCompositeOver(const PixelPacket *p,
  const MagickRealType alpha,const PixelPacket *q,const MagickRealType beta,
  PixelPacket *composite)
{
  MagickRealType
    gamma;

  /*
    Compose pixel p over pixel q with the given opacities.
  */
  if (alpha == TransparentOpacity)
    {
      if (composite != q)
        *composite=(*q);
      return;
    }
  gamma=1.0-QuantumScale*QuantumScale*alpha*beta;
#if !defined(MAGICKCORE_HDRI_SUPPORT)
  composite->opacity=(Quantum) (QuantumRange*(1.0-gamma)+0.5);
  gamma=1.0/(gamma <= MagickEpsilon ? 1.0 : gamma);
  SetRedPixelComponent(composite,gamma*MagickOver_((MagickRealType)
    GetRedPixelComponent(p),alpha,(MagickRealType)
    GetRedPixelComponent(q),beta)+0.5);
  SetGreenPixelComponent(composite,gamma*MagickOver_((MagickRealType)
    GetGreenPixelComponent(p),alpha,(MagickRealType)
    GetGreenPixelComponent(q),beta)+0.5);
  SetBluePixelComponent(composite,gamma*MagickOver_((MagickRealType)
    GetBluePixelComponent(p),alpha,(MagickRealType)
    GetBluePixelComponent(q),beta)+0.5);
#else
  SetOpacityPixelComponent(composite,QuantumRange*(1.0-gamma));
  gamma=1.0/(gamma <= MagickEpsilon ? 1.0 : gamma);
  SetRedPixelComponent(composite,gamma*MagickOver_((MagickRealType)
    GetRedPixelComponent(p),alpha,(MagickRealType)
    GetRedPixelComponent(q),beta));
  SetGreenPixelComponent(composite,gamma*MagickOver_((MagickRealType)
    GetGreenPixelComponent(p),alpha,(MagickRealType)
    GetGreenPixelComponent(q),beta));
  SetBluePixelComponent(composite,gamma*MagickOver_((MagickRealType)
    GetBluePixelComponent(p),alpha,(MagickRealType)
    GetBluePixelComponent(q),beta));
#endif
}

static inline void MagickPixelCompositeOver(const MagickPixelPacket *p,
  const MagickRealType alpha,const MagickPixelPacket *q,
  const MagickRealType beta,MagickPixelPacket *composite)
{
  MagickRealType
    gamma;

{'fraction_non_alphanumeric': 0.09926918392204628, 'fraction_numerical': 0.012789281364190013, 'mean_word_length': 5.709908069458631, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4907921', 'n_tokens_mistral': 2138, 'n_tokens_neox': 2066, 'n_words': 458}