Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualAhmed Egyptian

Posted 13 March 2013 - 03:35 PM

Hi All,

I tried to figure out the meaning of that function, I couldn't, even tried on paper, but didn't get it. Would someone explain that to me smile.png ? If that's possible with Ascii text or some images would be so much appreciated.

 

 

static void inline resizeRow(uint32_t *dst, uint32_t *src, uint32_t pixelsPerRow)

{
        uint8_t * pSrc8 = (uint8_t *)src;
        uint8_t * pDest8 = (uint8_t *)dst;
        int stride = pixelsPerRow * sizeof(uint32_t);
        int x;
        int r, g, b, a;


        for (x=0; x<pixelsPerRow; x++)
        {
                r = pSrc8[0] + pSrc8[4] + pSrc8[stride+0] + pSrc8[stride+4];
                g = pSrc8[1] + pSrc8[5] + pSrc8[stride+1] + pSrc8[stride+5];
                b = pSrc8[2] + pSrc8[6] + pSrc8[stride+2] + pSrc8[stride+6];
                a = pSrc8[3] + pSrc8[7] + pSrc8[stride+3] + pSrc8[stride+7];
                pDest8[0] = (uint8_t)((r + 2)/4); // average with rounding
                pDest8[1] = (uint8_t)((g + 2)/4);
                pDest8[2] = (uint8_t)((b + 2)/4);
                pDest8[3] = (uint8_t)((a + 2)/4);
                pSrc8 += 8; // skip forward 2 source pixels
                pDest8 += 4; // skip forward 1 destination pixel
        }
}
 

#2Ahmed Egyptian

Posted 13 March 2013 - 03:34 PM

Hi All,

I tried to figure out the meaning of that function, I couldn't, even tried on paper, but didn't get it. Would someone explain that to me smile.png ?

 

 

static void inline resizeRow(uint32_t *dst, uint32_t *src, uint32_t pixelsPerRow)

{
        uint8_t * pSrc8 = (uint8_t *)src;
        uint8_t * pDest8 = (uint8_t *)dst;
        int stride = pixelsPerRow * sizeof(uint32_t);
        int x;
        int r, g, b, a;


        for (x=0; x<pixelsPerRow; x++)
        {
                r = pSrc8[0] + pSrc8[4] + pSrc8[stride+0] + pSrc8[stride+4];
                g = pSrc8[1] + pSrc8[5] + pSrc8[stride+1] + pSrc8[stride+5];
                b = pSrc8[2] + pSrc8[6] + pSrc8[stride+2] + pSrc8[stride+6];
                a = pSrc8[3] + pSrc8[7] + pSrc8[stride+3] + pSrc8[stride+7];
                pDest8[0] = (uint8_t)((r + 2)/4); // average with rounding
                pDest8[1] = (uint8_t)((g + 2)/4);
                pDest8[2] = (uint8_t)((b + 2)/4);
                pDest8[3] = (uint8_t)((a + 2)/4);
                pSrc8 += 8; // skip forward 2 source pixels
                pDest8 += 4; // skip forward 1 destination pixel
        }
}
 

 


#1Ahmed Egyptian

Posted 13 March 2013 - 03:33 PM

Hi All,

I tried to figure out the meaning of that function, I couldn't, even tried on paper, but didn't get it. Would someone explain that to me :) ?

 

 

static void inline resizeRow(uint32_t *dst, uint32_t *src, uint32_t pixelsPerRow)

{
        uint8_t * pSrc8 = (uint8_t *)src;
        uint8_t * pDest8 = (uint8_t *)dst;
        int stride = pixelsPerRow * sizeof(uint32_t);
        int x;
        int r, g, b, a;


        for (x=0; x<pixelsPerRow; x++)
        {
                r = pSrc8[0] + pSrc8[4] + pSrc8[stride+0] + pSrc8[stride+4];
                g = pSrc8[1] + pSrc8[5] + pSrc8[stride+1] + pSrc8[stride+5];
                b = pSrc8[2] + pSrc8[6] + pSrc8[stride+2] + pSrc8[stride+6];
                a = pSrc8[3] + pSrc8[7] + pSrc8[stride+3] + pSrc8[stride+7];
                pDest8[0] = (uint8_t)((r + 2)/4); // average with rounding
                pDest8[1] = (uint8_t)((g + 2)/4);
                pDest8[2] = (uint8_t)((b + 2)/4);
                pDest8[3] = (uint8_t)((a + 2)/4);
                pSrc8 += 8; // skip forward 2 source pixels
                pDest8 += 4; // skip forward 1 destination pixel
        }
}
 

 


PARTNERS