Skip to content

Add Image::SetChannelData() function #708

@iche033

Description

@iche033

Desired behavior

Add a function that allows users to set a specific channel of an image, e.g. set the red channel of an RGB image from either another grayscale image or an array of data

Implementation suggestion

One is to add the function:

     bool SetChannelData(Channel _channel,                                         
          const std::vector<unsigned char> &_data) const;  

In the implementation, we make use of the FreeImage_SetChannel API call:

DLL_API BOOL DLL_CALLCONV FreeImage_SetChannel(FIBITMAP *dst, FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel);

Note we'll need to convert the raw std::vector data array to a FIBITMAP first. So need to profile and make sure it is efficient.

Additional context

See https://github.com/gazebosim/gz-common/pull/706/files#r2331699575

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Inbox

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions