Hi, sorry, this one does not ring a bell, and I really don't have any Windows knowledge to help out with.
It would be helpful if you could make a full DEBUG build of OIIO and catch the crash in a debugger, so at least we could narrow down where in the code it's running into trouble. > On Mar 23, 2017, at 3:03 AM, Heng Zhou <[email protected]> wrote: > > Hi, Larry Gritz: > > Thank you so much for your help. I successfully ran the code on Linux and got > what I want. The only problem is when running on Windows, the output is all > black without any text. I guess it is due to the OpenImageIO binary library I > used. So I was wondering if you could please take a look at it. > > The OpenImageIO binary library I am using on Windows is downloaded from here > <https://urldefense.proofpoint.com/v2/url?u=http-3A__jesnault.fr_website_wp-2Dcontent_uploads_OIIO-2Dinstall-2Dmsvc11-2Dx64.7z&d=DwMFaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=yN_mtgnvh2k3WD8QIZam9tbZUPHJMoZc_18KfiSrxx0&m=XXy2-fXn17psA3p18bZUaPjQ7xX0HVz9zDgc_F0CCMc&s=r264H7-f1kWULEwvRNvCF4iCm2Eh1ZJ7YPjKzpDPYwU&e=> > in this webpage > <https://urldefense.proofpoint.com/v2/url?u=http-3A__jesnault.fr_website_how-2Dto-2Dbuild-2Dwindows-2Dimages-2Dlibraries_&d=DwMFaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=yN_mtgnvh2k3WD8QIZam9tbZUPHJMoZc_18KfiSrxx0&m=XXy2-fXn17psA3p18bZUaPjQ7xX0HVz9zDgc_F0CCMc&s=iCu1OtJNTi82EdHi_1lId-kdQIogtxzTKSULtDtvcWE&e=>. > I can correctly link it in Visual Studio 2015 but when running the statement > ImageOutput::create("file_name.exr");, the program crashes with the following > error message: > <untitled.png> > > I have no idea how to fix this problem. I guess the binary library files I > downloaded have some problem because the above webpage says it is compiled > for Visual Studio 2012 but I am using Visual Studio 2015. The instructions of > building OpenImageIO from source are either not working > (https://sites.google.com/site/openimageio/building-oiio-on-windows > <https://urldefense.proofpoint.com/v2/url?u=https-3A__sites.google.com_site_openimageio_building-2Doiio-2Don-2Dwindows&d=DwMFaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=yN_mtgnvh2k3WD8QIZam9tbZUPHJMoZc_18KfiSrxx0&m=XXy2-fXn17psA3p18bZUaPjQ7xX0HVz9zDgc_F0CCMc&s=uGh1rGb2DG9tLqQL8XydSsDTeGr7qzVikvQ68t2rVgs&e=>) > or looks too daunting for me > (http://jesnault.fr/website/how-to-build-windows-images-libraries/?lang=en > <https://urldefense.proofpoint.com/v2/url?u=http-3A__jesnault.fr_website_how-2Dto-2Dbuild-2Dwindows-2Dimages-2Dlibraries_-3Flang-3Den&d=DwMFaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=yN_mtgnvh2k3WD8QIZam9tbZUPHJMoZc_18KfiSrxx0&m=XXy2-fXn17psA3p18bZUaPjQ7xX0HVz9zDgc_F0CCMc&s=ajCPIbmNvOONZsMUliOCqyoFoIENFiUtf8oWDDveVlY&e=>), > so what I'd like to ask is: if you (or anyone else) happen to have a > compiled binary library of OpenImageIO for Windows 7 64-bit, could you please > share that with me? Thanks a lot! > > Thank you again for teaching me how to render text. > > Best Regards > Heng Zhou > > On Tue, Mar 21, 2017 at 1:11 PM, Larry Gritz <[email protected] > <mailto:[email protected]>> wrote: >> On Mar 21, 2017, at 4:40 AM, Heng Zhou <[email protected] >> <mailto:[email protected]>> wrote: >> >> Thank you for the interesting post. I happen to be working on a project in >> which I need to composite a text onto a background image. But both the text >> and background image are generated by C++ code, so I hope I can write a few >> lines of code to do the same job as what oiiotool does in your post. I have >> no idea how. Could you (or any other nice people) please share a C++ snippet >> with me? I don't need a shadowed text; just displaying it on the image I >> generated would suffice. Thanks a lot! >> > > > > Sure! > > I'm just doing this off the top of my head, so please double check against > the docs, but this should point you there. > > #include <OpenImageIO/imagebuf.h> > #include <OpenImageIO/imagebufalgo.h> > using namespace OIIO; > ... > > To load a background image: > > ImageBuf bg ("background.tif"); > > Or to *wrap* an existing buffer (the ImageBuf won't allocate or own the pixel > memory): > > unsigned char image[xres*yres*channels]; > ImageSpec spec (xres, yres, channels, TypeDesc::UINT8); > ImageBuf bg (spec, image); > > Alternately, to *copy* from an existing buffer (with the ImageBuf allocating > and managing its own pixel memory): > > ImageBuf bg (spec); > bg.set_pixels (ROI(0,xres,0,yres,0,1,0,channels), TypeDesc::UINT8, image); > > To add text to your buffer: > > float textcolor[3] = { 1, 1, 1 }; // MUST be at least as long as the > number of channels! > ImageBufAlgo::render_text (bg, 50 /* x */, 100 /* y */, > "Hello, world!" /* text to draw */, > 32 /* font size */, "" /* font name, empty for > default */, > textcolor); > > And then to save the image to disk: > > bg.set_write_format (TypeDesc::UINT8); > bg.write ("output.tif"); > > Or, if you had "wrapped" an image, the text will already be in your original > buffer. > > Or, if you *copied* the image, you can copy out again like this: > > bg.get_pixels (ROI(0,xres,0,yres,0,1,0,channels), TypeDesc::UINT8, image); > > > Does that answer your question? > > >> >> On Tue, Mar 21, 2017 at 2:00 AM, Larry Gritz <[email protected] >> <mailto:[email protected]>> wrote: >> Let's see if this comes through the mail list with images intact. If not, >> I'll make it into a wiki page or something. >> >> --- >> >> Let's say you have a text image, white on black, and you want to composite >> it over an existing background image. Let's quickly generate one to have it >> as an example: >> >> $ oiiotool -create 128x96 3 -text:x=20:y=50:size=32:color=1,0,0 "Hello" >> -d uint8 -o text.tif >> >> <text.png> >> >> And let's make an RGBA file for our background using something from our >> testsuite: >> >> $ cp tahoe-tiny.tif ./bg.tif >> >> <bg.png> >> >> Now, we could naively composite it: >> >> $ oiiotool text.tif bg.tif --over -o comp.tif >> oiiotool ERROR: over : images must have alpha channels >> >> Oops. Well, adding alpha to the background would be easy, >> >> oiiotool ... bg.tif -ch R,G,B,A=1.0 ... >> >> But what about the foreground? >> >> Well, if we really were just using oiiotool to make the text in the first >> place, we could have given it an alpha channel: >> >> $ oiiotool -create 128x96 4 -text:x=20:y=50:size=32:color=1,0,0,1 >> "Hello" -d uint8 -o textrgba.tif >> >> But let's suppose for a minute that we didn't have that luxury, we have an >> RGBA image of text and that's that. We can construct an alpha channel from >> the luminance, then thresholding it, like this, step by step (first, an >> invalid command line that explains, then a fully valid command line): >> >> oiiotool text.tif # read input >> --dup # duplicate it on the stack >> --chsum:weight=.2126,.7152,.0722 # compute luminance as >> single channel >> --mulc 20 # multiply it... >> --clamp:min=0:max=1 # ...and clamp to threshold >> --chappend # mash the original RGB with the >> luminance-computed alpha >> --chnames R,G,B,A # make sure that new channel has the right >> name >> bg.tif # read the background >> --ch R,G,B,A=1.0 # add an alpha channel to the backgound >> (opaque) >> --over # composite >> -o comp1.tif # output >> >> $ oiiotool text.tif --dup --chsum:weight=.2126,.7152,.0722 --mulc 20 >> --clamp:min=0:max=1 --chappend -chnames R,G,B,A bg.tif -ch R,G,B,A=1.0 >> --over -o comp1.tif >> >> The purpose of the --mulc and --clamp is so that a dimmer text color (less >> than luminance 1.0) won't make a semi-transparent alpha and show the >> background color through the text. >> >> <comp1.png> >> >> This is fairly nice, but a little naive about the text readability. What we >> really want is a bit of a blurred drop shadow, black rim around the letters, >> for better visibility against light backgrounds. So let's add a blur to the >> alpha we are generating, thus making the alpha image extend past the edges >> of the letters themselves to suppress part of the background: >> >> $ oiiotool text.tif --dup --chsum:weight=.2126,.7152,.0722 --blur 5x5 >> --mulc 20 --clamp:min=0:max=1 --chappend -chnames R,G,B,A bg.tif -ch >> R,G,B,A=1.0 --over -o comp2.tif >> >> <comp2.png> >> >> Voilà! Much nicer! Adjust the blur size and mulc threshold to suit your >> taste. >> >> >> >> -- >> Larry Gritz >> [email protected] <mailto:[email protected]> >> >> >> >> _______________________________________________ >> Oiio-dev mailing list >> [email protected] <mailto:[email protected]> >> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org >> <https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openimageio.org_listinfo.cgi_oiio-2Ddev-2Dopenimageio.org&d=DwMFaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=yN_mtgnvh2k3WD8QIZam9tbZUPHJMoZc_18KfiSrxx0&m=euk9A4Ibxbdf6xWtliyUXHguHMD7O_gAzN3HZ6km25E&s=I64wq-2NHLavZXU1sdfiiXSdK59wX0HuUtIxnG4WhD0&e=> >> >> >> _______________________________________________ >> Oiio-dev mailing list >> [email protected] <mailto:[email protected]> >> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org >> <https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openimageio.org_listinfo.cgi_oiio-2Ddev-2Dopenimageio.org&d=DwMFaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=yN_mtgnvh2k3WD8QIZam9tbZUPHJMoZc_18KfiSrxx0&m=XXy2-fXn17psA3p18bZUaPjQ7xX0HVz9zDgc_F0CCMc&s=Hd0yDoQco-n-nchovBIwrYc8Ltg429M_AosmjJJtY2w&e=> > > -- > Larry Gritz > [email protected] <mailto:[email protected]> > > > > _______________________________________________ > Oiio-dev mailing list > [email protected] <mailto:[email protected]> > http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org > <https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openimageio.org_listinfo.cgi_oiio-2Ddev-2Dopenimageio.org&d=DwMFaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=yN_mtgnvh2k3WD8QIZam9tbZUPHJMoZc_18KfiSrxx0&m=XXy2-fXn17psA3p18bZUaPjQ7xX0HVz9zDgc_F0CCMc&s=Hd0yDoQco-n-nchovBIwrYc8Ltg429M_AosmjJJtY2w&e=> > > > _______________________________________________ > Oiio-dev mailing list > [email protected] > http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org -- Larry Gritz [email protected]
_______________________________________________ Oiio-dev mailing list [email protected] http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
