Skip to content

Commit baff6bd

Browse files
committed
add: Header에 필요한 data struct를 추가하다.
- EXRWindow : 해당 window 크기 및 위치
1 parent 051669b commit baff6bd

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed

openexr_python/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@
99

1010
__version__ = "0.0.0" # dynamic
1111

12+
from .exr_enums import *
13+
from .exr_channel_info import *
14+
from .exr_channel_sampling_rate import *
1215
from openexr_python.header import Header
16+
from .exr_window import *

openexr_python/exr_channel_info.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from dataclasses import dataclass
2+
from typing import Any, Type
3+
from openexr_python.exr_enums.exr_image_data_type import EXRImageDataType
4+
from openexr_python.exr_channel_sampling_rate import EXRChannelSamplingRate
5+
6+
7+
@dataclass
8+
class EXRChannelInfo:
9+
data_type: Type[EXRImageDataType]
10+
sampling_rate: EXRChannelSamplingRate
11+
12+
@classmethod
13+
def parse_raw2pyobj(cls, raw_channel_info: Any):
14+
return EXRChannelInfo(
15+
data_type=EXRImageDataType.parse_raw2pyobj(
16+
raw_channel_info=raw_channel_info,
17+
),
18+
sampling_rate=EXRChannelSamplingRate.parse_raw2pyobj(
19+
raw_channel_info=raw_channel_info,
20+
),
21+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from dataclasses import dataclass
2+
from typing import Any
3+
4+
5+
@dataclass
6+
class EXRChannelSamplingRate:
7+
x_sampling: int
8+
y_sampling: int
9+
10+
@classmethod
11+
def parse_raw2pyobj(cls, raw_channel_info: Any):
12+
return EXRChannelSamplingRate(
13+
x_sampling=raw_channel_info.xSampling, y_sampling=raw_channel_info.ySampling
14+
)

openexr_python/exr_window.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from dataclasses import dataclass
2+
from typing import Any, Tuple
3+
4+
5+
@dataclass
6+
class EXRWindow:
7+
x_min: int
8+
y_min: int
9+
x_max: int
10+
y_max: int
11+
12+
@property
13+
def min(self) -> Tuple[int, int]:
14+
return (self.x_min, self.y_min)
15+
16+
@property
17+
def max(self) -> Tuple[int, int]:
18+
return (self.x_max, self.y_max)
19+
20+
@property
21+
def width(self) -> int:
22+
assert self.x_max > self.x_min
23+
return 1 + self.x_max - self.x_min
24+
25+
@property
26+
def height(self) -> int:
27+
assert self.y_max > self.y_min
28+
return 1 + self.y_max - self.y_min
29+
30+
@classmethod
31+
def parse_raw_to_window(cls, raw_window: Any):
32+
return EXRWindow(
33+
x_min=raw_window.min.x,
34+
y_min=raw_window.min.y,
35+
x_max=raw_window.max.x,
36+
y_max=raw_window.max.y,
37+
)

0 commit comments

Comments
 (0)