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 6983311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:24:09+00:00 2026-05-27T18:24:09+00:00

I have made a function for posterizing images. // =( #define ARGB_COLOR(a, r, g,

  • 0

I have made a function for posterizing images.

// =(
#define ARGB_COLOR(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))

inline UINT PosterizeColor(const UINT &color, const float &nColors)
{
    __m128 clr = _mm_cvtepi32_ps(  _mm_cvtepu8_epi32((__m128i&)color)  );

    clr = _mm_mul_ps(clr,  _mm_set_ps1(nColors / 255.0f)  );
    clr = _mm_round_ps(clr, _MM_FROUND_TO_NEAREST_INT);
    clr = _mm_mul_ps(clr, _mm_set_ps1(255.0f / nColors)  );

    __m128i iClr = _mm_cvttps_epi32(clr);

    return ARGB_COLOR(iClr.m128i_u8[12],
                      iClr.m128i_u8[8],
                      iClr.m128i_u8[4],
                      iClr.m128i_u8[0]);
}

in the first line, I unpack the color into 4 floats, but I can’t find the proper way to do the reverse.

I searched through the SSE docs and could not find the reverse of _mm_cvtepu8_epi32

does one exist?

  • 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-27T18:24:10+00:00Added an answer on May 27, 2026 at 6:24 pm

    Unfortunately, there’s no instruction to do that even in AVX (none that I’m aware of). So you will have to do it manually like are right now.

    However, your current method is very sub-optimal and you’re relying on .m128i_u8 which is an MSVC extension. Based on my experience with MSVC, it will use an aligned buffer to access the individual elements. This has a very heavy penalty because of partial-word access.

    Instead of .m128i_u8, use _mm_extract_epi32(). This is in SSE4.1. But you’re already relying with SSE4.1 with _mm_cvtepu8_epi32().

    This situation is particularly bad since you’re working with 1-byte granularity. If you were working with 2-byte (16-bit integer) granularity instead, there is an efficient solution using shuffle intrinsics.

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

Sidebar

Related Questions

I have made this function to calculate color differences in the CIE Lab colorspace,
I have made my Toggle() function that alternates an image (changes the images to
I want to define a function available_translations which lists the translations I have made
Well i have made this jquery code $(document).ready(function(){ $(.graduate).keyup(function(e){ if(e.keyCode!=8 && (e.keyCode<48 && e.keyCode>57)){
Hi have made this function which is made to replicate an error that I
I have made a function to cound the weeks in a year, and that
I have made this function, that seems to work fine, but it return #
i have made a function taketext() which returns a string value of entered text
I have made strcat() function myself but after adding the string it is printing
i have made a function which works just fine with 32-bit dates (acceptable with

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.