Grok 20.3.2
GrkImageMeta.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016-2026 Grok Image Compression Inc.
3 *
4 * This source code is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License, version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This source code is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Affero General Public License for more details.
12 *
13 * You should have received a copy of the GNU Affero General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#pragma once
19
20namespace grk
21{
22
24{
25public:
27 {
28 obj.wrapper = new GrkObjectWrapperImpl(this);
29 iptc_buf = nullptr;
30 iptc_len = 0;
31 xmp_buf = nullptr;
32 xmp_len = 0;
33 exif_buf = nullptr;
34 exif_len = 0;
35 geotiff_buf = nullptr;
36 geotiff_len = 0;
37 ipr_data = nullptr;
38 ipr_len = 0;
39 xml_buf = nullptr;
40 xml_len = 0;
41 asoc_boxes = nullptr;
43 color = {};
44 }
45
46 virtual ~GrkImageMeta()
47 {
49 delete[] iptc_buf;
50 delete[] xmp_buf;
51 delete[] exif_buf;
52 delete[] geotiff_buf;
53 delete[] ipr_data;
54 delete[] xml_buf;
55 if(asoc_boxes)
56 {
57 for(uint32_t i = 0; i < num_asoc_boxes; ++i)
58 {
59 free((void*)asoc_boxes[i].label);
60 free(asoc_boxes[i].xml);
61 }
62 free(asoc_boxes);
63 }
64 }
65 void allocPalette(uint8_t num_channels, uint16_t num_entries)
66 {
67 assert(num_channels);
68 assert(num_entries);
69
70 if(!num_channels || !num_entries)
71 return;
72
74 auto jp2_pclr = new grk_palette_data();
75 jp2_pclr->channel_sign = new bool[num_channels];
76 jp2_pclr->channel_prec = new uint8_t[num_channels];
77 jp2_pclr->lut = new int32_t[num_channels * num_entries];
78 jp2_pclr->num_entries = num_entries;
79 jp2_pclr->num_channels = num_channels;
80 jp2_pclr->component_mapping = nullptr;
81 color.palette = jp2_pclr;
82 }
84 {
85 if(color.palette)
86 {
87 delete[] color.palette->channel_sign;
88 delete[] color.palette->channel_prec;
89 delete[] color.palette->lut;
90 delete[] color.palette->component_mapping;
91 delete color.palette;
92 color.palette = nullptr;
93 }
94 }
96 {
98 delete[] color.icc_profile_buf;
99 color.icc_profile_buf = nullptr;
100 color.icc_profile_len = 0;
101 delete[] color.icc_profile_name;
102 color.icc_profile_name = nullptr;
103 if(color.channel_definition)
104 {
105 delete[] color.channel_definition->descriptions;
106 delete color.channel_definition;
107 color.channel_definition = nullptr;
108 }
109 }
110};
111
112} // namespace grk
virtual ~GrkImageMeta()
Definition GrkImageMeta.h:46
void allocPalette(uint8_t num_channels, uint16_t num_entries)
Definition GrkImageMeta.h:65
void releaseColor()
Definition GrkImageMeta.h:95
GrkImageMeta()
Definition GrkImageMeta.h:26
void releaseColorPalatte()
Definition GrkImageMeta.h:83
Definition GrkObjectWrapper.h:31
struct _grk_image_meta grk_image_meta
struct _grk_palette_data grk_palette_data
ResWindow.
Definition CompressedChunkCache.h:36
grk_color color
Definition grok.h:820
uint32_t num_asoc_boxes
Definition grok.h:834
size_t xml_len
Definition grok.h:832
uint8_t * xmp_buf
Definition grok.h:823
grk_object obj
Definition grok.h:819
uint8_t * geotiff_buf
Definition grok.h:827
size_t xmp_len
Definition grok.h:824
uint8_t * ipr_data
Definition grok.h:829
uint8_t * exif_buf
Definition grok.h:825
uint8_t * xml_buf
Definition grok.h:831
size_t geotiff_len
Definition grok.h:828
grk_asoc * asoc_boxes
Definition grok.h:833
size_t exif_len
Definition grok.h:826
size_t iptc_len
Definition grok.h:822
size_t ipr_len
Definition grok.h:830
uint8_t * iptc_buf
Definition grok.h:821