def writeTexture(scrBuffer, outFile): global errorFlag try: config = ImageSpec() # config.attribute("maketx:highlightcomp", 1) config.attribute("maketx:filtername", "lanczos3") # config.attribute("maketx:opaquedetect", 1) config.attribute("maketx:oiio options", 1) scrBuffer.set_write_tiles(tileSize, tileSize) ImageBufAlgo.make_texture(oiio.MakeTxTexture, scrBuffer, outFile, config) errorFlag = 0 except Exception as e: errorFlag = 1 tqdm.write( prefix + Fore.RED + "Error on conversion. Maybe wrong/corrupt texture file or resolution too high." )
bad = ImageBuf("../oiiotool-fixnan/bad.exr") b = ImageBuf() ImageBufAlgo.fixNonFinite(b, bad, oiio.NONFINITE_BOX3) write(b, "box3.exr") bad.clear() # fillholes_pushpull b = ImageBuf() ImageBufAlgo.fillholes_pushpull(b, ImageBuf("../oiiotool/ref/hole.tif")) write(b, "tahoe-filled.tif", oiio.UINT8) # over b = ImageBuf() ImageBufAlgo.over(b, ImageBuf("../oiiotool-composite/a.exr"), ImageBuf("../oiiotool-composite/b.exr")) write(b, "a_over_b.exr") # FIXME - no test for zover (not in oiio-composite either) # FIXME - no test for render_text # histogram, histogram_draw, # make_texture ImageBufAlgo.make_texture(oiio.MakeTxTexture, ImageBuf("../oiiotool/tahoe-small.tif"), "tahoe-small.tx") # capture_image - no test print "Done." except Exception as detail: print "Unknown exception:", detail
write(b, "box3.exr") bad.clear() # fillholes_pushpull b = ImageBuf() ImageBufAlgo.fillholes_pushpull(b, ImageBuf("../oiiotool/ref/hole.tif")) write(b, "tahoe-filled.tif", oiio.UINT8) # over b = ImageBuf() ImageBufAlgo.over(b, ImageBuf("../oiiotool-composite/a.exr"), ImageBuf("../oiiotool-composite/b.exr")) write(b, "a_over_b.exr") # FIXME - no test for zover (not in oiio-composite either) # FIXME - no test for render_text # histogram, histogram_draw, # make_texture ImageBufAlgo.make_texture(oiio.MakeTxTexture, ImageBuf("../oiiotool/tahoe-small.tif"), "tahoe-small.tx") # capture_image - no test print "Done." except Exception as detail: print "Unknown exception:", detail
broi = b.roi textsize = ImageBufAlgo.text_size("Centered", 40) if textsize.defined: x = broi.xbegin + broi.width // 2 - (textsize.xbegin + textsize.width // 2) y = broi.ybegin + broi.height // 2 - (textsize.ybegin + textsize.height // 2) ImageBufAlgo.render_text(b, x, y, "Centered", 40) write(b, "textcentered.tif", oiio.UINT8) # histogram, histogram_draw, b = make_constimage(100, 100, 3, oiio.UINT8, (.1, .2, .3)) Rhist = ImageBufAlgo.histogram(b, channel=0, bins=4) Ghist = ImageBufAlgo.histogram(b, channel=1, bins=4) Bhist = ImageBufAlgo.histogram(b, channel=2, bins=4) print("R hist: ", Rhist) print("G hist: ", Ghist) print("B hist: ", Bhist) # make_texture ImageBufAlgo.make_texture( oiio.MakeTxTexture, ImageBuf(OIIO_TESTSUITE_ROOT + "/oiiotool/src/tahoe-small.tif"), "tahoe-small.tx") # capture_image - no test print("Done.") except Exception as detail: print("Unknown exception:", detail)