Skip to content

Conversation

@dimitre
Copy link
Member

@dimitre dimitre commented May 5, 2024

simplification of pixelbits / bytes, channel count, etc.

@dimitre dimitre marked this pull request as draft May 5, 2024 21:16
@dimitre
Copy link
Member Author

dimitre commented May 11, 2024

it will be closed in favor of

Copy link
Member

@danoli3 danoli3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great

//----------------------------------------------------------------------
template<typename PixelType>
inline ofPixels_<PixelType>::ConstLine::ConstLine(const PixelType * _begin, size_t stride, size_t componentsPerPixel, size_t lineNum, ofPixelFormat pixelFormat)
inline ofPixels_<PixelType>::ConstLine::ConstLine(const PixelType * _begin, size_t stride, size_t componentsPerPixel, size_t lineNum, ofPixelFormat _pixelFormat)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the _

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to differentiate the function parameter to the private member called pixelFormat;

return 1 * sizeof(PixelType) * 8;
static size_t numChannelsFromPixelFormat(ofPixelFormat _pixelFormat) {
std::unordered_map<ofPixelFormat, size_t> pixelFormatChannels {
{ OF_PIXELS_RGB, 3 },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome

return
std::unordered_map<ofPixelFormat, std::string> {
{ OF_PIXELS_GRAY, "OF_PIXELS_GRAY" },
{ OF_PIXELS_GRAY_ALPHA, "OF_PIXELS_GRAY_ALPHA" },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so much cleaner!



PixelType * dstPixels = dst.getData();
auto dstPixels = dst.getData();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be auto I guess

@dimitre dimitre marked this pull request as ready for review July 28, 2024 22:47
@dimitre
Copy link
Member Author

dimitre commented Nov 12, 2025

Looking at this PR now, I think there are contradictions in the way OF handles pixels
example:
getBitsPerChannel / getBytesPerChannel are unusable in OF_PIXELS_RGB565 format

So a better design is needed or better yet, no design at all:
Internal pixel operations in openFrameworks are just tested in 8 bits colors and recently some effort to get it working in 16 bits (https://github.com/openframeworks/openFrameworks/pull/8226/files)

I really think this (pixel manipulation) is not something that should be done at OF core level.
Maybe only API wrapping the functionality (ins / outs of pixel buffers) to some backend (FreeImage, OpenCV, Mango, OpenImageIO, etc) that can do the heavy lifting.
It has the advantage of using much more tested operations, probably some intrinsics optimizations, and less things to take care at OF Core.

@dimitre dimitre added the close label Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants