[OIIO] seed details, synthesize RGB spec #1593

This commit is contained in:
Nick Black 2021-04-25 16:10:01 -04:00
parent 6f07ecb556
commit da6b8281d5
3 changed files with 9 additions and 6 deletions

View File

@ -69,11 +69,6 @@ char* oiio_subtitle(const ncvisual* ncv) { // no support in OIIO
return NULL;
}
void oiio_details_seed(ncvisual* ncv) {
(void)ncv;
// FIXME?
}
int oiio_init(int loglevel __attribute__ ((unused))) {
// FIXME set OIIO global attribute "debug" based on loglevel
// FIXME check OIIO_VERSION_STRING components against linked openimageio_version()

View File

@ -26,6 +26,13 @@ auto oiio_details_destroy(ncvisual_details* deets) -> void {
delete deets;
}
auto oiio_details_seed(ncvisual* ncv) -> void {
int pixels = ncv->rows * ncv->cols;
ncv->details->frame = std::make_unique<uint32_t[]>(pixels);
OIIO::ImageSpec rgbaspec{ncv->cols, ncv->rows, 4, OIIO::TypeDesc(OIIO::TypeDesc::UINT8, 4)};
ncv->details->ibuf = std::make_unique<OIIO::ImageBuf>(rgbaspec, ncv->data);
}
auto oiio_create() -> ncvisual* {
auto nc = new ncvisual{};
if((nc->details = oiio_details_init()) == nullptr){
@ -119,7 +126,7 @@ int oiio_decode_loop(ncvisual* ncv){
// resize, converting to RGBA (if necessary) along the way
int oiio_resize(ncvisual* nc, int rows, int cols) {
//fprintf(stderr, "%d/%d -> %d/%d on the resize\n", ncv->rows, ncv->cols, rows, cols);
//fprintf(stderr, "%d/%d -> %d/%d on the resize\n", nc->rows, nc->cols, rows, cols);
auto ibuf = std::make_unique<OIIO::ImageBuf>();
if(nc->details->ibuf && (nc->cols != cols || nc->rows != rows)){ // scale it
OIIO::ImageSpec sp{};

View File

@ -10,6 +10,7 @@ extern "C" {
int oiio_decode(ncvisual* nc);
struct ncvisual_details* oiio_details_init(void);
void oiio_printbanner(const struct notcurses* nc);
void oiio_details_seed(struct ncvisual* ncv);
int oiio_blit(ncvisual* ncv, int rows, int cols,
struct ncplane* n, const struct blitset* bset,
int leny, int lenx, const blitterargs* bargs);