Skip to content

EvaluateImage

Chuck Walbourn edited this page Jan 21, 2022 · 7 revisions
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.

For Use

  • Universal Windows Platform apps
  • Windows desktop apps
  • Windows 11
  • Windows 10
  • Windows 8.1
  • Xbox One
  • Xbox Series X|S
  • Windows Subsystem for Linux

Architecture

  • x86
  • x64
  • ARM64

For Development

  • Visual Studio 2022
  • Visual Studio 2019 (16.11)
  • clang/LLVM v12 - v18
  • GCC 10.5, 11.4, 12.3
  • MinGW 12.2, 13.2
  • CMake 3.20

Related Projects

DirectXTex Rust bindings

DirectX Tool Kit for DirectX 11

DirectX Tool Kit for DirectX 12

DirectXMesh

DirectXMath

Tools

Test Suite

Content Exporter

DxCapsViewer

See also

DirectX Landing Page

Clone this wiki locally