1
0
mirror of https://github.com/microsoft/DirectXTex synced 2024-11-08 14:00:05 +00:00
7 EvaluateImage
Chuck Walbourn edited this page 2022-01-20 17:41:58 -08:00
DirectXTex

Evaluates a user-supplied function across an image.

HRESULT EvaluateImage(const Image& image,
  std::function<
      void(const XMVECTOR* pixels, size_t width, size_t y)
  > pixelFunc );

HRESULT EvaluateImage(const Image* images, size_t nimages, const TexMetadata& metadata,
  std::function<
      void(const XMVECTOR* pixels, size_t width, size_t y)
  > pixelFunc );

Breaking change notice: In the September 2016 release this function was Evaluate but this generic name can cause conflicts in some client code so it was renamed EvaluateImage.

Parameters

pixelFunc: A callback function to invoke for each scanline of the image.

Example

This function computes the maximum luminance of an input.

XMVECTOR maxLum = XMVectorZero();
HRESULT hr = EvaluateImage(*image.GetImage(0, 0, 0),
    [&](const XMVECTOR* pixels, size_t width, size_t y)
    {
        UNREFERENCED_PARAMETER(y);
        for (size_t j = 0; j < width; ++j)
        {
            static const XMVECTORF32 s_luminance = { 0.3f, 0.59f, 0.11f, 0.f };

            XMVECTOR v = *pixels++;

            v = XMVector3Dot(v, s_luminance);

            maxLum = XMVectorMax(v, maxLum);
        }
    });
if (FAILED(hr))
    ...

Remarks

Image data is converted to DXGI_FORMAT_R32G32B32A32_FLOAT for this operation. BC data is automatically decompressed.

This function cannot operate directly on a planar format image. See ConvertToSinglePlane for a method for converting planar data to a format that is supported by this routine.