-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <OpenImageIO/imageio.h> | ||
|
||
#include <string> | ||
|
||
#include "oiio.h" | ||
|
||
extern "C" { | ||
|
||
void deleteImageOutput(ImageOutput *out) { | ||
delete static_cast<OIIO::ImageOutput*>(out); | ||
} | ||
|
||
ImageOutput* ImageOutput_Create(const char* filename, const char* plugin_searchpath) { | ||
std::string s_filename(filename); | ||
std::string s_path(plugin_searchpath); | ||
return (ImageOutput*) OIIO::ImageOutput::create(s_filename, s_path); | ||
} | ||
|
||
const char* ImageOutput_geterror(ImageOutput *out) { | ||
std::string sstring = static_cast<OIIO::ImageOutput*>(out)->geterror(); | ||
if (sstring.empty()){ | ||
return NULL; | ||
} | ||
return sstring.c_str(); | ||
} | ||
|
||
const char* ImageOutput_format_name(ImageOutput *out) { | ||
return static_cast<OIIO::ImageOutput*>(out)->format_name(); | ||
} | ||
|
||
const ImageSpec* ImageOutput_spec(ImageOutput *out) { | ||
const OIIO::ImageSpec *spec = &(static_cast<OIIO::ImageOutput*>(out)->spec()); | ||
return (ImageSpec*) spec; | ||
} | ||
|
||
bool ImageOutput_supports(ImageOutput *out, const char* feature){ | ||
std::string s_feature(feature); | ||
return static_cast<OIIO::ImageOutput*>(out)->supports(s_feature); | ||
} | ||
|
||
|
||
} // extern "C" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package oiio | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestOpenImageOutput(t *testing.T) { | ||
out, err := OpenImageOutput("png") | ||
if err != nil { | ||
t.Fatal(err.Error()) | ||
} | ||
|
||
out.Supports("xyz") | ||
|
||
actual := out.FormatName() | ||
if actual != "png" { | ||
t.Errorf("Expected FormatName 'png' but got actual %q", actual) | ||
} | ||
|
||
} | ||
|
||
func TestImageOutputSupports(t *testing.T) { | ||
|
||
// Test using .exr format as it has the widest support feature | ||
out, err := OpenImageOutput("exr") | ||
|
||
if err != nil { | ||
t.Fatal(err.Error()) | ||
} | ||
|
||
expectSupports := []string{ | ||
"tiles", | ||
"mipmap", | ||
"alpha", | ||
"nchannels", | ||
"channelformats", | ||
"displaywindow", | ||
"origin", | ||
"negativeorigin", | ||
"arbitrary_metadata", | ||
"exif", | ||
"iptc", | ||
"multiimage", | ||
"deepdata", | ||
} | ||
|
||
for _, expect := range expectSupports { | ||
if !out.Supports(expect) { | ||
t.Errorf("Expected support for feature %q (format %q)", expect, out.FormatName()) | ||
} | ||
} | ||
|
||
if out.Supports("invalidfeature") { | ||
t.Error("Supports() returned true for a feature we expected to report false") | ||
} | ||
|
||
} |