New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
making a stab at generated images by bending the null image plugin #4197
Comments
You can already do this, as you suspect, by writing a custom ImageInput plugin that does whatever you want to supply the pixels when it's asked for read_tile(). (I recommend making it look like it's tiled, rather then scanline.) Here's one such implementation, found in the OSL project, the makes an ImageInput that, instead of reading files, runs OSL shaders to generate the pixel values: https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/main/src/osl.imageio/oslinput.cpp I guess what you're suggesting here is that we make a procedural ImageInput like this, as part of the OIIO project, but instead of coding a specific procedural pattern, we allow it to take a configuration parameter that's a function pointer that supplies the value of one pixel. The point would be that somebody could then use it by ONLY supplying the function pointer to the "give me one pixel" (or "give me one tile") function instead of needing to bother setting up the rest of the ImageInput facade. |
🎣 Mackerel! |
As I said - I wanted something with minimal coding effort, short of writing a custom plugin. I feel the null image plugin is underused - the extra functionality takes nothing away from it, but instead brings out it's potential. I suppose, though, that I might as well copy and paste from other code which already implements a similar plugin, so thanks for the link! I wrote my slot-in code to serve both requests for scanlines and tiles - since the generator is pixel-based, this is simple, the read_native_tile and read_native_scanline both call the per-pixel code and user code can choose which interface is preferred, relying on the extant infrastructure code. Using the std::map to introduce the std::function can serve two purposes: one might set up a set of 'stock' objects providing common generated images and at the same time user code can add functions at runtime which are found in the map via their name. Since the REST API code is already there, one might even consider passing stuff through to the plugin. Ha! mackerel... the last mackerel you hung out to attract contributors hasn't yielded anything yet. Let's see if anyone bites now. |
Is your feature request related to a problem? Please describe.
I was looking for 'an easy way in' to introduce arbitrary generated image content with minimal coding effort. My problem was that I have such content and I did not find a way to make OIIO 'suck it in'.
Describe the solution you'd like
I want this capability to 'look like' an image, in order to make it 'palatable' for the higher OIIO functions.
Describe alternatives you've considered
I considered writing a specific plugin, but to flesh out a plugin for the purpose requires considerable coding effort. I looked at the extant plugins, and I found a candidate which can easily be bent to the task: the 'null' image format. While this provides a nice infrastructure, it's core functionality is very simple: colour pixels with some default colour. If, instead, it can be made to colour pixels by calling a user-provided function, it becomes much more versatile and can do the job I want done perfectly.
I have coded a proof of concept. First, I introduced a header 'feeder.h' into the OpenImageIO includes. It looks like this:
The changes to the plugin are small - rather than pasting the entire code here, I just give the diff, I'm sure you'll get my drift:
To use the 'feeder', it can be specified in the REST parameters, passing an image 'filename' like this:
foo.null?RES=640x480&CHANNELS=3&FEED=feed_gradient&TYPE=uint8
The text was updated successfully, but these errors were encountered: