Coverage Report

Created: 2026-07-25 07:03

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
1.23k
{
22
1.23k
    _width  = width;
23
1.23k
    _height = height;
24
1.23k
    _pixels = new PreviewRgba[checkArraySize (
25
1.23k
        uiMult (_width, _height), sizeof (PreviewRgba))];
26
27
1.23k
    if (pixels)
28
617
    {
29
1.68k
        for (unsigned int i = 0; i < _width * _height; ++i)
30
1.07k
            _pixels[i] = pixels[i];
31
617
    }
32
617
    else
33
617
    {
34
617
        for (unsigned int i = 0; i < _width * _height; ++i)
35
0
            _pixels[i] = PreviewRgba ();
36
617
    }
37
1.23k
}
38
39
PreviewImage::PreviewImage (const PreviewImage& other)
40
617
    : _width (other._width)
41
617
    , _height (other._height)
42
617
    , _pixels (new PreviewRgba[other._width * other._height])
43
617
{
44
1.68k
    for (unsigned int i = 0; i < _width * _height; ++i)
45
1.07k
        _pixels[i] = other._pixels[i];
46
617
}
47
48
PreviewImage::~PreviewImage ()
49
1.85k
{
50
1.85k
    delete[] _pixels;
51
1.85k
}
52
53
PreviewImage&
54
PreviewImage::operator= (const PreviewImage& other)
55
617
{
56
617
    if (this != &other)
57
617
    {
58
617
        delete[] _pixels;
59
60
617
        _width  = other._width;
61
617
        _height = other._height;
62
617
        _pixels = new PreviewRgba[other._width * other._height];
63
64
1.68k
        for (unsigned int i = 0; i < _width * _height; ++i)
65
1.07k
            _pixels[i] = other._pixels[i];
66
617
    }
67
68
617
    return *this;
69
617
}
70
71
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT