Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 307939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:36:16+00:00 2026-05-12T07:36:16+00:00

Ive got some in memory images in various simple formats, which I need to

  • 0

Ive got some in memory images in various simple formats, which I need to quickly convert to another format. In cases where the target format contains an alpha channel but the source does not, alpha should be taken as its full value (eg 0xFF for an 8bit target alpha channel).

I need to be able to deal with various formats, such as A8R8G8B8, R8G8B8A8, A1R4G4B4, R5G6B5, etc.

Conversion of pixels between any of these formats is simple, however I don’t want to have to manually code every single combination, I also don’t want to have a 2 pass solution of converting to a common format (eg A8R8G8B8) before converting again to the final format both for performance reasons, and that if I want to use a higher definition format, say A16B16G16R16 or a floating point I’d either loose some data converting to the intermediate format, or have to rewrite everything to use a different higher definition format…

Ideally id like some sort of enum with values for each format, and then a single method to convert, eg say

enum ImageFormat
{
    FMT_A8R8G8B8,//32bit
    FMT_A1R4G4B4,//16bit
    FMT_R5G6B5,//16bit
    FMT_A32R32G32B32F,//128bit floating point format
    ...
};
struct Image
{
    ImageFormat Format;
    size_t Width, Height;
    size_t Pitch;
    void *Data;
};
Image *ConvertImage(ImageFormat *targetFormat, const Image *sourceImage);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T07:36:17+00:00Added an answer on May 12, 2026 at 7:36 am

    You might want boost::gil.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got some code to convert a large (many gigabytes) XML file into another
I've got some XML files which are larger than available memory, and a large
I've got stuck in a problem with gflags when trying to find some memory
How can I manually set a position with some code? Ok Ive got some
I've got some code which takes a drawing made on in SVG with Raphael
I've got some code which downloads some RSS feeds. I've been using WebClient or
I've got some heavyweight process, which does some video processing. I would like run
I've got some example Python code that I need to mimic in C++. I
I've got some basic questions about C++. Consider the following code in which I
I've got some image processing code in C++ which calculates gradients and finds straight

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.