Fast method to copy memory with translation - ARGB to BGR

前端 未结 11 1894
野趣味
野趣味 2020-12-07 10:47

Overview

I have an image buffer that I need to convert to another format. The origin image buffer is four channels, 8 bits per channel, Alpha, Red, Green, and Blue

11条回答
  •  一向
    一向 (楼主)
    2020-12-07 11:26

    In combination with one of the fast conversion functions here, given access to Core 2s it might be wise to split the translation into threads, which work on their, say, fourth of the data, as in this psudeocode:

    void bulk_bgrFromArgb(byte[] dest, byte[] src, int n)
    {
           thread threads[] = {
               create_thread(bgrFromArgb, dest, src, n/4),
               create_thread(bgrFromArgb, dest+n/4, src+n/4, n/4),
               create_thread(bgrFromArgb, dest+n/2, src+n/2, n/4),
               create_thread(bgrFromArgb, dest+3*n/4, src+3*n/4, n/4),
           }
           join_threads(threads);
    }
    

提交回复
热议问题