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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:00:42+00:00 2026-05-29T07:00:42+00:00

I want to write a function for converting BGRA in BGR. void convertBGRAViewtoBGRView( const

  • 0

I want to write a function for converting BGRA in BGR.
void convertBGRAViewtoBGRView( const boost::gil::bgra8_view_t &src, boost::gil::bgr8_view_t dst )
If I write it like this:

size_t numPixels = src.width() * src.height();
boost::gil::bgra8_view_t::iterator it = src.begin();
boost::gil::bgr8_view_t::iterator itD = dst.begin();
for( int i = 0; i < numPixels; ++i ){

    boost::gil::bgra8_pixel_t pixe(it[0]);
    *it++;
    boost::gil::bgr8_pixel_t pix(pixe[0],pixe[1],pixe[2]);

    *itD++ = pix;        
}

it works, but it is very slow. So I want to use NEON instructions and therefore I need a pointer for example (UInt8*) or (UInt32*).
I tried it like this:

UInt32 *temp = (UInt32*)&src(0,0);
for( int i = 0; i < numPixels; ++i ){        
    boost::gil::bgr8_pixel_t pixk( (( *temp) & 0xff), ( (*temp>>8) & 0xff), ((*temp >> 16 )& 0xff));
    *itD++ = pixk;
    temp += 1;
}

This works more or less, but the resulting image isn’t correct. I think maybe a problem with alignment. Does anyone have an idea how get it to work?
This solution is about 3 times faster than the solution with the iterator.

UPDATE:
I checked with the debugger:
the src has width 480×360 and till i == 259 everything is correct, but afterwords the solution with iterator and pointer is different.

Thanks.

  • 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-29T07:00:43+00:00Added an answer on May 29, 2026 at 7:00 am

    After some computation based on your answer, I found out that 360*4 is dividable by anything up to 32, whereas 360*4+8*4 is even dividable by 64. So I guess the reason for the error is that GIL in your case tries to align image rows at 64 byte boundaries and therefore doesn’t store them contiguously.

    Because of this it is always advised to use the generic iterator interface instead of messing with the raw memory directly, otherwise you have to be completely sure about any such alignment conventions (but maybe they are perfectly standardized and can be read somewhere in the documentation).

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

Sidebar

Related Questions

I want to write a function in Python that returns different fixed values based
I want to write a function that takes an array of letters as an
I want to write a function that accepts two objects as parameters and compare
I want to write a function that returns the nearest next power of 2
I want to write a function that accepts a parameter which can be either
I want to write a function like equalp, which gives #t for (equalp Xy
I want to write a function which can validate a given value (passed as
i want to write a function that prints multi-dimensional objects which are text (or
I want to write 'twice' function that takes a function and an argument and
I have problem with fancybox. I want to write a function that will run

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.