summaryrefslogtreecommitdiffstats
path: root/tools/render-test/png-serialize-util.cpp
blob: 15aaba00b61f6151fc23a45894e46eff195d2385 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// png-serialize-util.cpp
#define _CRT_SECURE_NO_WARNINGS

#include "png-serialize-util.h"

#include <stdio.h>
#include <stdlib.h>

#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"

namespace renderer_test
{
using namespace Slang;

/* static */ Slang::Result PngSerializeUtil::write(
    const char* filename,
    ISlangBlob* pixels,
    uint32_t width,
    uint32_t height)
{
    int stbResult =
        stbi_write_png(filename, width, height, 4, pixels->getBufferPointer(), width * 4);

    return stbResult ? SLANG_OK : SLANG_FAIL;
}

} // namespace renderer_test