add notcurses_image_open() #23
parent
f1e7b4a8e5
commit
f20e8fde4b
@ -0,0 +1,14 @@
|
||||
#include <libavutil/error.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include "notcurses.h"
|
||||
|
||||
int notcurses_image_open(struct notcurses* nc, const char* filename){
|
||||
AVFormatContext* ps = NULL;
|
||||
int ret = avformat_open_input(&ps, filename, NULL, NULL);
|
||||
if(ret < 0){
|
||||
fprintf(stderr, "Couldn't open %s (%s)\n", filename, av_err2str(ret));
|
||||
return ret;
|
||||
}
|
||||
avformat_free_context(ps);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
#include <notcurses.h>
|
||||
#include "main.h"
|
||||
|
||||
class LibavTest : public :: testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
notcurses_options nopts{};
|
||||
nopts.outfd = STDIN_FILENO;
|
||||
nc_ = notcurses_init(&nopts);
|
||||
ASSERT_NE(nullptr, nc_);
|
||||
n_ = notcurses_stdplane(nc_);
|
||||
ASSERT_NE(nullptr, n_);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if(nc_){
|
||||
EXPECT_EQ(0, notcurses_stop(nc_));
|
||||
}
|
||||
}
|
||||
|
||||
struct notcurses* nc_{};
|
||||
struct ncplane* n_{};
|
||||
};
|
||||
|
||||
TEST_F(LibavTest, LoadImage) {
|
||||
int ret = notcurses_image_open(nc_, "../tools/dsscaw-purp.png");
|
||||
ASSERT_EQ(0, ret);
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 980 KiB |
Loading…
Reference in New Issue