Coverage Report

Created: 2026-08-17 07:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openexr/src/lib/OpenEXR/ImfPreviewImage.cpp
Line
Count
Source
1
//
2
// SPDX-License-Identifier: BSD-3-Clause
3
// Copyright (c) Contributors to the OpenEXR Project.
4
//
5
6
//-----------------------------------------------------------------------------
7
//
8
//  class PreviewImage
9
//
10
//-----------------------------------------------------------------------------
11
12
#include "ImfPreviewImage.h"
13
#include "Iex.h"
14
#include "ImfCheckedArithmetic.h"
15
#include "ImfNamespace.h"
16
17
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
18
19
PreviewImage::PreviewImage (
20
    unsigned int width, unsigned int height, const PreviewRgba pixels[])
21
2.14k
{
22
2.14k
    _width  = width;
23
2.14k
    _height = height;
24
2.14k
    _pixels = new PreviewRgba[checkArraySize (
25
2.14k
        uiMult (_width, _height), sizeof (PreviewRgba))];
26
27
2.14k
    if (pixels)
28
1.07k
    {
29
240k
        for (unsigned int i = 0; i < _width * _height; ++i)
30
239k
            _pixels[i] = pixels[i];
31
1.07k
    }
32
1.07k
    else
33
1.07k
    {
34
1.07k
        for (unsigned int i = 0; i < _width * _height; ++i)
35
0
            _pixels[i] = PreviewRgba ();
36
1.07k
    }
37
2.14k
}
38
39
PreviewImage::PreviewImage (const PreviewImage& other)
40
1.07k
    : _width (other._width)
41
1.07k
    , _height (other._height)
42
1.07k
    , _pixels (new PreviewRgba[other._width * other._height])
43
1.07k
{
44
240k
    for (unsigned int i = 0; i < _width * _height; ++i)
45
239k
        _pixels[i] = other._pixels[i];
46
1.07k
}
47
48
PreviewImage::~PreviewImage ()
49
3.21k
{
50
3.21k
    delete[] _pixels;
51
3.21k
}
52
53
PreviewImage&
54
PreviewImage::operator= (const PreviewImage& other)
55
1.07k
{
56
1.07k
    if (this != &other)
57
1.07k
    {
58
1.07k
        delete[] _pixels;
59
60
1.07k
        _width  = other._width;
61
1.07k
        _height = other._height;
62
1.07k
        _pixels = new PreviewRgba[other._width * other._height];
63
64
240k
        for (unsigned int i = 0; i < _width * _height; ++i)
65
239k
            _pixels[i] = other._pixels[i];
66
1.07k
    }
67
68
1.07k
    return *this;
69
1.07k
}
70
71
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT