Skip to content
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

Support for wider channel size in f3d::image #858

Merged
merged 24 commits into from
Jul 10, 2023
Prev Previous commit
Next Next commit
style
  • Loading branch information
Meakk committed Jul 10, 2023
commit 88996767a06ad37d130a119eed777f50f5657e05
12 changes: 8 additions & 4 deletions python/F3DPythonBindings.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ PYBIND11_MODULE(f3d, module)
.value("FLOAT", f3d::image::ChannelType::FLOAT)
.export_values();
Meakk marked this conversation as resolved.
Show resolved Hide resolved

auto setImageBytes = [](f3d::image& img, const py::bytes& data) {
auto setImageBytes = [](f3d::image& img, const py::bytes& data)
{
const py::buffer_info info(py::buffer(data).request());
size_t expectedSize =
img.getChannelCount() * img.getWidth() * img.getHeight() * img.getChannelTypeSize();
Expand All @@ -94,7 +95,8 @@ PYBIND11_MODULE(f3d, module)
img.setContent(info.ptr);
};

auto getImageBytes = [](const f3d::image& img) {
auto getImageBytes = [](const f3d::image& img)
{
size_t expectedSize =
img.getChannelCount() * img.getWidth() * img.getHeight() * img.getChannelTypeSize();
return py::bytes(static_cast<char*>(img.getContent()), expectedSize);
Expand Down Expand Up @@ -258,13 +260,15 @@ PYBIND11_MODULE(f3d, module)

// deprecated functions, will be removed in the next major release
Meakk marked this conversation as resolved.
Show resolved Hide resolved
#ifndef F3D_NO_DEPRECATED
image.def("setResolution", [](f3d::image& img, unsigned int width, unsigned height) {
image.def("setResolution", [](f3d::image& img, unsigned int width, unsigned height)
{
PyErr_WarnEx(PyExc_DeprecationWarning,
"setResolution is deprecated, use the appropriate constructor instead.", 1);
return img.setResolution(width, height);
});

image.def("setChannelCount", [](f3d::image& img, unsigned int channels) {
image.def("setChannelCount", [](f3d::image& img, unsigned int channels)
{
PyErr_WarnEx(PyExc_DeprecationWarning,
"setChannelCount is deprecated, use the appropriate constructor instead.", 1);
return img.setChannelCount(channels);
Expand Down