Hi all, I'm new to odin and also come from a mostly python based programming experience 🙂
I'm trying to understand how the OpenEXRCore library works so that I can load up some images for use with raylib. To make things simple I'm starting with a non compressed scanline exr file and just trying to get the RGB pixel values (ignorning anything else). I've got this non functional code so far, which compiles but gives a memory error "(EXR_ERR_READ_IO) Unable to read requested data: (998) Invalid access to memory location."
package main
import "core:fmt"
import exr "vendor:OpenEXRCore"
main :: proc() {
ctxt: exr.context_t
ctxt_initializer := exr.DEFAULT_CONTEXT_INITIALIZER
exr_file := exr.start_read(&ctxt, "X:/tmp/text.exr", &ctxt_initializer)
defer exr.finish(&ctxt)
width: int = 1920
height: int = 1080
chunk_info: exr.chunk_info_t
for y := 0; y < height; y += 1 {
read_head := exr.read_scanline_chunk_info(ctxt, 0, cast(i32)y, &chunk_info)
packed_data := make([]u8, cast(int)chunk_info.packed_size)
read_chunk := exr.read_chunk(ctxt, 0, &chunk_info, &packed_data)
for x := 0; x < width; x += 1 {
r := packed_data[x]
g := packed_data[x]
b := packed_data[x]
fmt.printf("Pixel (%d, %d): R=%.3f, G=%.3f, B=%.3f\n", x, y, r, g, b)
}
}
}
I'm sure apart from missing some basics I've probably got something wrong with how pointers work. I'd really appricate if someone can point me in the right direction!
I've made something similar in python before using OpenImageIO to read the files, PyOpenColorIO to do color space conversion, numpy for reformatting and finally PyQt to display it, but as you can imagine that is painfully slow. So I'm at the beginning of trying to make something more performant!