Mercurial > hg > orthanc-java
comparison JavaSDK/be/uclouvain/orthanc/PixelFormat.java @ 0:3ecef5782f2c
initial commit
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 18 Oct 2023 17:59:44 +0200 |
parents | |
children | 26c08ff926a3 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3ecef5782f2c |
---|---|
1 package be.uclouvain.orthanc; | |
2 | |
3 /** | |
4 * SPDX-FileCopyrightText: 2023 Sebastien Jodogne, UCLouvain, Belgium | |
5 * SPDX-License-Identifier: GPL-3.0-or-later | |
6 */ | |
7 | |
8 /** | |
9 * Java plugin for Orthanc | |
10 * Copyright (C) 2023 Sebastien Jodogne, UCLouvain, Belgium | |
11 * | |
12 * This program is free software: you can redistribute it and/or | |
13 * modify it under the terms of the GNU General Public License as | |
14 * published by the Free Software Foundation, either version 3 of the | |
15 * License, or (at your option) any later version. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, but | |
18 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 * General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program. If not, see http://www.gnu.org/licenses/. | |
24 **/ | |
25 | |
26 | |
27 /** | |
28 * The memory layout of the pixels of an image. | |
29 **/ | |
30 public enum PixelFormat { | |
31 /** | |
32 * Graylevel 8bpp image. The image is graylevel. Each pixel is unsigned and stored | |
33 * in one byte. | |
34 **/ | |
35 GRAYSCALE8(1), | |
36 /** | |
37 * Graylevel, unsigned 16bpp image. The image is graylevel. Each pixel is unsigned | |
38 * and stored in two bytes. | |
39 **/ | |
40 GRAYSCALE16(2), | |
41 /** | |
42 * Graylevel, signed 16bpp image. The image is graylevel. Each pixel is signed and | |
43 * stored in two bytes. | |
44 **/ | |
45 SIGNED_GRAYSCALE16(3), | |
46 /** | |
47 * Color image in RGB24 format. This format describes a color image. The pixels are | |
48 * stored in 3 consecutive bytes. The memory layout is RGB. | |
49 **/ | |
50 RGB24(4), | |
51 /** | |
52 * Color image in RGBA32 format. This format describes a color image. The pixels | |
53 * are stored in 4 consecutive bytes. The memory layout is RGBA. | |
54 **/ | |
55 RGBA32(5), | |
56 /** | |
57 * Unknown pixel format | |
58 **/ | |
59 UNKNOWN(6), | |
60 /** | |
61 * Color image in RGB48 format. This format describes a color image. The pixels are | |
62 * stored in 6 consecutive bytes. The memory layout is RRGGBB. | |
63 **/ | |
64 RGB48(7), | |
65 /** | |
66 * Graylevel, unsigned 32bpp image. The image is graylevel. Each pixel is unsigned | |
67 * and stored in four bytes. | |
68 **/ | |
69 GRAYSCALE32(8), | |
70 /** | |
71 * Graylevel, floating-point 32bpp image. The image is graylevel. Each pixel is | |
72 * floating-point and stored in four bytes. | |
73 **/ | |
74 FLOAT32(9), | |
75 /** | |
76 * Color image in BGRA32 format. This format describes a color image. The pixels | |
77 * are stored in 4 consecutive bytes. The memory layout is BGRA. | |
78 **/ | |
79 BGRA32(10), | |
80 /** | |
81 * Graylevel, unsigned 64bpp image. The image is graylevel. Each pixel is unsigned | |
82 * and stored in eight bytes. | |
83 **/ | |
84 GRAYSCALE64(11); | |
85 | |
86 private int value; | |
87 | |
88 private PixelFormat(int value) { | |
89 this.value = value; | |
90 } | |
91 | |
92 /** | |
93 * Return the enumeration value that corresponds to an integer value of interest. | |
94 * @param value The integer value. | |
95 * @return The enumeration value. | |
96 **/ | |
97 protected static PixelFormat getInstance(int value) { | |
98 if (value == 1) { | |
99 return GRAYSCALE8; | |
100 } | |
101 if (value == 2) { | |
102 return GRAYSCALE16; | |
103 } | |
104 if (value == 3) { | |
105 return SIGNED_GRAYSCALE16; | |
106 } | |
107 if (value == 4) { | |
108 return RGB24; | |
109 } | |
110 if (value == 5) { | |
111 return RGBA32; | |
112 } | |
113 if (value == 6) { | |
114 return UNKNOWN; | |
115 } | |
116 if (value == 7) { | |
117 return RGB48; | |
118 } | |
119 if (value == 8) { | |
120 return GRAYSCALE32; | |
121 } | |
122 if (value == 9) { | |
123 return FLOAT32; | |
124 } | |
125 if (value == 10) { | |
126 return BGRA32; | |
127 } | |
128 if (value == 11) { | |
129 return GRAYSCALE64; | |
130 } | |
131 | |
132 throw new IllegalArgumentException("Value out of range for enumeration PixelFormat: " + value); | |
133 } | |
134 | |
135 /** | |
136 * Get the integer value corresponding to this enumeration value. | |
137 * @return The integer value. | |
138 **/ | |
139 public int getValue() { | |
140 return value; | |
141 } | |
142 } |