Skip to content

Commit fc71519

Browse files
Merge pull request #23 from ukoethe/shape-fix
fixed shape in load_image()/dump_image() (resolves #22)
2 parents b3fb54b + 09f9a82 commit fc71519

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

include/xtensor-io/ximage.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ namespace xt
5858
int channels = spec.nchannels;
5959

6060
// allocate memory
61-
auto image = xarray<T>::from_shape({static_cast<std::size_t>(spec.width),
62-
static_cast<std::size_t>(spec.height),
61+
auto image = xarray<T>::from_shape({static_cast<std::size_t>(spec.height),
62+
static_cast<std::size_t>(spec.width),
6363
static_cast<std::size_t>(spec.nchannels)});
6464

6565
in->read_image(OIIO::TypeDesc::UINT8, image.raw_data());
@@ -94,8 +94,8 @@ namespace xt
9494
// something went wrong
9595
throw std::runtime_error("Error opening file to write image.");
9696
}
97-
OIIO::ImageSpec spec(static_cast<int>(ex.shape()[0]),
98-
static_cast<int>(ex.shape()[1]),
97+
OIIO::ImageSpec spec(static_cast<int>(ex.shape()[1]),
98+
static_cast<int>(ex.shape()[0]),
9999
static_cast<int>(ex.shape()[2]), OIIO::TypeDesc::UINT8);
100100

101101
spec.attribute("CompressionQuality", quality);

test/test_ximage.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@
1414
namespace xt
1515
{
1616
xarray<uint8_t> test_image_rgb = {{{ 0, 0, 0},
17-
{255, 0, 0}},
18-
{{ 0, 255, 0},
19-
{ 0, 0, 255}},
20-
{{228, 135, 255},
17+
{255, 0, 0},
18+
{ 0, 255, 0}},
19+
{{ 0, 0, 255},
20+
{228, 135, 255},
2121
{255, 255, 255}}};
2222

2323
xarray<uint8_t> test_image_rgba = {{{ 0, 0, 0, 255},
24-
{255, 0, 0, 255}},
25-
{{ 0, 255, 0, 255},
26-
{ 0, 0, 255, 255}},
27-
{{228, 135, 255, 255},
24+
{255, 0, 0, 255},
25+
{ 0, 255, 0, 255}},
26+
{{ 0, 0, 255, 255},
27+
{228, 135, 255, 255},
2828
{255, 255, 255, 255}}};
2929

3030
xarray<uint8_t> test_image_jpg = {{{ 0, 0, 35},
31-
{255, 12, 0}},
32-
{{ 0, 255, 0},
33-
{ 5, 10, 236}},
34-
{{222, 124, 237},
31+
{255, 12, 0},
32+
{ 0, 255, 0}},
33+
{{ 5, 10, 236},
34+
{222, 124, 237},
3535
{255, 253, 255}}};
3636

3737
TEST(ximage, load_png)

0 commit comments

Comments
 (0)