MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / af_draw_image

Function af_draw_image

src/api/c/image.cpp:84–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84af_err af_draw_image(const af_window window, const af_array in,
85 const af_cell* const props) {
86 try {
87 if (window == 0) { AF_ERROR("Not a valid window", AF_ERR_INTERNAL); }
88
89 const ArrayInfo& info = getInfo(in);
90
91 af::dim4 in_dims = info.dims();
92 af_dtype type = info.getType();
93 DIM_ASSERT(0, in_dims[2] == 1 || in_dims[2] == 3 || in_dims[2] == 4);
94 DIM_ASSERT(0, in_dims[3] == 1);
95
96 makeContextCurrent(window);
97 fg_image image = NULL;
98
99 switch (type) {
100 case f32: image = convert_and_copy_image<float>(in); break;
101 case b8: image = convert_and_copy_image<char>(in); break;
102 case s32: image = convert_and_copy_image<int>(in); break;
103 case u32: image = convert_and_copy_image<uint>(in); break;
104 case s16: image = convert_and_copy_image<short>(in); break;
105 case u16: image = convert_and_copy_image<ushort>(in); break;
106 case s8: image = convert_and_copy_image<schar>(in); break;
107 case u8: image = convert_and_copy_image<uchar>(in); break;
108 default: TYPE_ERROR(1, type);
109 }
110
111 ForgeModule& _ = forgePlugin();
112 auto gridDims = forgeManager().getWindowGrid(window);
113 FG_CHECK(_.fg_set_window_colormap(window, (fg_color_map)props->cmap));
114 if (props->col > -1 && props->row > -1) {
115 FG_CHECK(_.fg_draw_image_to_cell(
116 window, gridDims.first, gridDims.second,
117 props->row * gridDims.second + props->col, image, props->title,
118 true));
119 } else {
120 FG_CHECK(_.fg_draw_image(window, image, true));
121 }
122 }
123 CATCHALL;
124
125 return AF_SUCCESS;
126}

Callers 1

imageMethod · 0.50

Calls 4

makeContextCurrentFunction · 0.85
getWindowGridMethod · 0.80
dimsMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected